lightgbm不能自行检测分类特征

问题描述

hyper_params = {
    'task': 'train','objective': 'regression','metric': ['l2','auc'],'learning_rate': 0.005,"num_leaves": 128,'categorical_feature':'auto',"num_iterations": 10000,"n_estimators": 100
}

lgb = LGBMRegressor(**hyper_params)
lgb.fit(X_train,y_train,eval_set = [(X_valid,y_valid)],eval_metric='l1',early_stopping_rounds=100
           )

即使在'categorical_feature':'auto',之后,我的X_train仍包含类别变量

ValueError: DataFrame.dtypes for data must be int,float or bool.
Did not expect the data types in the following fields: MSZoning,Street,LotShape,...

如果我愿意

obj_feat = list(X_train.loc[:,X_train.dtypes == 'object'].columns.values)
obj_feat

我能够获得具有分类对象类型的特征

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)