Last answered:

15 Jul 2020

Posted on:

22 Jun 2020


Simple Linear Regression with sklearn – Summary Table

Hi, I am still getting error when i use predict function.reg.predict(1740). The error is ValueError: Expected 2D array, got scalar array instead, even though I have used reshape function as said previously.x_matrix = x.values.reshape(-1,1)
x_matrix.shape...... Please advise

1 answers ( 0 marked as helpful)
Posted on:

15 Jul 2020

Hi Manish,  the reg.predict(1740) doesn't appear to be running in the newer versions of Python. Instead you could try the following: new_array = np.array(1740).reshape(-1,1)
reg.predict(new_array) Do let us know if there is still an issue. Best,  365 Eli  

Submit an answer