91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-26
  • 語言: C/C++
  • 標簽:

資源簡介

機器學習,非參數學習算法,局部加權線性回歸,c++實現

資源截圖

代碼片段和文件信息

#include???
#include
using?namespace?std;??
??
const?int?Number?=?6;??
const?int?Dimesion?=?3;??
const?float?learningRate=0.001;???????
const?float?errorThr=1;?//variance?threshold???
const?int?MAX=1000;?????//Max?times?of?iteration???
??
typedef?struct?Data{??
????float?vectorComponent[Dimesion];??
}vectorData;??
??
vectorData?x[Number]?=?{??
???/*?{114}?
????{125}?
????{151}?
????{142}*/??
????{111}??
????{113}??
????{112}??
????{123}??
????{121}??
????{122}??
};??
float?y[Number]={21051358};??
//lwr(局部線性回歸)??
float?weightValue(vectorData?xivectorData?x){??
????float?weight?=?0.0;??
????for(int?i=0;i????????weight+=pow(xi.vectorComponent[i]-x.vectorComponent[i]2);??
????}??
????float?tempWeight?=?exp(-(weight/(2*36)));??
????if(tempWeight<0.02)??
????????tempWeight?=?0.0;??
????return?tempWeight;??
}??
??
float?multiPly(vectorData?x1vectorData?x2){??
????float?temp?=?0.0;??
???for(int?i=0;i????????temp?+=?x1.vectorComponent[i]*x2.vectorComponent[i];??
????}??
????return?temp;??
}??
??
vectorData?addVectorData(vectorData?x1vectorData?x2){??
????vectorData?temp;??
????for(int?i=0;i????????temp.vectorComponent[i]?=?x1.vectorComponent[i]+x2.vectorComponent[i];??
????return?temp;??
}??
??
vectorData?minusVectorData(vectorData?x1vectorData?x2){??
????vectorData?temp;??
????for(int?i=0;i????????temp.vectorComponent[i]?=?x1.vectorComponent[i]-x2.vectorComponent[i];??
????return?temp;??
}??
??
vectorData?numberMultiVectorData(float?paravectorData?x1){??
????vectorData?temp;??
????for(int?i=0;i????????temp.vectorComponent[i]?=?x1.vectorComponent[i]*para;??
????return?temp;??
}??
float?costFunction(vectorData?parameter[]vectorData?inputData[]float?inputResultData[]vectorData?object){??
????float?costValue?=?0.0;??
????float?tempValue?=?0.0;??
????float?weightedValue?=?0.0;??
????for(int?i=0;i????????tempValue?=?0.0;??
??????????
????????//consider?all?the?parameters?although?most?of?them?is?zero???
????????for(int?j=0;j????????????tempValue?+=?multiPly(parameter[j]inputData[i]);??
????????costValue?+=?weightValue(inputData[i]object)*pow((inputResultData[i]-tempValue)2);??????
????}??
??
????return?(costValue/2*4);?

評論

共有 條評論

相關資源