Skip to content

Commit

Permalink
Merge pull request #3 from hackermike/mf-patch-3
Browse files Browse the repository at this point in the history
bins_X_grouped may be unset if exceptions thrown for all cut attempts.
  • Loading branch information
hackermike authored Sep 8, 2020
2 parents 1641bcc + f859215 commit 2b627b2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion xverse/transformer/_binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def train(self, X, y):
r = 0
max_bins = self.max_bins
force_bins = self.force_bins
bins_X_grouped = None

"""Calculate spearman correlation for the distribution identified. If the distribution is not monotonic,
reduce bins and reiterate. Proceed until either one of the following happens,
Expand All @@ -168,7 +169,7 @@ def train(self, X, y):
Execute this block when monotonic relationship is not identified by spearman technique.
We still want our code to produce bins.
"""
if len(bins_X_grouped) == 1:
if bins_X_grouped is None or len(bins_X_grouped) == 1:
bins = algos.quantile(X, np.linspace(0, 1, force_bins)) #creates a new binnning based on forced bins
if len(np.unique(bins)) == 2:
bins = np.insert(bins, 0, 1)
Expand Down

0 comments on commit 2b627b2

Please sign in to comment.