python最优分箱中woe计算(求大圣)

Python017

python最优分箱中woe计算(求大圣),第1张

>>>list =[None,None,None,None,"a","b","c",None,"d",12,None,2,4,5,4]>>>list = list[4:]>>>len(list)11>>>list['a', 'b', 'c', None, 'd', 12, None, 2, 4, 5, 4]>>>#如果你的list 格式是相同的 比如前面4个都是None,这个格式是固定的,那么切片很容易解决

https://blog.csdn.net/kevin7658/article/details/50780391

IV 与 WOE:

IV表示一个变量的预测能力:

<=0.02,没有预测能力,不可用

0.02~0.1 弱预测性

0.1~0.2 有一定预测能力

0.2+高预测性

 IV还可以用来挑选变量,IV就越大,它就越应该进入到入模变量列表中。

Psi

def calculate_psi(expected, actual, buckets=10): # test, base

   def psi(expected_array, actual_array, buckets):

       def scale_range(input, min, max):

           input += -(np.min(input))

           input /= np.max(input) / (max - min)

           input += min

           return input

       # 按照概率值分10段

       breakpoints = np.arange(0, buckets + 1) / (buckets) * 100

       breakpoints = scale_range(breakpoints, np.min(expected_array), np.max(expected_array))

       expected_percents = np.histogram(expected_array, breakpoints)[0] / len(expected_array)

       # print(expected_percents)

       actual_percents = np.histogram(actual_array, breakpoints)[0] / len(actual_array)

       def sub_psi(test, base): # test,base

           if base == 0:

 base = 0.0001

           if test == 0:

 test = 0.0001

           value = (test - base) * np.log(test / base)

           return(value)

       psi_value = np.sum(sub_psi(expected_percents[i], actual_percents[i]) for i in range(0, len(expected_percents)))

       return(psi_value)

   if len(expected.shape) == 1:

       psi_values = np.empty(len(expected.shape))

   else:

       psi_values = np.empty(expected.shape[0])

   for i in range(0, len(psi_values)):

       if len(psi_values) == 1:

           psi_values = psi(expected, actual, buckets)

       else:

           psi_values[i] = psi(expected[:,i], actual[:,i], buckets)

   return(psi_values)

1、打开idle。点击file,然后点击new file 这是创建一个新的文件。新建...

答:1、打开idle。点击file,然后点击new file.这是创建一个新的文件。 新建一个文件之后,我们输入第一行代码,使用print函数,在屏幕上打印一句话,其中字符串要使用双引号,输入法要使用英文输入法,如果符号使用中文输入法输入,就会出现错误。p...

2020-11-17 回答者: 环球青藤  1个回答

python sympy中生成的公式怎么粘到word里

答:右键选 show math as→mathML Code 全选复制,在word中右键以文本形式粘贴

2018-01-27 回答者: 夜歌在路上 2个回答

如何使用python提取并处理word文档中插入的mathtyp...

答:我没做过,只能提供大概思路给你。这是mathtype的SDK:,里面关于API的描述: MathType API Documentation The MathType API allows you to call functions used by the MathType Commands For Word. On Windows, this API is split between MathP...

2017-10-03 回答者: 天天不看java 1个回答

如何用python写这个代码

问:使用两个参数定义一个名为dictionaryToListOfValues的函数。 此函数的第...

答:使用Python自带的IDLE 在开始-->程序-->Python2.5(视你安装的版本而不同)中找到IDLE(Python GUI)。 点击后弹出如下窗体: 1,在>>>提示符后输入代码,回车,就可以执行此代码。 IDLE支持语法高亮,支持自动缩进,支持方法提示,不过提示的很慢。...

2019-10-17 回答者: 司马刀剑 2个回答 3

如何用python编写计算器

答:我想你的需求应该是一个图形界面的程序,而不是简单的在命令行上输入。 那么,要做的第一件事就是选择一个图形界面套件。可以使用原生的TK,也可以用跨平台性能很好的wxPython,或者是整体结构很像MFC的PyWin32。至于pyGTK,pyQT,都是可选的,但...

2011-05-30 回答者: 碧蓝右耳 3个回答 6

用Python编写代码1×2×3+4×5×6+7×8×9+++···99×100×1...

答:t=1 for i in range(1,102): t*=i print(t)

2020-04-05 回答者: 知道网友 1个回答 2

python 如何识别docx中的公式

答:import fnmatch, os, sys, win32com.client readpath=r'D:\123' wordapp = win32com.client.gencache.EnsureDispatch("Word.Application") try: for path, dirs, files in os.walk(readpath): for filename in files: if not fnmatch.fnmatch(fi...

2016-07-09 回答者: 知道网友 1个回答 2

如何用Python代码运行Word中的VBA

问:请问有什么好的办法用Python代码运行Word中的VBA吗, 具体需要import哪...

答:安装pypiwin32 import win32com.client app= win32com.client.Dispatch("word.Application") app.Workbooks.Open("宏代码所在文件路径") app.Application.Run("宏名称") app.Application.Quit()

2019-08-31 回答者: 娘化的新世界 1个回答

用Python写一个,两个数的加,减,乘,除的函数,...

答:我课程中的部分代码(除没写): def f_add(a,b): return a+bdef f_mul(a,b): return a*bdef f_sub(a,b): return a-b def g1(f,a,b): return f(a,b)a,b,c,d = 1,2,3,4print g1(f_sub, g1(f_mul, g1(f_add,a,b), c), d), g1(f_mul, g1(f_add,a,b)...

2017-11-21 回答者: 黑板客 1个回答 4

python编写2个函数代码,实现求最小公倍数和最大公...

问:使用两个函数实现,最小公倍数和最大公约数

答:def gcd(a, b): # 求最大公约数 x = a % b while (x != 0): a, b = b, x x = a % b return bdef lcm(a,b): # 求最小公倍数 return a*b//gcd(a,b) 程序缩进如图所示