Skip to content

Commit

Permalink
FIX update deprecated param for example using class_likelihood_ratios (
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanieSenger authored Jan 20, 2025
1 parent 9312206 commit 119ade2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/model_selection/plot_likelihood_ratios.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class proportion than the target application.

estimator = LogisticRegression().fit(X_train, y_train)
y_pred = estimator.predict(X_test)
pos_LR, neg_LR = class_likelihood_ratios(y_test, y_pred)
pos_LR, neg_LR = class_likelihood_ratios(y_test, y_pred, replace_undefined_by=1.0)
print(f"LR+: {pos_LR:.3f}")

# %%
Expand All @@ -81,7 +81,7 @@ class proportion than the target application.

def scoring(estimator, X, y):
y_pred = estimator.predict(X)
pos_lr, neg_lr = class_likelihood_ratios(y, y_pred, raise_warning=False)
pos_lr, neg_lr = class_likelihood_ratios(y, y_pred, replace_undefined_by=1.0)
return {"positive_likelihood_ratio": pos_lr, "negative_likelihood_ratio": neg_lr}


Expand Down
4 changes: 2 additions & 2 deletions sklearn/metrics/_scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,11 +753,11 @@ def make_scorer(


def positive_likelihood_ratio(y_true, y_pred):
return class_likelihood_ratios(y_true, y_pred)[0]
return class_likelihood_ratios(y_true, y_pred, replace_undefined_by=1.0)[0]


def negative_likelihood_ratio(y_true, y_pred):
return class_likelihood_ratios(y_true, y_pred)[1]
return class_likelihood_ratios(y_true, y_pred, replace_undefined_by=1.0)[1]


positive_likelihood_ratio_scorer = make_scorer(positive_likelihood_ratio)
Expand Down

0 comments on commit 119ade2

Please sign in to comment.