Skip to content

Commit

Permalink
init bin
Browse files Browse the repository at this point in the history
  • Loading branch information
ShichenXie committed Mar 26, 2020
1 parent e040924 commit b2202a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
@@ -1,6 +1,7 @@
# scorecardpy 0.1.9.2
* fixed a bug in woebin function caused by the new function explode in pandas >= 0.25
* fixed a bug when intialzing binning
* modified the method to create initial fine binning breaks.

# scorecardpy 0.1.9
* fixed a bug in scorecard_ply, supports card as a DataFrame
Expand Down
4 changes: 2 additions & 2 deletions scorecardpy/woebin.py
Expand Up @@ -281,9 +281,9 @@ def woebin2_init_bin(dtm, init_count_distr, breaks, spl_val):
if is_numeric_dtype(dtm['value']): # numeric variable
xvalue = dtm['value'].astype(float)
# breaks vector & outlier
iq = xvalue.quantile([0.25, 0.5, 0.75])
iq = xvalue.quantile([init_count_distr, 0.25, 0.75, 1-init_count_distr])
iqr = iq[0.75] - iq[0.25]
xvalue_rm_outlier = xvalue if iqr == 0 else xvalue[(xvalue >= iq[0.25]-3*iqr) & (xvalue <= iq[0.75]+3*iqr)]
xvalue_rm_outlier = xvalue[(xvalue >= iq[init_count_distr]-3*iqr) & (xvalue <= iq[1-init_count_distr]+3*iqr)]
# number of initial binning
n = np.trunc(1/init_count_distr)
len_uniq_x = len(np.unique(xvalue_rm_outlier))
Expand Down

0 comments on commit b2202a5

Please sign in to comment.