0
我有下面的代码,我设法拼凑:如何计算的均方误差
private void CalcMSE(List<Point> data)
{
double sum = 0.0;
foreach (Point item in data)
{
double difference = item.m_x - item.m_y;
sum = sum + difference * difference;
}
double mse = sum/x; //<-- Don't know what x should be!
Console.WriteLine("The mean square error is {0}",mse) ;
}
输入是:
point.m_x = 3;
point.m_y = 1;
pointList.Add(point);
point.m_x = 4;
point.m_y = 4;
pointList.Add(point);
point.m_x = 5;
point.m_y = 6;
pointList.Add(point);
point.m_x = 6;
point.m_y = 6;
pointList.Add(point);
point.m_x = 8;
point.m_y = 10;
pointList.Add(point);
根据那些在知道MSE应是0.77和MSR 40.89
但我不知道x的“公式”是什么(请参阅代码注释)。
任何人都可以帮助我了解线性回归?
这里的。OUPUTS应该是什么
什么'd.Count()'? – Kinetic
data.Count()或Lenght ...或者让一个计数变量在for循环中增加一个。 x将等于计数。 –
你确定...?它给出的值为8 d.Count() – Eminem