8000 [MRG] Example for multioutput.RegressorChain by timnon · Pull Request #15215 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG] Example for multioutput.RegressorChain #15215

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sklearn/multioutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,18 @@ class RegressorChain(MetaEstimatorMixin, RegressorMixin, _BaseChain):
order_ : list
The order of labels in the classifier chain.

Examples
--------
>>> from sklearn.multioutput import RegressorChain
>>> from sklearn.linear_model import LogisticRegression
>>> logreg = LogisticRegression(solver='lbfgs',multi_class='multinomial')
>>> X, Y = [[1,0],[0,1],[1,1]], [[0,2],[1,1],[2,0]]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>>> X, Y = [[1,0],[0,1],[1,1]], [[0,2],[1,1],[2,0]]
>>> X, Y = [[1, 0], [0, 1], [1, 1]], [[0, 2], [1, 1], [2, 0]]

>>> chain = RegressorChain(base_estimator=logreg,order=[0,1]).fit(X,Y)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>>> chain = RegressorChain(base_estimator=logreg,order=[0,1]).fit(X,Y)
>>> chain = RegressorChain(base_estimator=logreg, order=[0, 1]).fit(X, Y)

Copy link
Contributor

Choose a reason for hiding this comment

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

@adrinjalali no, I don't think so

>>> chain.predict(X)
array([[0., 2.],
[1., 1.],
[2., 0.]])

See also
--------
ClassifierChain: Equivalent for classification
Expand Down
0