Giter VIP home page Giter VIP logo

scorecard-modeling's Introduction

评分卡模型建模流程

数据导入和建立

  • 读入数据:导入数据集 application.csv
  • 选择合适的建模样本
  • 数据集划分成训练集和测试集

第一步:数据预处理

  • 数据清洗:时间、类型特征等
  • 格式转换
  • 缺失值填补

第二步:变量衍生

  • 考虑申请额度与收入的占比
  • 考虑earliest_cr_line到申请日期的跨度,以月份记

第三步:分箱

  • 采用ChiMerge,要求分箱完之后:
    (1)不超过5箱
    (2)Bad Rate单调
    (3)每箱同时包含好坏样本
    (4)特殊值如-1,单独成一箱

  • 连续型变量可直接分箱

  • 类别型变量:
    (a)当取值较多时,先用bad rate编码,再用连续型分箱的方式进行分箱
    (b)当取值较少时:

    (b1)如果每种类别同时包含好坏样本,无需分箱
    (b2)如果有类别只包含好坏样本的一种,需要合并

第四步:WOE编码、计算IV

  • WOE的公式:

  • WOE 的值越高,代表着该分组中客户是坏客户的风险越低。
  • IV值是用来衡量某个变量对好坏客户区分能力的一个指标,IV值公式如下:
  • 关于更详细的WOE和IV可见:数据挖掘模型中的IV和WOE详解

第五步:单变量分析和多变量分析,均基于WOE编码后的值

  • 选择IV高于0.02的变量
  • 比较两两线性相关性,如果相关系数的绝对值高于阈值,剔除IV较低的一个
  • 亦可使用机器学习的特征选择方法(RF、Xgboost)

第六步:逻辑回归模型(或其他机器学习算法)

  • 要求:
    (1)变量显著
    (2)系数为负
  • 逻辑回归的原理可见逻辑回归 - 理论篇
  • 每次迭代中,剔除最不显著的变量,直到
    (1) 剩余所有变量均显著
    (2) 没有特征可选
  • 亦可尝试L1或L2约束

第七步:评估

  • 利用ks和AUC等评估指标(亦可使用混淆矩阵)

  • KS值越大,表示模型能够将正、负客户区分开的程度越大。

  • 通常来讲,KS>0.2即表示模型有较好的预测准确性。

  • KS绘制方式与ROC曲线略有相同,都要计算TPR和FPR。但是TPR和FPR都要做纵轴,横轴为把样本分成多少份。

  • 步骤:
    (1)按照分类模型返回的概率降序排列
    (2)把0-1之间等分N份,等分点为阈值,计算TPR、FPR
    (3)对TPR、FPR描点画图即可

  • KS值即为Max(TPR-FPR)

scorecard-modeling's People

Contributors

yanx27 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.