Reputation: 278
Basically just the title. It just struck me as odd when I was dipped my toes into the sklearn
library. Is there an explanation for this?
Upvotes: 1
Views: 4053
Reputation: 88305
This is just the way it is by design choice for the fit
methods of ML models in scikit-learn afaik. It's mostly to stay consistent with the specification of the input shape: (n_samples, n_features)
:
X : {array-like, sparse matrix} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples and n_features is the number of features.
Which is also made clear right at the top of check_array
, the validation step where the error is raised:
Input validation on an array, list, sparse matrix or similar. By default, the input is checked to be a non-empty 2D array containing only finite values. If the dtype of the array is object, attempt converting to float, raising on failure.
LinearRegression
does actually accept 2D
target arrays though, in which case it will perform a multiple linear regression.
Upvotes: 2