简介&安装
简介
评分卡建模尽在于此
Scorecard-Bundle是一个基于Python的高级评分卡建模API,实施方便且符合Scikit-Learn的调用习惯,包含的类均遵守Scikit-Learn的fit-transform-predict习惯。Scorecard-Bundle包括基于ChiMerge的特征离散化、WOE编码、基于信息值(IV)和共线性的特征评估、基于逻辑回归的评分卡模型、针对二元分类任务的模型评估、以及评分卡模型的模型解释工具。
展示如何训练评分卡模型的完整示例见Example Notebooks
Scorecard-Bundle各模块的详细介绍见API Reference (Detailed documentation about the package)
Scorecard-Bundle中WOE和IV的计算、评分卡转化等的核心计算逻辑源自《信用风险评分卡研究 —基于SAS的开发与实施》一书,该书籍由王松奇和林治乾翻译自Mamdouh Refaat的"Credit Risk Scorecards: Development and Implementation Using SAS";而ChiMerge算法则是复现了原作者Randy Kerber的论文"ChiMerge: Discretization of Numeric Attributes"。
安装
由于每次版本更新都在修复已知的bug或添加重要的新功能,强烈建议安装最新版本 。严重的bug原则上都会在被发现的第一时间修复,因此若在使用Scorecard-Bundle的过程中怀疑存在bug,欢迎到Github主页的issue中记录。
注意,Scorecard-Bundle依赖NumPy, Pandas, matplotlib, Scikit-Learn, SciPy,可单独安装或直接使用Anaconda安装。
-
Pip: Scorecard-Bundle可使用pip安装:
pip install --upgrade scorecardbundle注意!最新版本可能尚未被纳入一些镜像源网站 (e.g. https://mirrors.aliyun.com/pypi/simple/ )。因此为了更新到最新版本,可以使用下面的命令,指定 https://pypi.org/project 作为源
pip install -i https://pypi.org/project --upgrade scorecardbundle导入模块:
from scorecardbundle.feature_discretization import ChiMerge as cm from scorecardbundle.feature_discretization import FeatureIntervalAdjustment as fia from scorecardbundle.feature_encoding import WOE as woe from scorecardbundle.feature_selection import FeatureSelection as fs from scorecardbundle.model_training import LogisticRegressionScoreCard as lrsc from scorecardbundle.model_evaluation import ModelEvaluation as me from scorecardbundle.model_interpretation import ScorecardExplainer as mise -
手动: 也可以从Github下载代码
<https://github.com/Lantianzz/Scorecard-Bundle>, 直接导入:import sys sys.path.append('E:\Github\Scorecard-Bundle') # add path that contains the codes from scorecardbundle.feature_discretization import ChiMerge as cm from scorecardbundle.feature_discretization import FeatureIntervalAdjustment as fia from scorecardbundle.feature_encoding import WOE as woe from scorecardbundle.feature_selection import FeatureSelection as fs from scorecardbundle.model_training import LogisticRegressionScoreCard as lrsc from scorecardbundle.model_evaluation import ModelEvaluation as me from scorecardbundle.model_interpretation import ScorecardExplainer as mise