What i tried :
from sklearn.model_selection import train_test_split x_train,y_train,x_test,y_test=train_test_split(x,y.flatten(),test_size=0.2,random_state=0) x_train.shape y_train.shape x_test.shape y_test.shape (151, 1) (38, 1) (151, 1) (38, 1) from sklearn.linear_model import LinearRegression lreg=LinearRegression() lreg.fit(x_train,y_train)
error comes:-ValueError: Found input variables with inconsistent numbers of samples: [151, 38]
you have wrong positional order of train-test-split ouput, Should be as follows:
x_train, x_test, y_train, y_test = train_test_split(x,y.flatten(),test_size=0.2,random_state=0)
1.4m articles
1.4m replys
5 comments
57.0k users