Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

special values in woebin #51

Open
ghost opened this issue Jul 15, 2020 · 4 comments
Open

special values in woebin #51

ghost opened this issue Jul 15, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Jul 15, 2020

  作者大大你好,我是一名Python初学者。最近在尝试使用您写的这个package,train 里面没有缺失值,已经由特殊值 -9999、-8888代替了,special_values 里面写其中一个特殊值时是可以正常跑完的,一旦填了2个就会报出以下的错误,

其中-9999是每个变量都会有的特殊值,-8888是部分变量才有的,以下问题我个人还没找到解决办法,能麻烦您看看嘛

分箱

bins=sc.woebin(train,'od',
init_count_distr=0.02,
count_distr_limit=0.05,
stop_limit=0.1,bin_num_limit=5,
special_values=[-9999,-8888])

AttributeError Traceback (most recent call last)
in
4 count_distr_limit=0.05,
5 stop_limit=0.1,bin_num_limit=5,
----> 6 special_values=[-9999,-8888])

D:\anaconda\lib\site-packages\scorecardpy\woebin.py in woebin(dt, y, x, var_skip, breaks_list, special_values, stop_limit, count_distr_limit, bin_num_limit, positive, no_cores, print_step, method, ignore_const_cols, ignore_datetime_cols, check_cate_num, replace_blank, save_breaks_list, **kwargs)
964 stop_limit=stop_limit,
965 bin_num_limit=bin_num_limit,
--> 966 method=method
967 )
968 # try catch:

D:\anaconda\lib\site-packages\scorecardpy\woebin.py in woebin2(dtm, breaks, spl_val, init_count_distr, count_distr_limit, stop_limit, bin_num_limit, method)
722 bin_list = woebin2_tree(
723 dtm, init_count_distr=init_count_distr, count_distr_limit=count_distr_limit,
--> 724 stop_limit=stop_limit, bin_num_limit=bin_num_limit, breaks=breaks, spl_val=spl_val)
725 elif method == "chimerge":
726 # 2.chimerge optimal binning

D:\anaconda\lib\site-packages\scorecardpy\woebin.py in woebin2_tree(dtm, init_count_distr, count_distr_limit, stop_limit, bin_num_limit, breaks, spl_val)
485 initial_binning = bin_list['initial_binning']
486 binning_sv = bin_list['binning_sv']
--> 487 if len(initial_binning.index)==1:
488 return {'binning_sv':binning_sv, 'binning':initial_binning}
489 # initialize parameters

AttributeError: 'NoneType' object has no attribute 'index'

@ShichenXie
Copy link
Owner

你可以把这列数据和y发我试试。
或者优先用R版本的包,那边更成熟。
原来两个版本是同步更新的,后来R版本大更新一次之后,python版本一直没时间去同步。

@ShichenXie
Copy link
Owner

ShichenXie commented Jul 16, 2020

如果你只是为了学习python的话,建议你去玩玩pandas,sklearn这种比较成熟的工具包。。。

scorecard和scorecardpy目前后面的逻辑是一模一样的,输出的结果也是差不多的

@ghost
Copy link
Author

ghost commented Jul 17, 2020

嗯嗯,谢谢您的建议~~不过还是比较在意现在这个具体是什么原因导致的错误,我已经基于自己的理解去尝试筛选和替换调整过数据了,但还是没解决根本问题 =_=

@ShichenXie
Copy link
Owner

你的数据集里面好像没有-9999和-8888吧。woebin一般情况下是可以自动将缺失分为一箱的。如果只是为了处理缺失值,可以不填充为特殊值。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant