Skip to content

Commit

Permalink
fix for empty bin corner case in generic loss mode
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixWick committed Dec 1, 2023
1 parent d3c6cbe commit 81c8dcf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions cyclic_boosting/generic_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def calc_parameters(
y_pred_bins = np.split(y_pred[sorting], split_indices)

# keep potential empty bins in multi-dimensional features
all_bins = range(max(feature.lex_binned_data) + 1)
all_bins = range(feature.n_bins)
empty_bins = list(set(bins) ^ set(all_bins))
for i in empty_bins:
y_pred_bins.insert(i, np.zeros((0, 3)))
Expand All @@ -90,14 +90,11 @@ def calc_parameters(
)

neutral_factor = self.unlink_func(np.array(self.neutral_factor_link))
if n_bins + 1 == feature.n_bins:
parameters = np.append(parameters, neutral_factor)
uncertainties = np.append(uncertainties, 0)

if neutral_factor != 0:
epsilon = 1e-5
parameters = np.where(np.abs(parameters) < epsilon, epsilon, parameters)
parameters = np.log(parameters)

return parameters, uncertainties

def optimization(self, y: np.ndarray, yhat_others: np.ndarray, weights: np.ndarray) -> Tuple[float, float]:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyclic-boosting"
version = "1.2.3"
version = "1.2.4"
description = "Implementation of Cyclic Boosting machine learning algorithms"
authors = ["Blue Yonder GmbH"]
packages = [{include = "cyclic_boosting"}]
Expand Down

0 comments on commit 81c8dcf

Please sign in to comment.