Skip to content

[RFC][MRG] ENH EstimatorCVMixin class #7305

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

raghavrv
Copy link
Member

@raghavrv raghavrv commented Aug 31, 2016

Adds a new EstimatorCVMixin to be used for all Estimators with CV search of hyper params.

This mixin will provision enabling the predict methods of the best_estimator_ available to the inheriting class.

@jnothman @amueller @agramfort (Up for discussion after the release of 0.18)

@raghavrv raghavrv force-pushed the estimator_cv_mixin branch from 4fada2b to df0faa1 Compare August 31, 2016 14:25
@jnothman
Copy link
Member

But most specialised CV implementations (LogisticRegressionCV, ElasticNetCV, ...) don't have estimator..?

At this point, I don't see us gaining much from such a refactoring.

@jnothman
Copy link
Member

No, you can't share ducktyping delegation so easily, nor docstrings.

@raghavrv
Copy link
Member Author

But most specialised CV implementations (LogisticRegressionCV, ElasticNetCV, ...) don't have estimator..?

I was thinking we could add one to unify the interface of EstimatorCV... (As we also would like to have cv_results_ in them)?

@amueller
Copy link
Member

@raghavrv can you maybe focus on things that are release relevant for this week and the next? That would be very helpful. Thanks :)

@raghavrv
Copy link
Member Author

Yes ofcourse! This PR was started just as I mentioned here and as I noted at the PR description... For discussion after release of 0.18 not for now... ;)

@raghavrv
Copy link
Member Author

BTW @amueller just to clarify everything currently tagged with 0.18 is release critical correct? Or are there false positives in tagging?

@amueller
Copy link
Member

there might be false positives ;)

@amueller
Copy link
Member

and false negatives

@raghavrv
Copy link
Member Author

raghavrv commented Oct 16, 2016

@jnothman @amueller Could we revisit this now?

@amueller And responding to your earlier question in the other PR

would the new base-class also be used in other CV objects?

Currently only BaseSearchCV and in the near future GradientBoostingCV can use this... If this proposal goes well, BaseForestCV would also use it...

How much negative lines does that yield?

Right now since this just refactors the Mixin class out of GridSearchCV into base.py, this adds 30 lines, but with GradientBoostingCV reusing it, it could save about 100 lines of redundant code...

Additionally we can use this to design our validation API?

@jmschrei
Copy link
Member

I'm not too familiar with this part of the code. What is the explicit benefit of this change?

@amueller amueller added this to the 0.19 milestone Oct 17, 2016
@amueller
Copy link
Member

@raghavrv I want to get out 0.18.1 first ;)
Also: why wouldn't the other existing CV estimators use it? What's different about them compared to the Random Forest and Gradient Boosting?

@raghavrv
Copy link
Member Author

@raghavrv I want to get out 0.18.1 first ;)

Deja vu ;) But yes I'm working on it. :)

@jnothman
Copy link
Member

Please, @raghavrv, can you add to the description precisely what you propose to be shared/provided by this mixin?

@raghavrv
Copy link
Member Author

raghavrv commented Oct 25, 2016

Also: why wouldn't the other existing CV estimators use it? What's different about them compared to the Random Forest and Gradient Boosting?

For instance LogisticRegressionCV does not use best_estimator_ nor does it need predict as it inherits from LogisticRegression. (Maybe we should do the same for GradientBoostingCV too instead of having this mixin?)

can you add to the description precisely what you propose to be shared/provided by this mixin?

When I opened this I thought it would be nice to refactor the predict.* functions (with if_delegate_has_method decorators) from GridSearchCV and BaseGradientBoostingCV into a separate mixin (EstimatorCVMixin).

Now after Andy brought up the question of a separate validation set instead of cross-validation.

I thought maybe we could use this mixin to specify a new method for passing the validation set explicitly...

def validated_fit(X_train, y_train, X_validate, y_validate):
    X_all = np.vstack(X_train, X_validate)
    y_all = np.vstack(y_train, y_validate)
    test_folds = np.hstack((np.zeros(X_train.shape[0]), np.ones(X_test.shape[0]))))
    self.cv = PredefinedSplit(test_folds)
    return self.fit(X_all, y_all)

(Not sure how sensible that train of thought was...)

@jnothman
Copy link
Member

I am -1 for adding new methods. And I don't think there's enough shared
between *CV to benefit from sharing the delegated methods.

On 26 October 2016 at 00:01, Raghav RV notifications@github.com wrote:

Also: why wouldn't the other existing CV estimators use it? What's
different about them compared to the Random Forest and Gradient Boosting?

For instance LogisticRegressionCV does not use best_estimator_ nor does
it need predict as it inherits from LogisticRegression. (Maybe we should
do the same for GradientBoostingCV too instead of having this mixin?)

can you add to the description precisely what you propose to be
shared/provided by this mixin?

When I opened this I thought it would be nice to refactor the predict.*
functions (with if_delegate_has_method decorators) from GridSearchCV and
BaseGradientBoostingCV
#7071 into a separate
mixin (EstimatorCVMixin).

Now after Andy brought up the question of a separate validation set
instead of cross-validation.

I thought maybe we could use this mixin to specify an abstract method

def validated_fit(X_train, y_train, X_validate, y_validate):
X_all = np.vstack(X_train, X_validate)
y_all = np.vstack(y_train, y_validate)
test_folds = np.hstack((np.zeros(X_train.shape[0]), np.ones(X_test.shape[0]))))
self.cv = PredefinedSplit(test_folds)
return self.fit(X_all, y_all)

(Not sure how sensible that train of thought was...)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7305 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEz68byP2WgQHKMjaGBxhA-qwdFgfLUks5q3f2QgaJpZM4Jxq9Z
.

@raghavrv
Copy link
Member Author

Thanks for the comment :) I'll leave this closed and try to subclass from GradientBoosting for that PR...

@raghavrv raghavrv closed this Oct 25, 2016
@raghavrv raghavrv deleted the estimator_cv_mixin branch October 25, 2016 18:30
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.

4 participants