Skip to content

DOC improve the cost-sensitive learning example - #29149

Merged
lorentzenchr merged 3 commits into
scikit-learn:mainfrom
ogrisel:improve-cost-sensitive-learning-example
Jun 3, 2024
Merged

lorentzenchr merged 3 commits into
scikit-learn:mainfrom
ogrisel:improve-cost-sensitive-learning-example

Conversation

@ogrisel

@ogrisel ogrisel commented May 31, 2024 •

Copy link
Copy Markdown
Member

Here is a summary of the proposed changes:

  • better names for metrics to avoid confusion between gains and costs;
  • fixed the definition of the variable cost metric for the fraud transaction case to better align with the example in Elkan's paper;
  • removed any reference to balanced accuracy as the example is already long and I found it was mostly a distraction away from the important message on the business metrics;
  • use the new prefit=True option of FixedThresholdClassifier.

/cc @glemaitre @lorentzenchr.

@github-actions

github-actions Bot commented May 31, 2024 •

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 5382a42. Link to the linter CI: here

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. I think that @lorentzenchr will be happy to remove the balanced-accuracy mention :)

@ogrisel

ogrisel commented May 31, 2024

Copy link
Copy Markdown
Member Author

@lorentzenchr thanks for the review, I think I addressed all your feedback.

@lorentzenchr
lorentzenchr merged commit 5d92c35 into scikit-learn:main Jun 3, 2024
@ogrisel
ogrisel deleted the improve-cost-sensitive-learning-example branch June 3, 2024 07:38
Comment on lines -514 to -516
fraudulent_refuse = (mask_true_positive.sum() * 50) + amount[
mask_true_positive
].sum()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the amount here is removed, when I gave a talk on this, this was a nice point to make.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you don't gain the amount when rejecting a fraudulent case :). Indeed, you are just not loosing it.

The amount itself only contribute when accepting the claim by taking a proportional amount.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we have the false negative counterpart. Removing this puts a massive pressure on making sure we have no false negatives, and will somewhat be okay with true positives being low, since the amounts are usually a lot larger than 50€.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated PR puts our example cost matrix better in line with the one proposed in Elkan 2001 paper on cost-sensitive learning (the fixed costs and gains are not the same but the variable components are compatible). Here is an excerpt of the relevant paragraph (part of section 1.2):

image

I don't understand why we would put a gain that is proportional to amount in the fraudulent_refuse case. If you catch a frauder, nobody will pay the bank the amount of the transaction the frauder would have otherwise stolen.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Would be nice to have this chart in the example actually, makes things quite clear.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep that in mind for a future iteration on this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants