遗传算法寻优
cross_val_score(lgb,train_X,train_y,scoring='f1',cv=sKfold).mean()
0.8508040614085857
train_1 = train.drop('label',1)
cols = train_1.columns
train_1.head()
| 经营期限起 | 是否广告经营 | 是否城镇 | 从业人数 | 注册资本(金) | 实缴资本 | 注册 - 实缴 | 行政区划代码_count_encode | 行业类别代码_count_encode | 行业细类代码_count_encode | 企业类型_count_encode | 企业类型小类_count_encode | 状态_count_encode | 机构标识_count_encode | 职位标识_count_encode | 组织形式_count_encode | 经营方式_count_encode | 风险行业_count_encode | 经营场所_count_encode | 企业(机构)类型_count_encode | 行政区划代码_catboost_encode | 行业类别代码_catboost_encode | 行业细类代码_catboost_encode | 企业类型_catboost_encode | 企业类型小类_catboost_encode | 状态_catboost_encode | 机构标识_catboost_encode | 职位标识_catboost_encode | 组织形式_catboost_encode | 经营方式_catboost_encode | 风险行业_catboost_encode | 经营场所_catboost_encode | 企业(机构)类型_catboost_encode | 行政区划代码_targe_encode | 行业类别代码_targe_encode | 行业细类代码_targe_encode | 企业类型_targe_encode | 企业类型小类_targe_encode | 状态_targe_encode | 机构标识_targe_encode | 职位标识_targe_encode | 组织形式_targe_encode | 经营方式_targe_encode | 风险行业_targe_encode | 经营场所_targe_encode | 企业(机构)类型_targe_encode | 行政区划代码_woe_encode | 行业类别代码_woe_encode | 行业细类代码_woe_encode | 企业类型_woe_encode | 企业类型小类_woe_encode | 状态_woe_encode | 机构标识_woe_encode | 职位标识_woe_encode | 组织形式_woe_encode | 经营方式_woe_encode | 风险行业_woe_encode | 经营场所_woe_encode | 企业(机构)类型_woe_encode | 行政区划代码_ord_encode | 行业类别代码_ord_encode | 行业细类代码_ord_encode | 企业类型_ord_encode | 企业类型小类_ord_encode | 状态_ord_encode | 机构标识_ord_encode | 职位标识_ord_encode | 组织形式_ord_encode | 经营方式_ord_encode | 风险行业_ord_encode | 经营场所_ord_encode | 企业(机构)类型_ord_encode | 状态_2015 | 资金数额_2015 | 从业人数_2015 | 从业人数是否公示_2015 | 经营状态名称_2015 | 是否有网站标志_2015 | 是否有对外投资企业标志_2015 | 有限责任公司本年度是否发生股东股权转让标志_2015 | 公示状态_2015 | 其中下岗失业人数雇员_2015 | 其中退役士兵人数雇员_2015 | 其中残疾人人数经营者_2015 | 其中下岗失业人数经营者_2015 | 其中退役士兵人数经营者_2015 | 其中高校毕业生人数经营者_2015 | 其中残疾人人数雇员_2015 | 从业人数是否公示_2016 | 经营状态名称_2016 | 是否有网站标志_2016 | 是否有对外投资企业标志_2016 | 有限责任公司本年度是否发生股东股权转让标志_2016 | 公示状态_2016 | 其中下岗失业人数雇员_2016 | 其中退役士兵人数雇员_2016 | 其中残疾人人数经营者_2016 | 其中下岗失业人数经营者_2016 | 其中退役士兵人数经营者_2016 | 其中高校毕业生人数经营者_2016 | 其中残疾人人数雇员_2016 | 其中高校毕业生人数雇员_2016 | 状态_2017 | 资金数额_2017 | 从业人数_2017 | 从业人数是否公示_2017 | 经营状态名称_2017 | 是否有网站标志_2017 | 是否有对外投资企业标志_2017 | 有限责任公司本年度是否发生股东股权转让标志_2017 | 公示状态_2017 | 其中下岗失业人数雇员_2017 | 其中退役士兵人数雇员_2017 | 其中残疾人人数经营者_2017 | 其中下岗失业人数经营者_2017 | 其中退役士兵人数经营者_2017 | 其中高校毕业生人数经营者_2017 | 其中残疾人人数雇员_2017 | 其中高校毕业生人数雇员_2017 | 状态_2018 | 资金数额_2018 | 从业人数_2018 | 从业人数是否公示_2018 | 经营状态名称_2018 | 是否有网站标志_2018 | 是否有对外投资企业标志_2018 | 有限责任公司本年度是否发生股东股权转让标志_2018 | 公示状态_2018 | 其中下岗失业人数雇员_2018 | 其中退役士兵人数雇员_2018 | 其中残疾人人数经营者_2018 | 其中下岗失业人数经营者_2018 | 其中退役士兵人数经营者_2018 | 其中高校毕业生人数经营者_2018 | 其中残疾人人数雇员_2018 | 其中高校毕业生人数雇员_2018 | 状态_mode | 从业人数是否公示_mode | 经营状态名称_mode | 是否有网站标志_mode | 是否有对外投资企业标志_mode | 有限责任公司本年度是否发生股东股权转让标志_mode | 公示状态_mode | 状态_ischange | 从业人数是否公示_ischange | 经营状态名称_ischange | 是否有网站标志_ischange | 是否有对外投资企业标志_ischange | 有限责任公司本年度是否发生股东股权转让标志_ischange | 公示状态_ischange | 其中残疾人人数雇员_max | 其中残疾人人数雇员_mean | 其中残疾人人数雇员_min | 其中残疾人人数经营者_max | 其中残疾人人数经营者_mean | 其中残疾人人数经营者_min | 其中退役士兵人数雇员_max | 其中退役士兵人数雇员_mean | 其中退役士兵人数雇员_min | 其中下岗失业人数雇员_max | 其中下岗失业人数雇员_mean | 其中下岗失业人数雇员_min | 其中高校毕业生人数经营者_max | 其中高校毕业生人数经营者_mean | 其中高校毕业生人数经营者_min | 其中下岗失业人数经营者_max | 其中下岗失业人数经营者_mean | 其中下岗失业人数经营者_min | 从业人数_max | 从业人数_mean | 从业人数_min | 其中退役士兵人数经营者_max | 其中退役士兵人数经营者_mean | 其中退役士兵人数经营者_min | 资金数额_max | 资金数额_mean | 资金数额_min | 其中高校毕业生人数雇员_max | 其中高校毕业生人数雇员_mean | 其中高校毕业生人数雇员_min | 其中残疾人人数雇员_range | 其中残疾人人数经营者_range | 其中退役士兵人数雇员_range | 其中下岗失业人数雇员_range | 其中高校毕业生人数经营者_range | 其中下岗失业人数经营者_range | 从业人数_range | 其中退役士兵人数经营者_range | 资金数额_range | 其中高校毕业生人数雇员_range | id_count | 变更信息代码_110.0 | 变更信息代码_111.0 | 变更信息代码_112.0 | 变更信息代码_113.0 | 变更信息代码_115.0 | 变更信息代码_117.0 | 变更信息代码_118.0 | 变更信息代码_120.0 | 变更信息代码_121.0 | 变更信息代码_128.0 | 变更信息代码_129.0 | 变更信息代码_131.0 | 变更信息代码_133.0 | 变更信息代码_137.0 | 变更信息代码_138.0 | 变更信息代码_150.0 | 变更信息代码_190.0 | 变更信息代码_921.0 | 变更信息代码_922.0 | 变更信息代码_925.0 | 变更信息代码_930.0 | 变更信息代码_939.0 | 变更总次数 | date_range | 变更频率 | 个人所得税 | 企业所得税 | 其他收入 | 印花税 | 土地增值税 | 地方教育附加 | 城市维护建设税 | 城镇土地使用税 | 契税 | 房产税 | 教育费附加 | 残疾人就业保障金 | 水利建设专项收入 | 税务部门罚没收入 | 营业税 | 税收总额 | tax_date_range | 每天交税金额 | 是否有税收计记录 | 中立 | 消极 | 积极 | 曝光率 | 积极-消极 | 最近一次评价 | 中立评分比例 | 消极评分比例 | 积极评分比例 |
---|
企业唯一标识 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
---|
47645761dc56bb8c5fae00114b768b5d9b6e917c3aec07c4 | 479 | 0 | 0 | 5.0 | 50.0 | 0 | 52.0 | 1803 | 7017 | 234 | 14085 | 5679 | 21583 | 929 | 163 | 14234 | 15865 | 16428 | 18792 | 4795 | 0.018143 | 0.001633 | 0.000307 | 0.039825 | 0.028175 | 0.072861 | 0.033443 | 0.000437 | 0.081049 | 0.098250 | 0.095310 | 0.081644 | 0.008410 | 0.018100 | 0.001620 | 0.000000 | 0.039823 | 0.028165 | 0.072862 | 3.338898e-02 | 0.000000e+00 | 0.081051 | 0.098254 | 0.095313 | 0.081645 | 0.008394 | -1.297707 | -3.657842 | -2.722611 | -0.531992 | -0.884355 | 0.105468 | -0.670478 | -2.369253 | 0.221020 | 0.432157 | 0.398518 | 0.228804 | -2.090216 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1 | 1 | 1.0 | 1 | 1.0 | 1 | 1.0 | 1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | -1.0 | -1.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 |
---|
59b38c56de3836838082cfcb1a298951abfe15e6940c49ba | 47 | 0 | 0 | 2.0 | 100.0 | 0 | 102.0 | 5481 | 2968 | 43 | 14085 | 5679 | 21583 | 3617 | 260 | 14234 | 15865 | 16428 | 18792 | 4795 | 0.122277 | 0.002830 | 0.001610 | 0.039825 | 0.028175 | 0.072861 | 0.220212 | 0.000253 | 0.081049 | 0.098250 | 0.095310 | 0.081644 | 0.008410 | 0.122292 | 0.002795 | 0.000000 | 0.039823 | 0.028165 | 0.072862 | 2.202797e-01 | 0.000000e+00 | 0.081051 | 0.098254 | 0.095313 | 0.081645 | 0.008394 | 0.679055 | -3.047387 | -1.065545 | -0.531992 | -0.884355 | 0.105468 | 1.385412 | -2.916493 | 0.221020 | 0.432157 | 0.398518 | 0.228804 | -2.090216 | 2.0 | 2.0 | 2.0 | 1.0 | 1.0 | 1 | 2 | 2.0 | 1 | 1.0 | 1 | 1.0 | 1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | -1.0 | -1.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 |
---|
e9f7b28ec10e047000d16ab79e1b5e6da434a1697cce7818 | 1859 | 0 | 1 | 2.0 | 10.0 | 0 | 12.0 | 2092 | 1428 | 722 | 2180 | 757 | 21583 | 1361 | 87 | 14234 | 575 | 16428 | 18792 | 757 | 0.046508 | 0.609421 | 0.718118 | 0.523964 | 0.003689 | 0.072861 | 0.070961 | 0.057849 | 0.081049 | 0.004007 | 0.095310 | 0.081644 | 0.003689 | 0.046492 | 0.610147 | 0.719794 | 0.524402 | 0.003472 | 0.072862 | 7.096774e-02 | 5.769231e-02 | 0.081051 | 0.003774 | 0.095313 | 0.081645 | 0.003472 | -0.355709 | 3.094724 | 3.585902 | 2.745526 | -2.321786 | 0.105468 | 0.092740 | 0.122299 | 0.221020 | -2.238555 | 0.398518 | 0.228804 | -2.321786 | 3.0 | 3.0 | 3.0 | 2.0 | 2.0 | 1 | 3 | 3.0 | 1 | 2.0 | 1 | 1.0 | 2.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 3.0 | 0.0 | 3.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 |
---|
f000950527a6feb63ee1ce82bb22ddd1ab8b8fdffa3b91fb | 1066 | 0 | 0 | -1.0 | 100.0 | 0 | 102.0 | 5481 | 2968 | 336 | 14085 | 7467 | 3109 | 2261 | 53 | 14234 | 15865 | 16428 | 18792 | 7467 | 0.122277 | 0.002830 | 0.000269 | 0.039825 | 0.030685 | 0.019527 | 0.139795 | 0.021320 | 0.081049 | 0.098250 | 0.095310 | 0.081644 | 0.030685 | 0.122292 | 0.002795 | 0.000000 | 0.039823 | 0.030678 | 0.019502 | 1.398545e-01 | 2.040816e-02 | 0.081051 | 0.098254 | 0.095313 | 0.081645 | 0.030678 | 0.679055 | -3.047387 | -2.853231 | -0.531992 | -0.798098 | -1.242689 | 0.836353 | -0.550646 | 0.221020 | 0.432157 | 0.398518 | 0.228804 | -0.798098 | 2.0 | 2.0 | 4.0 | 1.0 | 3.0 | 2 | 4 | 4.0 | 1 | 1.0 | 1 | 1.0 | 3.0 | -1.0 | -1.0 | 2.0 | 2.0 | -1.0 | -1.0 | 4.0 | 3.0 | -1.0 | -1.0 | 4.0 | 3.0 | -1.0 | -1.0 | 2.0 | 2.0 | -1.0 | -1.0 | 2.0 | 2.0 | -1.0 | -1.0 | 2.0 | 2.0 | -1.0 | -1.0 | 2.0 | 2.0 | -1.0 | -1.0 | 3.0 | 3.0 | -1.0 | -1.0 | 0.0 | 0.0 | -1.0 | -1.0 | 0.0 | 0.0 | -1.0 | -1.0 | 0.0 | 0.0 | -1.0 | -1.0 | 0.0 | 0.0 | -1.0 | -1.0 | 3.0 | 1.0 | -1.0 | -1.0 | 0.0 | 0.0 | -1.0 | -1.0 | 0.0 | 0.0 | -1.0 | -1.0 | 1.0 | 2.0 | 2.0 | 2.0 | 0.0 | 2.0 | 2.0 | 2.0 | 3.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 4.0 | 3.5 | 3.0 | 3.0 | 2.0 | 1.0 | 4.0 | 3.5 | 3.0 | 2.0 | 1.5 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 2.0 | 1.0 | 1.0 | 2.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 3.0 | 220.0 | 0.013575 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 |
---|
9c7fa510616a6830b878f3c8c4317d93e1b022e7f22ae231 | 90 | 0 | 1 | 5.0 | 20.0 | 0 | 22.0 | 1338 | 10312 | 246 | 8193 | 8214 | 21583 | 41 | 27 | 10610 | 8186 | 8115 | 1 | 8193 | 0.035840 | 0.001466 | 0.000325 | 0.000014 | 0.000014 | 0.072861 | 0.002200 | 0.002357 | 0.037043 | 0.000014 | 0.001328 | 0.065994 | 0.000014 | 0.035802 | 0.001455 | 0.000000 | 0.000000 | 0.000000 | 0.072862 | 4.563131e-14 | 3.371647e-13 | 0.037037 | 0.000000 | 0.001314 | 0.065994 | 0.000000 | -0.612630 | -3.765978 | -2.665179 | -5.790555 | -5.794011 | 0.105468 | -0.753170 | -0.684177 | -0.604969 | -5.790339 | -3.831579 | 0.000000 | -5.790555 | 4.0 | 4.0 | 5.0 | 3.0 | 4.0 | 1 | 5 | 5.0 | 2 | 3.0 | 2 | 2.0 | 4.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | -1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | -1.0 | -1.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 |
---|
sKfold = StratifiedKFold(n_splits=5, shuffle=True, random_state=2020)
def fun_(x):
'''传入长度为特征数量的0,1向量,转化为bool之后作为特征的索引,提取特征子集,使用特征子集进行选了返回目标函数值'''
X = train_1[cols[x.astype('bool')]].values
val = cross_val_score(lgb,X,train_y,scoring='f1',cv=sKfold).mean()
return val
def GV_col(func,len_,num_,it_num = 50,jiaopei = 0.8,bianyi = 0.2):
'''
func:目标函数 输入为0,1向量,输出为目标函数值
len_:特征维度
it_num:种群的数量
jiaopei:种群进行杂交的概率
bianyi:种群进行变异的概率
返回值:传入长度为特征数量的0,1向量
历史种群达到的最优值
'''
pop = np.random.randint(0,2,(num_,len_))
best_f = 0
list_best_f = []
for _ in range(it_num):
scores = [func(i) for i in pop]
best_fit_ = scores[np.argmax(scores)]
if best_fit_ > best_f:
best_f = best_fit_
best_p = pop[np.argmax(scores)]
list_best_f.append(best_f)
fitness = scores - min(scores) + 0.01
idx = np.random.choice(np.arange(num_), size=num_, replace=True,
p=(fitness)/(fitness.sum()) )
pop = np.array(pop)[idx]
new_pop = []
for father in pop:
child = father
if np.random.rand() < jiaopei:
mother_id = np.random.randint(num_)
low_point = np.random.randint(len_)
high_point = np.random.randint(low_point+1,len_+1)
child[low_point:high_point] = pop[mother_id][low_point:high_point]
if np.random.rand() < bianyi:
mutate_point = np.random.randint(0, len_)
child[mutate_point] = 1 - child[mutate_point]
new_pop.append(child)
pop = new_pop
print(f'{_}/{it_num},当前分数:{best_f}')
return best_p,list_best_f
w = GV_col(fun_,244,10,30,0.9,0.3)
0/30,当前分数:0.8422718298032565
1/30,当前分数:0.8422718298032565
2/30,当前分数:0.8487626570528729
3/30,当前分数:0.8487626570528729
4/30,当前分数:0.850974123058376
5/30,当前分数:0.850974123058376
6/30,当前分数:0.850974123058376
7/30,当前分数:0.850974123058376
8/30,当前分数:0.850974123058376
9/30,当前分数:0.850974123058376
10/30,当前分数:0.850974123058376
11/30,当前分数:0.850974123058376
12/30,当前分数:0.850974123058376
13/30,当前分数:0.850974123058376
14/30,当前分数:0.850974123058376
15/30,当前分数:0.850974123058376
16/30,当前分数:0.850974123058376
17/30,当前分数:0.850974123058376
18/30,当前分数:0.850974123058376
19/30,当前分数:0.850974123058376
20/30,当前分数:0.850974123058376
21/30,当前分数:0.850974123058376
22/30,当前分数:0.850974123058376
23/30,当前分数:0.850974123058376
24/30,当前分数:0.850974123058376
25/30,当前分数:0.850974123058376
26/30,当前分数:0.8518982053263855
27/30,当前分数:0.8518982053263855
28/30,当前分数:0.8518982053263855
29/30,当前分数:0.8518982053263855
plt.plot(w[1])
[<matplotlib.lines.Line2D at 0x29a465389b0>]
lgb.fit(train_X,train_y)
LGBMClassifier(max_depth=4, min_child_samples=10, n_estimators=150,
num_leaves=14, reg_alpha=0.28296338218326345,
reg_lambda=0.18095776927233131, subsample=0.8272103969163492)
cols_2 = train.drop('label',1).columns[lgb.feature_importances_.astype('bool')]
train_X_2 = train[cols_2].values
cross_val_score(lgb,train_X_2,train_y,scoring='f1',cv=sKfold).mean()
0.8496644165439153
cols_3 = cols[w[0].astype('bool')]
train_X_3 = train[cols_3].values
cross_val_score(lgb,train_X_3,train_y,scoring='f1',cv=sKfold).mean()
0.8518982053263855