Skip to content

[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

Closed
wants to merge 1 commit into from

Conversation

SebastinSanty
Copy link
Contributor

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.

Copy link
Member

@jnothman jnothman left a 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)
Copy link
Member

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)
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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.

@SebastinSanty
Copy link
Contributor Author

I'll cover with tests too.

Base automatically changed from master to main January 22, 2021 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chain on decision_function or predict_proba in ClassifierChain
4 participants