Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WIP] Label power set multilabel classification strategy #2461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

arjoly
Copy link
Member

@arjoly arjoly commented Sep 20, 2013

Add one of the simplest and common multi-label classification strategy which use
a multi-class classifier as a base estimator.

The core code is functional, but there is still things to do:

  • Add some word about binary relevance in ovr narrative doc
  • Write narrative doc about LP
  • Add some references
  • Add some regression tests
  • "making your remark about overfitting a bit more explicit maybe?"

@arjoly
Copy link
Member Author

arjoly commented Sep 25, 2013

This pr is ready for review.

Label power set
===============

:class:`LabelPowerSetClassifier` is problem transformation method and
Copy link
Member Author

Choose a reason for hiding this comment

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

a problem ...

@glouppe
Copy link
Contributor

glouppe commented Sep 26, 2013

This is so funny, @arjoly are you reviewing your own pull request? :)

@arjoly
Copy link
Member Author

arjoly commented Sep 26, 2013

Yep ;-)

@arjoly
Copy link
Member Author

arjoly commented Sep 26, 2013

@rsivapr ENH means enhancement(s)

@rsivapr
Copy link
Contributor

rsivapr commented Sep 26, 2013

@arjoly That was quick! :) I literally deleted that post within a second when I realized it must mean that.

@arjoly
Copy link
Member Author

arjoly commented Sep 26, 2013

I received an email when you post a message on my pull request. ;-)

@arjoly
Copy link
Member Author

arjoly commented Oct 16, 2013

(ping @glouppe )

-------------------

Label power set can be used for multi-class classification, but this is
equivalent to a nop.
Copy link
Member

Choose a reason for hiding this comment

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

not sure everybody knows what you mean by nop ;)

@amueller
Copy link
Member

amueller commented Nov 4, 2013

My first question would be: does this ever work? And can we get an example of this vs OVR with one dataset where OVR works and one where this works?
Also, I think we should warn the user that this can only produce label combinations that actually exist in the trainingset (making your remark about overfitting a bit more explicit maybe?)

Otherwise this looks good, good job :)

I am not entirely happy with the testing as the real use case is only tested via a hard-coded result. I think I would like it best if the transformation would be done by hand there for a small problem and in an obvious way and compare against the estimator. But maybe that is overkill. wdyt?


The maximum number of class is bounded by the number of samples and
the number of possible label sets in the training set. This strategy
allows to take into account the correlation between the labels contrarily
Copy link
Member

Choose a reason for hiding this comment

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

"allows to" -> "may".
"contrarily to one-vs-the-rest" -> "unlike one-vs-rest".

Also, please add a warning that complexity blows out exponentially with the number of classes, restricting its use to ?<=10.

@arjoly
Copy link
Member Author

arjoly commented Dec 9, 2013

@amueller @jnothman Thanks for the review !!! I will try to find some time to work on all your comments.

@arjoly
Copy link
Member Author

arjoly commented Dec 10, 2013

My first question would be: does this ever work? And can we get an example of this vs OVR with one dataset where OVR works and one where this works?

Yes, this works. For instance on the yeast dataset, the lps meta-estimator shine on several metrics compare to ovr

{'hamming_loss': {'dummy': 0.23298021498675806,
                  'lps svm': 0.25775042841564105,
                  'ova svm': 0.23298021498675806},
 'jaccard': {'dummy': 0.33653822852296145,
             'lps svm': 0.43881512586528965,
             'ova svm': 0.33653822852296145},
 'macro-f1': {'dummy': 0.12221934801958166,
              'lps svm': 0.23575486447032259,
              'ova svm': 0.12221934801958166},
 'micro-f1': {'dummy': 0.47828362114076395,
              'lps svm': 0.56270648870093831,
              'ova svm': 0.47828362114076395},
 'samples-f1': {'dummy': 0.45689163011954953,
                'lps svm': 0.547173739867307,
                'ova svm': 0.45689163011954953},
 'subset_accuracy': {'dummy': 0.017448200654307525,
                     'lps svm': 0.14612868047982552,
                     'ova svm': 0.017448200654307525},
 'weighted-f1': {'dummy': 0.30083303670803041,
                 'lps svm': 0.43848139536413128,
                 'ova svm': 0.30083303670803041}}

Should I add the script to the examples?

@arjoly
Copy link
Member Author

arjoly commented Dec 10, 2013

I am not entirely happy with the testing as the real use case is only tested via a hard-coded result. I think I would like it best if the transformation would be done by hand there for a small problem and in an obvious way and compare against the estimator. But maybe that is overkill. wdyt?

Do you suggest to create a LabelPowerSetTransformer?

@arjoly
Copy link
Member Author

arjoly commented Dec 10, 2013

Hm strange, commons tests are failing and do not detect that this is a meta estimator.

y_coded = self.estimator.predict(X)
binary_code_size = len(self.label_binarizer_.classes_)

if binary_code_size == 2 and self.label_binarizer_:
Copy link
Member Author

Choose a reason for hiding this comment

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

FIX second condition. It needs a better tests.

Copy link
Member

Choose a reason for hiding this comment

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

What is this for, the case where it's really binary classification? I'd add a comment.

@arjoly
Copy link
Member Author

arjoly commented Jul 19, 2014

rebase on top of master

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling b5f1a9c on arjoly:labelpowerset into 0807e19 on scikit-learn:master.

@arjoly
Copy link
Member Author

arjoly commented Jul 19, 2014

@amueller and @vene Is it good for you?

@vene
Copy link
Member

vene commented Jul 19, 2014

Writeup of our discussion:

  • add a test for the zero-label class being handled correctly in predict_proba
  • marginalize to get p(label | x) (btw how would this relate with what OvR gets?

Apart from this lgtm, 👍

@arjoly
Copy link
Member Author

arjoly commented Jul 19, 2014

marginalize to get p(label | x) (btw how would this relate with what OvR gets?

There is an api discepancy for that classes.

@arjoly
Copy link
Member Author

arjoly commented Jul 19, 2014

see #2451 for more information

@vene
Copy link
Member

vene commented Jul 19, 2014

Isn't there some way of renormalizing the output of OvR to be comparable?

@arjoly
Copy link
Member Author

arjoly commented Jul 19, 2014

Isn't there some way of renormalizing the output of OvR to be comparable?

I answer to you totally off apparently. Yes, there is a way. The one we discussed today. I am working.

I need to add tests whenever some label set are missing, i.e. label set presented at fit are not the same whenver you predict.

@vene
Copy link
Member

vene commented Jul 20, 2014

LabelPowerSetClassifier doesn't have a classes_ attribute. Should it have one?

@arjoly
Copy link
Member Author

arjoly commented Jul 20, 2014

LabelPowerSetClassifier doesn't have a classes_ attribute. Should it have one?

yes, it should have one

Switch from MRG to WIP since I am progressing slowly on this.

@arjoly arjoly changed the title [MRG] Label power set multilabel classification strategy [WIP] Label power set multilabel classification strategy Jul 20, 2014
@maniteja123
Copy link
Contributor

Hi everyone, this seems to be almost in a completed state but not merged yet. Was there any reason for doing so ? I would also like to ask the same about classifier chain algorithm in #3727 and MultiOutput Bagging in #4848. I would like to complete these PRs in case no one else is currently working on these and if it is okay. Thanks !

@amueller
Copy link
Member

@maniteja123 I think you can feel free to take this over if you like, I think @arjoly is busy.

@amueller
Copy link
Member

given the lack of requests for this, I'd suggest moving this to scikit-learn-extras.

@amueller amueller added the Move to scikit-learn-extra This PR should be moved to the scikit-learn-extras repository label Jul 14, 2019
Base automatically changed from master to main January 22, 2021 10:48
@haiatn
Copy link
Contributor

haiatn commented Jul 29, 2023

given the lack of requests for this, I'd suggest moving this to scikit-learn-extras.

I agree. Should we close this and create an issue there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:utils Move to scikit-learn-extra This PR should be moved to the scikit-learn-extras repository New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.