我正在尝试添加一个组件,该组件将对我们应用程序中的数据进行回归分析。我编写了一项服务,该服务使用MathNet数值进行回归以计算各种特征的系数。我正在通过传递与Excel中的回归分析相同的数据来对其进行测试。我正在使用的数据以CSV格式显示在下面:
Accuracy,Age,Boundary Lines,Distance,Unit,County,Similarity,Size,Quality
0.894556528,0.301,1,1,1,1,0.753,0.76,0.625
0.870692849,0.234,1,0.737,1,1,0.598,0.804,0.625
1.044444444,0.49,1,1,1,0,0.714,0.933,0.833
1.04120514,0.165,1,1,1,1,0.224,0.268,0.833
1.157635468,0.179,1,1,1,1,0.224,0.268,0.8
1.080750408,1,1,1,1,1,0.826,0.536,0.833
1.100041511,1,1,1,1,1,0.569,0.5,0.833
0.932113964,1,1,1,1,1,0.78,0.25,0.625
0.966800438,0.267,1,1,1,1,0.916,0.408,0.625
0.941051136,0.212,1,0.713,1,1,0.755,0.667,0.625
0.932835821,0.429,1,1,1,1,1,0.999,1
1.689189189,0.12,1,1,1,1,1,0.941,1
1.199451679,0.292,1,1,1,1,1,0.6,1
0.7,0.188,1,0.981,1,1,1,1,0.333
0.795454545,1,1,1,1,1,1,0.364,0.5
“精度”是相关值,我正在使用其他列作为独立值来计算其他列的系数。当我在Excel中进行回归时,会得到以下结果:
当我在代码中测试数据时,除边界线和单位系数外,我得到相同的值,在Excel中为0,在我的代码中分别为-0.581和0.876
我正在通过创建评级列的矩阵和准确性列的向量并使用DirectRegressionMethod.NormalEquations
来进行计算。
Matrix<double> ratingsMatrix = DenseMatrix.OfRowVectors(ratingsVectors);
Vector<double> accuracyVector = DenseVector.OfEnumerable(accuracyRatings);
Vector<double> coefficientVector = MultipleRegression.DirectMethod(ratingsMatrix, accuracyVector, DirectRegressionMethod.NormalEquations);
我正在尝试找出差异的原因。 Excel的结果可以很好地满足我的需求,因此我希望能够复制它。我怀疑这可能是因为这两列都是1?