【发布时间】:2022-10-16 05:58:33
【问题描述】:
我想在我的数据上的模块 scorecardpy 中对函数 woebin 使用“special_values”,但它不起作用。所以我找到了一些例子,但我遇到了同样的错误。 代码:
import scorecardpy as sc
dat = sc.germancredit()
dt_s = sc.var_filter(dat, y="creditability")
train, test = sc.split_df(dt_s, 'creditability').values()
bins = sc.woebin(dt_s, y="creditability")
special_values = {
'credit.amount': [2600, 9960, "6850%,%missing"],
'purpose': ["education", "others%,%missing"]
}
breaks_adj = {
'age.in.years': [26, 35, 40],
'other.debtors.or.guarantors': ["none", "co-applicant%,%guarantor"]
}
bins_adj = sc.woebin(dt_s, y="creditability", breaks_list=breaks_adj,special_values=special_values)
出现错误:
MergeError:只能传递参数“on”或“left_index”和“right_index”,而不是两者的组合。
你可以帮帮我吗 ?你知道为什么它不起作用吗?
没有“special_values”就可以了。
导致问题:
bins_adj = sc.woebin(dt_s, y="creditability", breaks_list=breaks_adj,special_values=special_values) -
我重新启动内核,我得到另一个错误:(
bins_adj = sc.woebin(dt_s, y="creditability",breaks_list=breaks_adj,special_values=special_values)
[INFO] 创建 woe binning ...
回溯(最近一次通话最后):
文件“”,第 1 行,在 bins_adj = sc.woebin(dt_s, y="creditability",breaks_list=breaks_adj,special_values=special_values)
文件“C:\ProgramData\Anaconda3\lib\site-packages\scorecardpy\woebin.py”,第 958 行,在 woebin 箱[x_i] = woebin2(
woebin2 中的文件“C:\ProgramData\Anaconda3\lib\site-packages\scorecardpy\woebin.py”,第 722 行 bin_list = woebin2_tree(
woebin2_tree 中的文件“C:\ProgramData\Anaconda3\lib\site-packages\scorecardpy\woebin.py”,第 484 行 bin_list = woebin2_init_bin(dtm,init_count_distr=init_count_distr,breaks=breaks,spl_val=spl_val)
woebin2_init_bin 中的文件“C:\ProgramData\Anaconda3\lib\site-packages\scorecardpy\woebin.py”,第 276 行 dtm_binsv_list = dtm_binning_sv(dtm,中断,spl_val)
文件“C:\ProgramData\Anaconda3\lib\site-packages\scorecardpy\woebin.py”,第 108 行,在 dtm_binning_sv sv_df['value'] = sv_df['value'].astype(dtm['value'].dtypes)
文件“C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py”,第 5877 行,astype new_data = self._mgr.astype(dtype=dtype,copy=copy,errors=errors)
文件“C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py”,第 631 行,astype return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
文件“C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py”,第 427 行,在应用中 应用 = getattr(b, f)(**kwargs)
文件“C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py”,第 673 行,astype 值 = astype_nansafe(vals1d, dtype, copy=True)
文件“C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\dtypes\cast.py”,第 1074 行,在 astype_nansafe 返回 lib.astype_intsafe(arr.ravel(), dtype).reshape(arr.shape)
文件“pandas_libs\lib.pyx”,第 619 行,在 pandas._libs.lib.astype_intsafe
ValueError:无法将浮点 NaN 转换为整数
【问题讨论】:
-
您能否发布导致问题的行以及错误堆栈跟踪?
-
请编辑您的帖子,而不是添加评论。
标签: python