I'm trying to apply a transformation to customers data without using .fit() or .fit_transform() method to re-fit the old objects, and I face this error in my code:

ValueError: X has 67 features per sample, expected 207

feat_customers = clean_data(customers)
scaler = StandardScaler()
imputer = Imputer(missing_values='NaN', strategy='most_frequent', axis=0)
# code that causes the error
customer_reduced = pca.transform(scaler.transform(imputer.transform(feat_customers)))

1 Answers

0
Chintan Gotecha On

It seems that 'clean_data' function is doing data-preprocessing for you. Please use this function to train your model and then apply transform after using same 'clean_data' function on the new data.

I'm trying to apply a transformation to customers data without using .fit()

The above sentence is not okay. Please check this link to exactly understand the difference between fit, fit_trnsform and transform. You may have an idea of these terminologies but as you have come up with this question it will be a good idea to revisit them once again.