While trying for linear regression, I got the following error.

Code:-

from sklearn.linear_model import LinearRegression

linreg = LinearRegression()

linreg.fit(X_train, Y_train)

RMSE_test = np.sqrt(metrics.mean_squared_error(Y_test, Y_pred_test))

System response -

ValueError: Expected 2D array, got 1D array instead:

Make sure whenever you divide the dataset, the training data is in dataframe rather than array and the target variable is in array.

## Comments

0 comments

Article is closed for comments.