-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[WIP] Chain on decision_function or predict_proba in ClassifierChain #9316
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
Conversation
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.
We should probably also support predict_log_proba. Or we could find a way to support an arbitrary method.
This needs a test which at a minimum, runs the code with different settings, checks the learnt models differs as a result, and perhaps that the coef_ shape corresponds to the choice.
if self.chain_method == "predict": | ||
Y_pred_chain[:, chain_idx] = estimator.predict(X_aug) | ||
elif self.chain_method == "predict_proba": | ||
Y_pred_chain[:, chain_idx] = estimator.predict_proba(X_aug) |
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.
The output of these methods may be a different shape, more than a single column.
if self.chain_method == "predict": | ||
Y_pred_chain[:, chain_idx] = estimator.predict(X_aug) | ||
elif self.chain_method == "predict_proba": | ||
Y_pred_chain[:, chain_idx] = estimator.predict_proba(X_aug) |
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.
Predict_proba returns a 2d array
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.
Needs to be done in fit too
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.
Yes, predict_proba
returns a 2d array, and I had mentioned this in the issue comment. This was just a mock implementation, to know whether I was going on the right path.
I'll cover with tests too. |
Reference Issue
Fixes #9247
What does this implement/fix? Explain your changes.
ClassifierChain uses the prediction from the classifier for each label as a feature for the next label's classifier. This change will enable users to select a method to chain on, one of { predict, predict_proba, decision_function }. The default being categorical prediction.
Any other comments?
No.