X has 290 features, but LinearRegression is expecting 869 features as input.
HP_model=lm.LinearRegression()
for i in range(4,34,1):
x=df1[col[0]].copy()
y=df1[col[i]]
x_train,x_test,y_train,y_test=model_selection.train_test_split(x,y,test_size=0.25)
x_train=[x_train]
x_test=[x_test]
y_train=[y_train]
y_test=[y_test]
HP_model = HP_model.fit(x_train, y_train)
m1=HP_model.predict(x_test)
print(m1)
# i copy this code from my old note book but some how it is an eror. My teacher have never seen this eror before too
1 answers ( 0 marked as helpful)
Hey,
Thank you for reaching out!
Unfortunately, I don't have access to the df1
DataFrame and can't reproduce your results. However, such an error occurs when there is a mismatch in the dimensions of the training and testing dataset - you have trained your model on 869 features but are testing it on 290 features. Make sure that x_train
and x_test
have the same dimensions during all iterations.
Kind regards,
365 Hristina