Coder Social home page Coder Social logo

francoisporcher / calibration_curve Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 665 KB

Pushing classifiers to their limits by chaining a second model to calibrate probabilities

Jupyter Notebook 100.00%
calibration classification machine-learning python sklearn

calibration_curve's Introduction

๐Ÿ“Š Calibration Curve

Calibration Curve is an advanced concept in machine learning that allows to improve the performance of classifier even after they have been already trained.

The issue is that a trained classifier is uncalibrated, meaning that it is overconfident or underconfident in some regions.

The calibration of probabilities allows us to transform the predicted probabilities of a model into a probability distribution that matches the empirical distribution of the target variable.

In other words we chain a new model to the trained model that predicts calibrated probabilities.

A very concrete example:

Let's imagine our model has a cholesterol of 235 as input feature, and outputs a probability of 0.78 that the patient has cardiovascular issues. Let's imagine that this patient really has cardiovascular issues, and that our model has a threshold of 0.5. So in this case our model outputs a correct prediction (0.78 > 0.5).

However:

The model is over confident because only 69% of the population having a similar cholesterol have a heart disease. This is exactly the phenomenon of overconfidence/underconfidence that we are trying to calibrate.

๐ŸŽ‡ Demo

Random Forest

We can clearly see that after calibration, the probabilities are much closer to the empirical distribution we are aiming for.

Screenshot

Same phenomenon.

SVC (Support Vector Classifier)

Screenshot

โžก๏ธ Conclusion:

Curve Calibration is often the last step in the fine tuning of a model, but it can significantly improve the quality of predictions, and hence should not be overlooked!

๐Ÿ™‹๐Ÿปโ€โ™‚๏ธ Authors

๐Ÿ”— Links

portfolio linkedin

calibration_curve's People

Contributors

francoisporcher avatar

Stargazers

 avatar Wind&Moon avatar Hongli Ma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.