numpy Not_Fitted_Error:此LabelEncoder示例尚未安装,在使用此估计器之前,使用适当的参数调用'fit'

tquggr8v  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(74)

I am new to Ml_ModellingI am working on a solution to create a model with three columns nature_of_business , industry, products.
| 业务性质|行业|产品|
| --|--|--|
| 制造商|资本货物|product1|
| 服务|采矿|product2|
| 其他|资本货物|产品展示|
| 制造商|商业服务|产品中心|
Now, with the label encoder I'm encoding the entire Data Frame.

df = df.apply(LabelEncoder().fit_transform)

After this i have splitted the data into test and test and created the model
Now, I'm trying to predict the Product using the model for a new Dataframe. I'm using the same Label encoder as used earlier.

df_Predict = pd.DataFrame({
'Industry_nature_of_business': ['Manufacturer'], 
'Industry_Category': ['Capital Goods']})
 df_encoded_Predict = df_Predict.apply(LabelEncoder().fit_transform)
 predictions_train = knc.predict(df_encoded_Predict)
 print(LabelEncoder().inverse_transform(predictions_train))
ki0zmccv

ki0zmccv1#

encoder=LabelEncoder()
df_encoded_Predict = df_Predict.apply(LabelEncoder().fit_transform)
predictions_train = knc.predict(df_encoded_Predict)
print(LabelEncoder().inverse_transform(predictions_train))

相关问题