[Solved] Why couldn’t I predict directly using Features Matrix?

You are using this method in both training and testing: def encode_string(cat_features): enc = preprocessing.LabelEncoder() enc.fit(cat_features) enc_cat_features = enc.transform(cat_features) ohe = preprocessing.OneHotEncoder() encoded = ohe.fit(enc_cat_features.reshape(-1,1)) return encoded.transform(enc_cat_features.reshape(-1,1)).toarray() by calling: Features = encode_string(combined_custs[‘CountryRegionName’]) for col in categorical_columns: temp = encode_string(combined_custs[col]) Features = np.concatenate([Features, temp],axis=1) But as I said in my comment above, you need to apply … Read more