在 Math.Net 多元回归中使用矩阵和向量类型
Using Matrix and Vector types in Math.Net MultipleRegression
我已经声明了 MathNet 矩阵和向量类型如下...
Matrix<double> X = Matrix<double>.Build.Dense(sampleSize,2);
Vector<double> yObserved = Vector<double>.Build.Dense(sampleSize);
但是当我打电话给...
Vector<double> p = MultipleRegression.NormalEquations(X, yObserved, true);
Visual Studio 给出错误
Error CS0411 The type arguments for method 'MultipleRegression.NormalEquations(T[][], T[], bool)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
那么,如果不是这样的话,我该如何调用带有 Matrix 和 Vector 参数的 MultipleRegression class?为什么 Visual Studio 发现我的类型编码不明确?
我的代码可以很好地处理矩阵的锯齿状数组;现在我想得到 运行 Matrix/Vector 类型。
MultipleRegression.NormalEquations()
的重载只有 Matrix
和 Vector
参数集组合的 2 个参数。
添加布尔参数会混淆它并让它认为您正在尝试提供 T[][], T[], bool
的参数而不是 Matrix, Vector
.
我不知道拦截是什么意思,但您必须了解它在没有它的情况下会做什么。将您的参数转换为 T[][]
和 T[]
或在没有布尔值的情况下调用它(见下文)。
var p = MultipleRegression.NormalEquations(X, yObserved);
或
var p = MultipleRegression.NormalEquations<double>(X, yObserved);
我已经声明了 MathNet 矩阵和向量类型如下...
Matrix<double> X = Matrix<double>.Build.Dense(sampleSize,2);
Vector<double> yObserved = Vector<double>.Build.Dense(sampleSize);
但是当我打电话给...
Vector<double> p = MultipleRegression.NormalEquations(X, yObserved, true);
Visual Studio 给出错误
Error CS0411 The type arguments for method 'MultipleRegression.NormalEquations(T[][], T[], bool)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
那么,如果不是这样的话,我该如何调用带有 Matrix 和 Vector 参数的 MultipleRegression class?为什么 Visual Studio 发现我的类型编码不明确?
我的代码可以很好地处理矩阵的锯齿状数组;现在我想得到 运行 Matrix/Vector 类型。
MultipleRegression.NormalEquations()
的重载只有 Matrix
和 Vector
参数集组合的 2 个参数。
添加布尔参数会混淆它并让它认为您正在尝试提供 T[][], T[], bool
的参数而不是 Matrix, Vector
.
我不知道拦截是什么意思,但您必须了解它在没有它的情况下会做什么。将您的参数转换为 T[][]
和 T[]
或在没有布尔值的情况下调用它(见下文)。
var p = MultipleRegression.NormalEquations(X, yObserved);
或
var p = MultipleRegression.NormalEquations<double>(X, yObserved);