项目场景:
调用scorecardpy
包对feature进行分箱时报错:AttributeError: ‘PandasArray’ object has no attribute ‘_str_findall’
scorecardpy
包目标是通过提供一些常见任务的功能,使传统信用风险记分卡模型的开发变得更加容易和高效。
- 数据分区 (
split_df
) - 变量选择 (
iv, var_filter
) - 证据权重 (
woe
) 分箱 (woebin, woebin_plot, woebin_adj, woebin_ply
) - 记分卡缩放 (
scorecard, scorecard_ply
) - 绩效评估 (
perf_eva, perf_psi
)
问题描述
对特征进行数据分箱时,选择scorecardpy进行
import scorecardpy as sc
bins = sc.woebin(df, y=label, method='tree', var_skip=skip_col, bin_num_limit=100) # 决策树分箱
sc.woebin_plot(bins)
报错:
AttributeError: 'PandasArray' object has no attribute '_str_findall'
包版本:
scorecardpy==0.1.9.7
pandas==1.2.4
原因分析:
可能是与
toad
包冲突,导致pandas
包版本过高。
解决方案:
将pandas包的版本降低为1.1.5
pip install pandas==1.1.5