def discrete(self, x, bin=5):
#res = np.array([0] * x.shape[-1], dtype=int)
#?????????????????????WOE?????????????<=?WOE??
x_copy = pd.Series.copy(x)
x_copy = x_copy.astype(str)
#x_copy = x_copy.astype(np.str_)
#x_copy = x
x_gt0 = x[x>=0]
#if x.name == 'TD_PLTF_CNT_1M':
#bin = 5
#x_gt0 = x[(x>=0) & (x<=24)]
for i in range(bin):
point1 = stats.scoreatpercentile(x_gt0, i * (100.0/bin))
point2 = stats.scoreatpercentile(x_gt0, (i + 1) * (100.0/bin))
x1 = x[(x >= point1) & (x <= point2)]
mask = np.in1d(x, x1)
#x_copy[mask] = i + 1
x_copy[mask] = '%s-%s' % (point1,point2)
#x_copy[mask] = point1
#print x_copy[mask]
#print x
#print x
return x_copy
information_value.py 文件源码
python
阅读 35
收藏 0
点赞 0
评论 0
评论列表
文章目录