public RidgeRegressionEstimator Fit(Matrix <double> x, Vector <double> y) { var(x1, y1, xMean, yMean) = CenterData(x, y); (x, y) = (x1, y1); if (Method == RidgeRegressionMethod.Automatic) { // TODO: implement some logic here Method = RidgeRegressionMethod.LSQR; } Vector <double> w; if (Method == RidgeRegressionMethod.LSQR) { // TODO: make benchmark with sparse matrices. w = Lsqr(x, y, Alpha); if (Intercept) { var intercept = GetIntercept(xMean, yMean, w); var w1 = Vector <double> .Build.Dense(w.Count + 1); w.CopySubVectorTo(w1, 0, 1, w.Count); w1[0] = intercept; w = w1; } } else { throw new NotSupportedException(); } return(new RidgeRegressionEstimator(this, w)); }
public RidgeRegression(bool intercept = true, double alpha = 1.0, RidgeRegressionMethod method = RidgeRegressionMethod.Automatic) { Intercept = intercept; Alpha = alpha; Method = method; }