Commit f1f45079 authored by linfang.wang's avatar linfang.wang

特征图

parent b58ac63f
...@@ -26,30 +26,30 @@ def report(dftrain,dftest,features,label,path,filename): ...@@ -26,30 +26,30 @@ def report(dftrain,dftest,features,label,path,filename):
document.add_paragraph('模型训练集{}'.format(xgboost.auc(clf,dftrain,features,label))) document.add_paragraph('模型训练集{}'.format(xgboost.auc(clf,dftrain,features,label)))
document.add_paragraph('模型测试集{}'.format(xgboost.auc(clf, dftest, features, label))) document.add_paragraph('模型测试集{}'.format(xgboost.auc(clf, dftest, features, label)))
# document.add_heading('调整参数') document.add_heading('调整参数')
# max_depth=[2,3] max_depth=[2,3]
# min_child_weight=range(1,4,1) min_child_weight=range(1,4,1)
# document, clf = tun_params(document, clf, dftrain, dftest, {'max_depth': max_depth,'min_child_weight':min_child_weight}, features, label) document, clf = tun_params(document, clf, dftrain, dftest, {'max_depth': max_depth,'min_child_weight':min_child_weight}, features, label)
# # gamma # gamma
# gamma=[i/10 for i in range(0,5)] gamma=[i/10 for i in range(0,5)]
# document,clf=tun_params(document,clf,dftrain,dftest,{'gamma':gamma},features,label) document,clf=tun_params(document,clf,dftrain,dftest,{'gamma':gamma},features,label)
#
# # subsample colsample_bytree # subsample colsample_bytree
# subsample=[0.8,0.9,1] subsample=[0.8,0.9,1]
# colsample_bytree=[0.8,0.9,1] colsample_bytree=[0.8,0.9,1]
# document, clf = tun_params(document, clf, dftrain, dftest, document, clf = tun_params(document, clf, dftrain, dftest,
# {'subsample': subsample, 'colsample_bytree': colsample_bytree}, features, label) {'subsample': subsample, 'colsample_bytree': colsample_bytree}, features, label)
#
# # reg_alpha # reg_alpha
# reg_alpha=[0.001,0.01,0.1,1,10] reg_alpha=[0.001,0.01,0.1,1,10]
# document, clf = tun_params(document, clf, dftrain, dftest, document, clf = tun_params(document, clf, dftrain, dftest,
# {'reg_alpha': reg_alpha}, features, label) {'reg_alpha': reg_alpha}, features, label)
#
# # reg_lambda # reg_lambda
# reg_lambda = [0.001, 0.01, 0.1, 1, 10] reg_lambda = [0.001, 0.01, 0.1, 1, 10]
# document, clf = tun_params(document, clf, dftrain, dftest, document, clf = tun_params(document, clf, dftrain, dftest,
# {'reg_lambda': reg_lambda}, features, label) {'reg_lambda': reg_lambda}, features, label)
#==生成模型最后的报告,各个特征的单变量图,PDP,liftchart #==生成模型最后的报告,各个特征的单变量图,PDP,liftchart
dftrain=xgboost.predict(clf,dftrain,features) dftrain=xgboost.predict(clf,dftrain,features)
...@@ -87,17 +87,17 @@ def report(dftrain,dftest,features,label,path,filename): ...@@ -87,17 +87,17 @@ def report(dftrain,dftest,features,label,path,filename):
document.add_paragraph('测试集分渠道--liftchart') document.add_paragraph('测试集分渠道--liftchart')
document.add_picture('tmp.png') document.add_picture('tmp.png')
# #== 各个特征的 单变量图 和 pdp 图 #== 各个特征的 单变量图 和 pdp 图
# for i in featureimp.feature.tolist(): for i in featureimp.feature.tolist():
# drawplot.univarchart(dftest, i, label, bin=10, title='单变量%s' % i, drawplot.univarchart(dftest, i, label, bin=10, title='单变量%s' % i,
# ylabel='逾期率').savefig('tmp.png') ylabel='逾期率').savefig('tmp.png')
# document.add_paragraph('单变量%s' % i) document.add_paragraph('单变量%s' % i)
# document.add_picture('tmp.png') document.add_picture('tmp.png')
# #= pdp #= pdp
# drawplot.pdpchart(dftest, i, 'predict_proba', bin=10, title='pdp %s' % i, drawplot.pdpchart(dftest, i, 'predict_proba', bin=10, title='pdp %s' % i,
# ylabel='模型分').savefig('tmp.png') ylabel='模型分').savefig('tmp.png')
# document.add_paragraph('pdp %s' % i) document.add_paragraph('pdp %s' % i)
# document.add_picture('tmp.png') document.add_picture('tmp.png')
filetool.saveDocument(document, path, filename) filetool.saveDocument(document, path, filename)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment