Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Number of features of the model must match the input

$
0
0

@Jayanti_Bhanushali wrote:

I have developed a Linear Regression model using SKlearn that involves dummy variables (due to categorical variables as input). I created a pickle file and loaded it in another session.

from sklearn.externals import joblib
loaded_model = joblib.load(‘LR_Model.pkl’)

When performing Out-Of-Sample validation on new data set (much smaller than trained), I again transform the categorical variables into dummy variables.

for column in validation_df.columns:
if validation_df[column].dtype==object:
dummyCols=pd.get_dummies(validation_df[column])
validation_df=validation_df.join(dummyCols)
del validation_df[column]

When I try to predict on new data set (Y_predicted = loaded_model.predict(validation_df)),
I get the below error (full error in image):


ValueError: shapes (1349,1000) and (2017,2) not aligned: 1000 (dim 1) != 2017 (dim 0)

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles