The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Making prediction with Scikit learn

Making prediction with Scikit learn

Super Learner
0
Votes
1
Answer

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:
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.
1 Answer

365 Team
0
Votes

Hi Gurpinder,
Thanks for reaching out.
Please note that sklearn expects your data to be in 2D form.
To achieve that you can write:

reg.predict([[1740]])

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

Thanks very much for the reply, this solved my problem

4 months
×
LAST CHANCE
Ready to Learn Data Science?
50% OFF