In ‘Simple Linear Regression with sklearn – Summary Table’ Lecture
After following the whole lecture and reshaping x to x_matrix, everything was running smoothly until I have to run the ‘reg.predict(1740)’ command.
It gives me the same error.
ValueError: Expected 2D array, got scalar array instead: array=1740. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Thank you for reaching out.
Depending on your version of sklearn this may or may not be an issue. To turn the number to a 2D array, please add double square brackets like below: