在开发评分卡的时候,我们需要将原始数据替换成WOE编码,我给出的代码如下:
def applyBinMap(X_data, bin_map, var):
"""
将最优分箱的结果WOE值对原始数据进行编码
------------------------------------------------
Params
x: pandas Series
bin_map: pandas dataframe, map table
------------------------------------------------
Return
bin_res: pandas Series, result of bining
"""
x = X_data[var]
bin_map = bin_map[bin_map['var_name'] == var]
bin_res = np.array([0] * x.shape[-1], dtype=float)
for i in bin_map.index:
upper = b