1
$\begingroup$

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.

$\endgroup$
0

1 Answer 1

1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.