变量分箱(woebin, woebin_plot, woebin_adj, woebin_ply) 分数转换(scorecard, scorecard_ply) 效果评估(perf_eva, perf_psi) scorecardpy安装 pip install scorecardpy 基本流程 数据准备 import scorecardpy as sc dat = sc.germancredit() ## 变量筛选 dt_s = sc.var_filter(dat, y="creditability")...
train_woe=sc.woebin_ply(train[cols], bins_adj) test_woe=sc.woebin_ply(test[cols], bins_adj) train_woe.columns'''Index(['creditability', 'credit.history_woe', 'purpose_woe', 'other.debtors.or.guarantors_woe', 'duration.in.month_woe', 'present.employment.since_woe', 'savings.accoun...
分箱完成后,使用woebin_ply()函数对变量进行woe变换,之后需要把所得到的woe值作为模型的输入:train_woe = sc.woebin_ply(train, bins_adj)test_woe = sc.woebin_ply(test, bins_adj)模型训练 y_train = train_woe.loc[:,'creditability']X_train = train_woe.loc[:,train_woe.columns != 'credit...
train_woe=sc.woebin_ply(train,bins_adj) test_woe=sc.woebin_ply(test,bins_adj) y_train=train_woe.loc[:,'creditability'] X_train=train_woe.loc[:,train_woe.columns!='creditability'] y_test=test_woe.loc[:,'creditability'] X_test=test_woe.loc[:,train_woe.columns!='creditability'] #...
train_woe = sc.woebin_ply(train, bins_adj) test_woe = sc.woebin_ply(test, bins_adj) y_train = train_woe.loc[:,'creditability'] X_train = train_woe.loc[:,train_woe.columns != 'creditability'] y_test = test_woe.loc[:,'creditability'] ...
证据权重 (woe) 分箱(woebin、woebin_plot、woebin_adj、woebin_ply) 评分卡缩放 (scorecard, scorecard_ply) 性能评估(perf_eva、perf_psi) Github:https://github.com/shichenxie/scorecardpy 案例 scorecardpy库的使用简介 - 知乎 评分卡建模工具scorecardpy全解读 - 知乎 ...
首先,scorecardpy简化了数据准备过程,通过现成的函数,如var_filter(),基于缺失率、IV值和同值性等因素,筛选出关键变量,如creditability。其默认设置可自动剔除IV值低、缺失率高或同值率过高的变量。接下来,data_split()函数帮助我们将数据划分为训练集和测试集,灵活调整切分比例。woebin()函数则...
#scorecardpy默认使用决策树分箱,method=‘tree’ #这里使用卡方分箱,method=‘chimerge’ #返回的是一个字典数据,用pandas.concat()查看所有数据 bins = sc.woebin(dt_s,y="creditability",method="chimerge") bins_df = pd.concat(bins).reset_index().drop(columns="level_0") #pandas里的concat,看表...
例如,`sc.woebin_plot`可以绘制WOE和IV的图表,`sc.perf_plot`可以绘制模型评估指标的曲线图。 除了上述的基本功能,ScorecardPy还支持一些高级功能,例如特征交互、多项式特征和变量筛选等。用户可以根据具体需求选择合适的功能来构建信用评分卡模型。 使用ScorecardPy构建信用评分卡模型的一般流程如下: 1.数据准备:包括...
sc.woebin_plot()可以画出变量分箱之后的Bi_variate图,这里的坏样本率图展示了每一箱的好坏样本数、样本占比、坏样本率,比较清晰明了。 代码语言:javascript 复制 sc.woebin_plot(bins) 分箱调整 代码语言:javascript 复制 breaks_adj=sc.woebin_adj(dt_s,"creditability",bins)defwoebin_adj(dt,y,bins,...