void lir_BGD()
{
//在x中添加一列1,对应w0
std::vector> x={
{1,1.1,1.5},
{1,1.3,1.9},
{1,1.5,2.3},
{1,1.7,2.7},
{1,1.9,3.1},
{1,2.1,3.5},
{1,2.3,3.9},
{1,2.5,4.3},
{1,2.7,4.7},
{1,2.9,5.1}
};
std::vector y={
2.5,
3.2,
3.9,
4.6,
5.3,
6,
6.7,
7.4,
8.1,
8.8
};
//学习速率
double alpha=0.01;
std::vector w=std::vector(x[0].size(),0);
//每个w的导数
std::vector deri=std::vector(x[0].size(),0);
int loop=1;
while(loop++<10000) {
for(auto &iter:deri) iter=0;
for(int i=0;i