热线电话:13121318867

登录
2020-07-31 阅读量: 3072
用scorecardpy库画图出现错误提示:RuntimeWarning: More than 20 figures have been opened.
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 31 18:59:15 2020
@author: Administrator
"""
#第一步导入相关库
import numpy as np
import pandas as pd
import scorecardpy as sc
import matplotlib as mpl
import matplotlib.pyplot as plt
#第二步准备数据
x_a=pd.DataFrame(np.random.random_integers(1,4,(1000,30)))
x_a.columns=["x"+str(i)for i in x_a.columns]
y_a=pd.DataFrame({'y':['good','bad']}).sample(1000, replace=True)
y_a.reset_index(inplace=True)
data1=pd.concat([x_a,y_a],axis=1)
y_b=pd.DataFrame({'y':['good','bad']}).sample(50, replace=True)
data4 = pd.concat([data1,y_b], ignore_index=True,axis=0)
#第三步画图
bins = sc.woebin(data4, y="y")
sc.woebin_plot(bins)

'''

运行最后一行命令时会出现错误提示如下:

C:\ProgramData\Anaconda3\lib\site-packages\scorecardpy\woebin.py:1203: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).

fig, ax1 = plt.subplots()

C:\ProgramData\Anaconda3\lib\site-packages\scorecardpy\woebin.py:1203: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).

C:\ProgramData\Anaconda3\lib\site-packages\scorecardpy\woebin.py:1203: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).


'''

image.png

#这是什么原因?是因为x变量的个数太多了,超过了画图允许的个数,画图允许的默认个数是20

#把这个参数改大一些,比如改成40就可以画出来了


plt.rcParams['figure.max_open_warning']=40

sc.woebin_plot(bins)

#再执行就可以出结果了

image.png


image.png

image.png

0.0005
5
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子