1

I have N data vectors $X_i$ and N target vectors $Y_i$ where $i$ indexes the sample. I would like to learn a linear map $A$ between the data and the target i.e find the matrix $A$ that minimize $$\sum_i^N||Y_i-AX_i||^2.$$ Is that a well know machine learning problem ? What would be the equivalent model in scikit-learn ? I thought this is a linear regression, but in scikit-learn the documentation of the linear regression states

LinearRegression fits a linear model with coefficients w = (w1, …, wp) to minimize the residual sum of squares between the observed targets in the dataset, and the targets predicted by the linear approximation.

So it seems like scikit-learn's linear regression learns a list of coefficients w = (w1, …, wp), not a matrix A.

Nichola
  • 113
  • 4

1 Answers1

1

This is a normal linear regression where the target variable has multiple components. This is often referred to as "multivariate linear regression". To implement it with scikit-learn, you can use a normal LinearRegression model.

Given that you have no intercept term, you should use fit_intercept=False.

After fitting the model, you can find $A$ in the coef_ attribute of the model:

coef_: array of shape (n_features, ) or (n_targets, n_features)

Estimated coefficients for the linear regression problem. If multiple targets are passed during the fit (y 2D), this is a 2D array of shape (n_targets, n_features), while if only one target is passed, this is a 1D array of length n_features.

Valentas
  • 1,412
  • 1
  • 10
  • 22
noe
  • 28,203
  • 1
  • 49
  • 83