Reputation: 524
I'm working with Multiple Linear Regression in C# using Accord.NET, I followed the example, the method needs 2 arguments inputs which is a 2d array, and outputs which is a 1d array, the two arrays must have the same length.
public static double[] RegressionLineaire(double[][]input,double[]output)
{
double[] coeff = new double[40];
var ols = new OrdinaryLeastSquares();
{
ols.UseIntercept = true;
};
Console.WriteLine("inputs length = " + input.Length + " outputs
length = " + output.Length);
MultipleLinearRegression regression = ols.Learn(input, output);
coeff = regression.Weights;
return coeff;
}
the inputs and outputs have the same length but I get this exception
System.InvalidOperationException : 'Matrix is rank deficient.'
Upvotes: 4
Views: 678
Reputation: 524
I just found a solution to the problem, it was not a input shape issue, and i don't know what is exatly the cause of the matrix is rank deficient exception, but i managed de make it work by adding this line.
var ols = new OrdinaryLeastSquares();
{
ols.UseIntercept = true;
ols.IsRobust = true;
};
Upvotes: 5