question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for ordinal multi-classification

See original GitHub issue

Describe the workflow you want to enable

Encode response variable ordering with every scikit learn classifier according to the method introduced in this frequently cited paper.

Describe your proposed solution

Implement OrdinalClassifier, a classifier that takes another scikit learn classifier as input and encodes the ordinality assumption into the classifier. It’s quite simple, and there are also blog posts on it, for example by @M46F here. Here’s a slightly more advanced version that can also handle arbitrary labels that I’d be willing to contribute as a PR: https://gist.github.com/lorenzwalthert/51371894225c7b530b66bdabfad60327

A lot of classification problems are inherently ordinal in nature and this trick has proven to work well in various settings, the code is very little to add to the project, adds zero dependencies and is a much cited approach (600+).

Describe alternatives you’ve considered, if relevant

Using that code outside of scikit learn, but I think ti’s generally useful to others.

Additional context

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lorenzwalthertcommented, May 20, 2022

I think it’s important to be aware that there is a major flaws in the implementation that I wrote in that article: since each classifier are independent from each other, the method won’t give the true probability (it won’t sum up to 1)

Ok. But I don’t think that’s a big problem. We can just normalize the probability, no?

Also. here is some other related work: https://github.com/leeprevost/OrdinalClassifier

0reactions
MuhammadAgfcommented, Dec 1, 2022

I think it’s important to be aware that there is a major flaws in the implementation that I wrote in that article: since each classifier are independent from each other, the method won’t give the true probability (it won’t sum up to 1)

Ok. But I don’t think that’s a big problem. We can just normalize the probability, no?

Also. here is some other related work: https://github.com/leeprevost/OrdinalClassifier

I’ve checked the link that you share, I think it has a better implementation than the one that I provide in the medium post

Read more comments on GitHub >

github_iconTop Results From Across the Web

One-vs-Rest and One-vs-One for Multi-Class Classification
Binary classification models like logistic regression and SVM do not support multi-class classification natively and require meta-strategies.
Read more >
Tips and Tricks for Multi-Class Classification
Inherently Multi-class Classifiers. Not all models inherently support multi-class classification. Lets start by using some that do. K-nearest- ...
Read more >
Multiclass Classification Using Support Vector Machines
In its most simple type, SVM doesn't support multiclass classification natively. It supports binary classification and separating data points ...
Read more >
Comprehensive Guide to Multiclass Classification With ...
Learn how to tackle any multiclass classification problem with Sklearn. The tutorial covers how to choose a model selection strategy, ...
Read more >
Multiclass Classification Using SVM
In this article understand the multiclass classification using SVM (Support Vector Machine) for aspiring data scientists.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found