Ask Your Question
3

The error in Machine Learning says that a 1D array was received instead of the expected 2D array.

asked 2023-05-11 10:01:55 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-11 10:02:01 +0000

pufferfish gravatar image

This error message typically occurs when a function or method in a Machine Learning library or framework expects a two-dimensional array as input, but receives only a one-dimensional array.

For example, if you try to fit a linear regression model to a single feature, you may get this error because scikit-learn's LinearRegression class requires a two-dimensional array for the feature input.

To resolve this error, you can reshape the data using NumPy's reshape method or use functions like numpy.expand_dims to convert the one-dimensional array to a two-dimensional array. Additionally, you should check the documentation for the function or method you are using to ensure that you are providing the correct input format.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-11 10:01:55 +0000

Seen: 13 times

Last updated: May 11 '23