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

Skip to content

Conversation

@agamemnonc
Copy link
Contributor

Reference Issues/PRs

Fixes #14615.

What does this implement/fix? Explain your changes.

MultiOutputClassifier class now has attribute classes_ (same as ClassifierChain)

Any other comments?

@agamemnonc
Copy link
Contributor Author

Shall we include a non-regression test checking the classes_ of a fitted MultiOutputClassifier?

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.

Please do extend a test to check this.

@agamemnonc
Copy link
Contributor Author

Please do extend a test to check this.

OK done.

Please let me know if anything else is needed. Otherwise please review and change PR title accordingly.

@agamemnonc agamemnonc changed the title Multioutput classes fix MultiOutputClassifier classes_ attribute fix Aug 12, 2019
@agamemnonc agamemnonc changed the title MultiOutputClassifier classes_ attribute fix MultiOutputClassifier classes_ attribute Aug 12, 2019
@agamemnonc
Copy link
Contributor Author

On a side note, the dataset used in most of the tests is created globally, would it not be better practice to have that wrapped in a function definition, then call that function from within all tests that use the particular dataset?

# Import the data
iris = datasets.load_iris()
# create a multiple targets by randomized shuffling and concatenating y.
X = iris.data
y1 = iris.target
y2 = shuffle(y1, random_state=1)
y3 = shuffle(y1, random_state=2)
y = np.column_stack((y1, y2, y3))
n_samples, n_features = X.shape
n_outputs = y.shape[1]
n_classes = len(np.unique(y1))
classes = list(map(np.unique, (y1, y2, y3)))

@glemaitre
Copy link
Member

On a side note, the dataset used in most of the tests is created globally, would it not be better practice to have that wrapped in a function definition, then call that function from within all tests that use the particular dataset?

We could use the pytest.fixture instead. But I would say that this is out of the scope for this PR. We might need to have something consistent across the source code then such that this is easy to know where the fixtures are defined etc. However, this is a good remark

@agamemnonc
Copy link
Contributor Author

On a side note, the dataset used in most of the tests is created globally, would it not be better practice to have that wrapped in a function definition, then call that function from within all tests that use the particular dataset?

We could use the pytest.fixture instead. But I would say that this is out of the scope for this PR. We might need to have something consistent across the source code then such that this is easy to know where the fixtures are defined etc. However, this is a good remark

Agreed. Feel free to open a separate issue then if you wish.

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

Couple of comments but it looks good

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Nit but LGTM, thanks @agamemnonc

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM

@glemaitre
Copy link
Member

Could you also merge master into your branch such that we check that the CI for the doc is passing.
It seems just an issue that we earlier fixed

@agamemnonc
Copy link
Contributor Author

Thanks @glemaitre @NicolasHug and @jnothman for feedback.

I think this is now ready.

@agamemnonc agamemnonc changed the title MultiOutputClassifier classes_ attribute [MRG+2] MultiOutputClassifier classes_ attribute Aug 14, 2019
@glemaitre glemaitre merged commit 06dc44c into scikit-learn:master Aug 14, 2019
@glemaitre
Copy link
Member

@agamemnonc Thanks for your contribution

@agamemnonc agamemnonc deleted the multioutput_classes_fix branch August 14, 2019 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError with cross_val_predict(method='predict_proba') when using MultiOuputClassifier

4 participants