amphibian-dev / toad

ESC Team's credit scorecard tools.
https://toad.readthedocs.io
MIT License
478 stars 174 forks source link

分箱Combiner在训练集上训练后,无法使用至无标签的测试集上 #90

Closed Shiruiruiwang closed 2 years ago

Shiruiruiwang commented 2 years ago

由于测试集没有标签,直接使用combiner.transform会报错:"['label'] not in index" 尝试了增加exclude='label'参数,但仍旧会报错,且该参数在训练时(fit时)无法加入,所以它必须要求训练数据带有标签... 请问这一问题怎么处理?谢谢!

Secbone commented 2 years ago

@siri-ya 有数据样例么?没太理解你说的没有标签是什么意思?

Shiruiruiwang commented 2 years ago

嗯嗯,代码样例是这样: c = toad.transform.Combiner()

toBinedData:需要被分箱的训练集数据,标签为'label'列

c.fit(toBinedData,y='label',method='chi',min_samples=0.05)

bined_trn:分箱后的训练集数据

binned_trn = c.transform(toBinedData,exclude='label')

toBined_tst:需要被分箱的测试集,由于无标签(需要模型预测),它们没有label这一列

binned_tst = c.transform(toBined_tst,exclude='label')

我后面发现,是我前面的处理问题,toBined_tst可以不包含label列,运行是没有问题的,不好意思打扰啦!

Secbone @.***> 于2021年12月5日周日 下午9:49写道:

@siri-ya https://github.com/siri-ya 有数据样例么?没太理解你说的没有标签是什么意思?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/amphibian-dev/toad/issues/90#issuecomment-986233855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU4MG2DSQKFLQTOXQTRUTGDUPNUYDANCNFSM5JMPW3MA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.