Skip to content

[MRG+2] Minimize the validation of X in adaboost - #13174

Merged
jnothman merged 25 commits into
scikit-learn:masterfrom
chkoar:minimize_validation_in_meta_estimators
Feb 28, 2019
Merged

jnothman merged 25 commits into
scikit-learn:masterfrom
chkoar:minimize_validation_in_meta_estimators

Conversation

@chkoar

@chkoar chkoar commented Feb 15, 2019

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #7768. Takes over #8304.

What does this implement/fix? Explain your changes.

This PR (almost) transfers the responsibility of the validation of X and y from AdaBoost to the base estimator.

Any other comments?

I retained all the tests. If we want to relax the check about sparsity we should remove the test_sparse_classification and test_sparse_regression tests.

@jnothman jnothman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks nice

Please add an entry to the change log at doc/whats_new/v0.21.rst. Like the other entries there, please reference this pull request with :issue: and credit yourself (and other contributors if applicable) with :user:

Comment thread sklearn/ensemble/weight_boosting.py Resolved
Comment thread sklearn/ensemble/weight_boosting.py Resolved
Comment thread sklearn/ensemble/weight_boosting.py Resolved

boost = AdaBoostRegressor(DummyEstimator(), n_estimators=3)
boost.fit(X, y_regr)
assert_equal(len(boost.estimator_weights_), len(boost.estimator_errors_))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With the adoption of pytest, we are phasing out use of test helpers assert_equal, assert_true, etc. Please use bare assert statements, e.g. assert x == y, assert not x, etc.

@chkoar chkoar Feb 18, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did not touch that test. It seems that I did because I removed and then readd the test_sparse_classification and test_sparse_regression tests. Do you want me to fix that even it is unrelated to the PR?

@NicolasHug NicolasHug left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

some comments

@chkoar

chkoar commented Feb 18, 2019

Copy link
Copy Markdown
Contributor Author

@jnothman @NicolasHug do you think that we should retain the test_sparse_classification and test_sparse_regression tests?

@jnothman jnothman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand. Why should we not retain those tests?

@chkoar

chkoar commented Feb 18, 2019 •

Copy link
Copy Markdown
Contributor Author

I don't understand. Why should we not retain those tests?

@jnothman in the process of the minimization of the validation I was thinking that these checks/tests should be in the responsibility of the base estimator. That's why I am asking.

@chkoar
chkoar force-pushed the minimize_validation_in_meta_estimators branch from 88cebc6 to 2e9a045 Compare February 21, 2019 17:35
@chkoar

chkoar commented Feb 21, 2019

Copy link
Copy Markdown
Contributor Author

@jnothman _num_samples might be unnecessary since we use check_array and check_X_y

Comment thread sklearn/ensemble/weight_boosting.py Resolved
Comment thread sklearn/ensemble/weight_boosting.py Resolved

@jnothman jnothman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Otherwise LGTM

Comment thread doc/whats_new/v0.21.rst Outdated
:issue:`6463` by :user:`movelikeriver <movelikeriver>`.

- |Enhancement| Minimized the validation of X in :class:`ensemble.AdaBoostClassifier`
and :class:`ensemble.AdaBoostRegressor` :issue:`13174` by :user:`Christos Aridas <chkoar>`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please keep lines under 80 characters


def _validate_data(self, X, y=None):

accept_sparse = ['csr', 'csc']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It took me a while to understand why we don't just accept_sparse=True. Maybe add a comment that these are required for safe_indexing support???

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

test_sparse_regression and test_sparse_classification check that sparse matrices will be converted in one of the two formats. Check here for instance. We could minimize more the validation by turn of these assertions and use accept_sparse=True but safe_indexing does not support all sparse matrices. What do you propose?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What @jnothman is asking for is simply a comment on the line above saying that these are required for safe_indexing support.

@agramfort agramfort changed the title Minimize the validation of X in adaboost [MRG+1] Minimize the validation of X in adaboost Feb 27, 2019

@GaelVaroquaux GaelVaroquaux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, but the comment by @jnothman should be addressed (it's just a question of adding a comment line)


def _validate_data(self, X, y=None):

accept_sparse = ['csr', 'csc']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What @jnothman is asking for is simply a comment on the line above saying that these are required for safe_indexing support.

@GaelVaroquaux GaelVaroquaux changed the title [MRG+1] Minimize the validation of X in adaboost [MRG+2] Minimize the validation of X in adaboost Feb 27, 2019
@glemaitre

Copy link
Copy Markdown
Member

Some PEP8 I think

@chkoar

chkoar commented Feb 27, 2019 •

Copy link
Copy Markdown
Contributor Author

@glemaitre good catch. I think it is ok.

@jnothman
jnothman merged commit 9d21197 into scikit-learn:master Feb 28, 2019
@jnothman

Copy link
Copy Markdown
Member

Thanks @chkoar!

xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
davidgegiya added a commit to davidgegiya/agent-orchestrator that referenced this pull request Nov 9, 2026
… base estimator

Pin 09bc27630fb8feea2f10627dce25e93cd6ff258a and its regression selectors for reproducible runs.

Source: scikit-learn/scikit-learn#13174
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.

Minimize validation of X in ensembles with a base estimator

6 participants