所以我想在vb.net中使用math.net。我已从网站上复制了c#摘录,并尝试将其转换为vb.net。我已经达到了这一点:
Dim m = Matrix(Of Double).Build.DenseOfArray({{1.0, 4.0}, {2.0, 5.0}, {3.0, 2.0}})
Dim y = Vector(Of Double).Build.DenseOfArray({15, 20, 10})
Dim p = MultipleRegression.NormalEquations(m, y, True)
Dim a = p(0)
Dim b = p(1)
Dim c = p(2)
它不喜欢多重回归线,我不知道为什么。
任何帮助将不胜感激
答案 0 :(得分:3)
带有布尔截距参数的重载当前只接受数组,而不是矩阵(因为你通常已经准备好了正确形状的矩阵)。
手动添加拦截:
Dim m = Matrix(Of Double).Build.DenseOfArray({{1.0, 1.0, 4.0}, {1.0, 2.0, 5.0}, {1.0, 3.0, 2.0}})
Dim y = Vector(Of Double).Build.DenseOfArray({15, 20, 10})
Dim p = MultipleRegression.NormalEquations(m,y)
Dim a = p(0)
Dim b = p(1)
Dim c = p(2)
或代码:
Dim m = Matrix(Of Double).Build.DenseOfArray({{1.0, 4.0}, {2.0, 5.0}, {3.0, 2.0}})
Dim y = Vector(Of Double).Build.DenseOfArray({15, 20, 10})
' add intercept
Dim mi = m.InsertColumn(0, Vector(Of Double).Build.Dense(m.RowCount, 1.0))
Dim p = MultipleRegression.NormalEquations(mi,y)
Dim a = p(0)
Dim b = p(1)
Dim c = p(2)