R smbinning包详解

smbinning包是R语言中用于评分卡建模的最佳分箱工具,采用条件推测决策树算法进行监督离散化。它提供了多种功能,如自定义分组、探索性数据分析、因子变量分箱等。用户可以使用smbinning.plot、smbinning.sql和smbinning.gen等工具进一步处理输出结果。
摘要由CSDN通过智能技术生成

做评分卡用到
整理一下


smbinning

Optimal Binning for Scoring Modeling
最佳分箱将数字特征归类为分数模式中的其他用途。 这个过程,也称为监督离散化,利用递归分区来将数字特征分类。
特定的算法是条件推测决策树(Conditional Inference Trees),它最初排除缺失值(NA)以计算切点,并在计算信息值的过程中稍后添加它们。

The user should save the output result so it can be used with smbinning.plot, smbinning.sql, and smbinning.gen.

关于条件推测决策树的认知

经典决策树,条件推断树,随机森林,SVM的R实现
决策树算法汇总
ctree: Conditional Inference Trees

party包的处理方式:它的背景理论是“条件推断决策树”(conditional inference trees):它根据统计检验来确定自变量和分割点的选择。即先假设所有自变量与因变量均独立。再对它们进行卡方独立检验,检验P值小于阀值的自变量加入模型,相关性最强的自变量作为第一次分割的自变量。自变量选择好后,用置换检验来选择分割点。用party包建立的决策树不需要剪枝,因为阀值就决定了模型的复杂程度。所以如何决定阀值参数是非常重要的(参见ctree_control)。较为流行的做法是取不同的参数值进行交叉检验,选择误差最小的模型参数。

**Usage**
    smbinning(df, y, x, p = 0.05)
Arguments
df  A data frame.
y   Binary response variable (0,1). Integer (int) is required. Name of y must not have a dot. Name "default" is not allowed.
x   Continuous characteristic. At least 5 different values. Value Inf is not allowed.
Name of x must not have a dot.
p   Percentage of records per bin. Default 5% (0.05). This parameter only accepts values greater that 0.00 (0%) and lower than 0.50 (50%).
m02result=smbinning(df=traindata,y="y",x="m02",p=0.05)
smbinning.plot(m02result,option="WoE",sub="m02") 
m02result$iv #信息值
> m02result$iv
[1] 0.0503
m02result$bands#分箱

> m02result$bands
[1]  0.0000 19.0000 44.0000 66.8262
> m02result$ivtable
  Cutpoint CntRec CntGood CntBad CntCumRec CntCumGood CntCumBad PctRec GoodRate BadRate   Odds  LnOdds     WoE     IV
1    <= 19  76110     772  75338     76110        772     75338 0.4789   0.0101  0.9899 0.0102 -4.5808  0.1649 0.0141
2    <= 44  72270     557  71713    148380       1329    147051 0.4548   0.0077  0.9923 0.0078 -4.8579 -0.1122 0.0054
3     > 44  10533      40  10493    158913       1369    157544 0.0663   0.0038  0.9962 0.0038 -5.5696 -0.8240 0.0308
4  Missing      0       0      0    158913       1369    157544 0.0000      NaN     NaN    NaN     NaN     NaN    
  • 0
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值