Last answered:

07 Dec 2022

Posted on:

11 Nov 2021

28

The line reg.predict(1740) does not work anymore

The line reg.predict(1740) does not work anymore.
The new versions of sklearn requiere a matrix as input.
thus, it can be solved by using this code:

obs = 1740
obs_as_matrix = np.reshape(obs, (1,1))
reg.predict(obs_as_matrix)

Alternatively:

obs = 1740
obs_as_matrix = np.array([obs]).reshape(1, 1)
reg.predict(obs_as_matrix)

Or as a data frame:

obs = 1740
obs_as_matrix = pd.DataFrame({'SAT':[1740]})
reg.predict(obs_as_matrix)

4 answers ( 0 marked as helpful)
Posted on:

11 Nov 2021

1

Thank you for the clarification

Posted on:

13 Jun 2022

0

Thank you very much! I have had the same problem.

Posted on:

05 Nov 2022

0

You are great, keep up the good work.

Posted on:

07 Dec 2022

7

reg.predict([[1740]]) works as well

Submit an answer