Reputation: 11
Please help me. After splitting my data into
X_train, y_train, X_test, y_test = train_test_split(X,y)
then passing it to my linear regression model I.e
linereg = LinearRegression().fit(X_train, y_train)
It brings out an error saying array must be 2D not 1D array. How can I make it a 2D array.
Upvotes: 0
Views: 2088
Reputation: 11
first split the data correctly
X_train, x_test, Y_train,y_test=train_test_split(features,labels,train_size=0.7, test_size=0.3, random_state=2)
try reshaping the x_train and x_test using reshape method.
x_test=x_test.reshape(-1,1)
x_train=x_train.reshape(-1,1)
Upvotes: 1