我有下面的python Numpy函数;它可以获取X,一个具有任意数量的列和行的数组,并输出由最小二乘函数预测的Y值。在
什么是数学.Net这个函数的等价物?在
下面是Python代码:
newdataX = np.ones([dataX.shape[0],dataX.shape[1]+1])
newdataX[:,0:dataX.shape[1]]=dataX
# build and save the model
self.model_coefs, residuals, rank, s = np.linalg.lstsq(newdataX, dataY)
您可以使用pythonnet从.NET调用numpy(下面的C代码是从GITHUB复制的):
pythonnet现在唯一“时髦”的部分就是传递numpy数组。在接口上将它们转换为Python列表是可能的,不过这会降低某些情况下的性能。在
https://github.com/pythonnet/pythonnet/tree/develop
输出:
^{pr2}$以下是使用github上发布的F#的示例:
https://github.com/pythonnet/pythonnet/issues/112
我想您正在寻找这个页面上的函数:http://numerics.mathdotnet.com/api/MathNet.Numerics.LinearRegression/MultipleRegression.htm
您有几个选项需要解决:
正规方程:
MultipleRegression.NormalEquations(x, y)
QR分解:
MultipleRegression.QR(x, y)
高级副总裁:
MultipleRegression.SVD(x, y)
法方程速度较快,但数值稳定性较差,而SVD数值稳定性最好,但速度最慢。在
相关问题 更多 >
编程相关推荐