-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] ENH add support for multiclass-multioutput to ClassifierChain #14654
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
[MRG] ENH add support for multiclass-multioutput to ClassifierChain #14654
Conversation
@jnothman @glemaitre @amueller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are failing @agamemnonc. Let us know if we can assist. |
Thanks @jnothman. I think I might actually need some help here as I am not really sure why tests are failing and the reports seem a bit obscure to me. I have run tests locally us, which pass, so I am not really sure what the issue is? Thanks again! |
@jnothman can you please have a look again? Any suggestions on how to keep code coverage above the required threshold also welcome! |
Hi @agamemnonc, are you still interested in finalizing this PR? If yes, could you please resolve the conflicts with master? I've checked the codecov report and couldn't find any problem related to your changes, a sync will clarify if there is still work to do in testing. Thanks for your patience! |
Sure, I can do this when I find some time -- hopefully next week. |
@cmarmo Conflicts with main have now been resolved (apologies for the delay in doing so), so this is now ready to merge as far as I am concerned. You can remove the "stalled" label if you wish. @thomasjpfan @glemaitre pinging you again to have another look as there has been an update on the docstring example. |
Hi @agamemnonc , thanks for your work! Version 0.24 has been released before Christmas, could you please put the changelog entry in v1.0.rst? Thanks! |
@cmarmo thanks for looking at this. Please note that this PR breaks backward compatibility ( |
I have a couple of questions regarding supporting this use case indeed. It would be nice to have some insights if anyone has some. By adding support to multioutput, I have the impression that we don't solve the same problem as stated in the documentation, we create a link between the output and not between class labels (I also commented there: #19853 (comment)). But this is not really clear to me what this involves (I never played with these classification problems). If there are differences, we should change the documentation as well.
I think that we should be able to be back-compatible. We could detect beforehand which type of target we have and we can output a |
@glemaitre am not sure I am exactly following your points, but this is likely due to confusion regarding the terminology. To avoid any further confusion, I will follow here the convention outlined in our user guide, that is, multi-output classification problems with binary outputs --> "multilabel" and multi-output problems with number of classes > 2 --> "multi-class multioutput" or simply "multioutput".
In multi-output problems (either multi-label or multi-class multi-output), Classifier Chains indeed create links between the outputs (binary or multi-class, respectively). For example you predict the second output by adding the first output in the feature space. I am afraid I am not sure what you mean by links between "class labels" in this case? You are right in that in the original paper Classifier Chains were proposed for multi-label (binary) problems. However this needs not be restrictive, and indeed it is straightforward to extend them to multi-class multi-output. Personally, I think it would be great to support this case too -- in my own research, I have come across multi-class multi-output classification problems where there is structure between the outputs, and in such cases Classifier Chains came in handy. If we decide to provide such support, I would think that
I think what you are suggesting is indeed feasible, however I just wanted to double-check that in the multi-label case the output should be Happy to further work on this PR once a consensus has been reached regarding whether multi-class multi-output should be supported for |
You are right and I think that we are going to the rabbit hole: #2451. However, we should need to have some deprecation. I will start to write some common tests to check what are the current status in scikit-learn. My proposal will be to implement the multiclass-multioutput as you propose and keep the array format for multilabel-indicator. A separate PR should take care to introduce a common test to check the consistency of the array format. |
I just had another thought regarding the support of multi-class multi-output for |
My bad, I confused multilabel and one-hot encoded multiclass (multilabel with a single 1 per line). So the extension seems correct. |
Yes this is right. In this case, we might want to have a keyword specifying the encoding strategy; for instance |
Has this lagged behind |
this would be very useful, I would be happy to pitch in effort! |
@creatorrr Please go ahead and take this forward, I am afraid I do not currently have time to commit to this |
Hello, happy to contribute if needed. From what I've read it is still needed since #9245, #13338, #13339 are open? @agamemnonc |
@WestedCrean please feel free to pick it up. I submitted a PR a couple of times but review was either delayed or not made, unfortunately I don't have time to spend on this atm |
Closing as needs a new PR. |
Reference Issues/PRs
Fixes #9245
Fixes #13338
Fixes #13339
What does this implement/fix? Explain your changes.
predict_proba
anddecision_function
ofClassifierChain
retuns now a list ofn_outputs
arrays, each of shape(n_samples, n_classes)
. This format is consistent with that ofMultiOutputClassifier
.Any other comments?
multiouput_only
tag has now been removed. I wonder whether we should keep the_skip_test
tag. Tests pass even when this tag is removed.This change will break backward compatibility, since the functions previously returned arrays rather than lists. Any ideas on how to handle this?