Last answered:

21 May 2020

Posted on:

20 May 2020


Making prediction with Scikit learn

Hey, i am getting following error while following your code line by line. I reshaped the x variable prior to performing regression. I ran the regression successfully and got the Coefficient, R squared etc. But when i run this code  ##reg.predict(1740), i get the following error .Thanks 
ValueError: Expected 2D array, got scalar array instead:
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.
1 answers ( 0 marked as helpful)
Posted on:

21 May 2020

Hi Gurpinder, Thanks for reaching out. Please note that sklearn expects your data to be in 2D form. To achieve that you can write:
And the problem will be fixed.  Note that when we were recording the video, it was working even without the square brackets. Best,
The 365 Team

Submit an answer