Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
model_mvp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
decision-science
model_mvp
Commits
f1f45079
Commit
f1f45079
authored
Apr 22, 2019
by
linfang.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
特征图
parent
b58ac63f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
35 deletions
+35
-35
xgbreport.py
mvp/xgbreport.py
+35
-35
No files found.
mvp/xgbreport.py
View file @
f1f45079
...
...
@@ -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
,
dftest
,
features
,
label
)))
#
document.add_heading('调整参数')
#
max_depth=[2,3]
#
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)
#
#
gamma
#
gamma=[i/10 for i in range(0,5)]
#
document,clf=tun_params(document,clf,dftrain,dftest,{'gamma':gamma},features,label)
#
#
#
subsample colsample_bytree
#
subsample=[0.8,0.9,1]
#
colsample_bytree=[0.8,0.9,1]
#
document, clf = tun_params(document, clf, dftrain, dftest,
#
{'subsample': subsample, 'colsample_bytree': colsample_bytree}, features, label)
#
#
#
reg_alpha
#
reg_alpha=[0.001,0.01,0.1,1,10]
#
document, clf = tun_params(document, clf, dftrain, dftest,
#
{'reg_alpha': reg_alpha}, features, label)
#
#
#
reg_lambda
#
reg_lambda = [0.001, 0.01, 0.1, 1, 10]
#
document, clf = tun_params(document, clf, dftrain, dftest,
#
{'reg_lambda': reg_lambda}, features, label)
document
.
add_heading
(
'调整参数'
)
max_depth
=
[
2
,
3
]
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
)
# gamma
gamma
=
[
i
/
10
for
i
in
range
(
0
,
5
)]
document
,
clf
=
tun_params
(
document
,
clf
,
dftrain
,
dftest
,{
'gamma'
:
gamma
},
features
,
label
)
# subsample colsample_bytree
subsample
=
[
0.8
,
0.9
,
1
]
colsample_bytree
=
[
0.8
,
0.9
,
1
]
document
,
clf
=
tun_params
(
document
,
clf
,
dftrain
,
dftest
,
{
'subsample'
:
subsample
,
'colsample_bytree'
:
colsample_bytree
},
features
,
label
)
# reg_alpha
reg_alpha
=
[
0.001
,
0.01
,
0.1
,
1
,
10
]
document
,
clf
=
tun_params
(
document
,
clf
,
dftrain
,
dftest
,
{
'reg_alpha'
:
reg_alpha
},
features
,
label
)
# reg_lambda
reg_lambda
=
[
0.001
,
0.01
,
0.1
,
1
,
10
]
document
,
clf
=
tun_params
(
document
,
clf
,
dftrain
,
dftest
,
{
'reg_lambda'
:
reg_lambda
},
features
,
label
)
#==生成模型最后的报告,各个特征的单变量图,PDP,liftchart
dftrain
=
xgboost
.
predict
(
clf
,
dftrain
,
features
)
...
...
@@ -87,17 +87,17 @@ def report(dftrain,dftest,features,label,path,filename):
document
.
add_paragraph
(
'测试集分渠道--liftchart'
)
document
.
add_picture
(
'tmp.png'
)
#
#
== 各个特征的 单变量图 和 pdp 图
#
for i in featureimp.feature.tolist():
#
drawplot.univarchart(dftest, i, label, bin=10, title='单变量%s' % i,
#
ylabel='逾期率').savefig('tmp.png')
#
document.add_paragraph('单变量%s' % i)
#
document.add_picture('tmp.png')
#
#= pdp
#
drawplot.pdpchart(dftest, i, 'predict_proba', bin=10, title='pdp %s' % i,
#
ylabel='模型分').savefig('tmp.png')
#
document.add_paragraph('pdp %s' % i)
#
document.add_picture('tmp.png')
#== 各个特征的 单变量图 和 pdp 图
for
i
in
featureimp
.
feature
.
tolist
():
drawplot
.
univarchart
(
dftest
,
i
,
label
,
bin
=
10
,
title
=
'单变量
%
s'
%
i
,
ylabel
=
'逾期率'
)
.
savefig
(
'tmp.png'
)
document
.
add_paragraph
(
'单变量
%
s'
%
i
)
document
.
add_picture
(
'tmp.png'
)
#= pdp
drawplot
.
pdpchart
(
dftest
,
i
,
'predict_proba'
,
bin
=
10
,
title
=
'pdp
%
s'
%
i
,
ylabel
=
'模型分'
)
.
savefig
(
'tmp.png'
)
document
.
add_paragraph
(
'pdp
%
s'
%
i
)
document
.
add_picture
(
'tmp.png'
)
filetool
.
saveDocument
(
document
,
path
,
filename
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment