特征选取的boruta

# X=X.values
# y=y.values
#更改为bor特征选择器
# import sklearn
# from lightgbm.sklearn import LGBMClassifier
# from sklearn.ensemble import RandomForestClassifier
# from boruta import BorutaPy

# rf = LGBMClassifier(num_leaves=60,max_depth=7,n_estimators=1200,learning_rate=0.03,bagging_fraction=0.7,bagging_freq=60,max_bin=150,min_data_in_leaf=60,feature_fraction=0.7,random_state=1)
# feat_selector = BorutaPy(rf, n_estimators='auto', verbose=2, random_state=1,max_iter=20)

# # find all relevant features - 5 features should be selected
# feat_selector.fit(X, y)

# check ranking of features
#feat_selector.ranking_

X = train_data.drop(['ts_code','date','rownum','target','week', 'year'],axis=1)#原理的X加了values就不行了

t = pd.DataFrame(pd.DataFrame(X).columns)
t.columns = ['var']
t['importance'] = feat_selector.ranking_
#t = t.sort_values(by=['importance'],ascending=False)
var_ok = t[t['importance']<=4]['var'].values

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值