While practicing Simple Linear Regression Model I got this error:
ValueError: Expected 2D array, got scalar array instead:
array=60.
Reshape your data either
The ValueError is fairly clear, predict expects a 2D array but you passed a scalar.
hgt = np.random.randint(50, 70, 10).reshape(-1, 1)
wgt = np.random.randint(90, 120, 10).reshape(-1, 1)
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
regression = LinearRegression()
regression.fit(hgt,wgt)
regression.predict([[60]])
You get
array([[105.10013717]])