Repository navigation
API/REF: Clone before fitting in Incremental.fit - #258
Conversation
This changes Incremental.fit to clone before fitting. Alternative to dask#207
|
cc @stsievert |
|
|
||
| assert isinstance(result.estimator.coef_, np.ndarray) | ||
| np.testing.assert_array_almost_equal(result.estimator.coef_, | ||
| assert isinstance(result.estimator_.coef_, np.ndarray) |
There was a problem hiding this comment.
This is the API change.
| assert callable(check_scoring(clf, scoring=scoring)) | ||
| clf.fit(X, y, classes=np.unique(y)) | ||
| clf.score(X, y) | ||
| clf.estimator.score(X, y) |
There was a problem hiding this comment.
I don't think this was doing what we wanted earlier.
When Incremental is created with scoring, clf.score(X, y) will in general be different then clf.estimator_.score(X, y). The latter always uses the "default" scoring for that estimator (e.g. accuracy score). I opted to just remove this line.
| def test_fit_ndarrays(): | ||
| X = np.ones((10, 5)) | ||
| y = np.ones(10) | ||
| y = np.concatenate([np.zeros(5), np.ones(5)]) |
There was a problem hiding this comment.
Needed a mix of zeros and ones. I'm not entirely sure what changed to necessitate that...
|
|
||
| inc.partial_fit(X, y, classes=[0, 1]) | ||
| inc.fit(X, y) | ||
| inc.fit(X, y, classes=[0, 1]) |
There was a problem hiding this comment.
need this, as classes_ no longer leasks through the partial_fit to the fit (a good thing!)
|
I think if we implement For more complete thoughts on the API, see #207 (comment) |
|
Agreed that having a The solution is to probably to have See https://stackoverflow.com/a/35534452/1889400 for how So either inc = Incremental(SGDClassifier(), name='sgdclassifier')
inc = Incremental(('sgdclassifier', SGDClassifier())In the latter case, we would have a Then in a context where you need to get / set params, it'd be param_grid = {
'sgdclassifier__alpha': [0.1, 10.0],
'sgdclassifier__max_iter': [1000, 2000],
'max_iter': [1, 5],
}
clf = GridSearchCV(inc, param_grid) |
|
Looks like https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/metaestimators.py has some utilities for get / set params in a meta-estimator, though most are private. |
|
55fccf2 has the changes. Turns out BaseEstimator already does the right thing, we don't have to mess with I'm encouraged by the lines of code we could delete from For now, I haven't made the name configurable. If you want to set the parameters for the underlying estimator, then you use |
|
I'll implement @stsievert, do you have a feeling for what a good default would be? I'm leaning towards |
|
What does Scikit-Learn do in situations like these? Do they have some sort
of convergence criterion that they check? Perhaps we can do the same?
…On Mon, Jul 2, 2018 at 2:45 PM, Tom Augspurger ***@***.***> wrote:
I'll implement max_iter now.
@stsievert <https://github.com/stsievert>, do you have a feeling for what
a good default would be? I'm leaning towards max_iter=1, but am not sure.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#258 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszCZqzB6rYrroevjEP51dcPAYdRYhks5uCmpVgaJpZM4U_ZrG>
.
|
|
It varies from model to model. scikit-learn/scikit-learn#1626 is the general API that we would want to follow here, when that is implemented. |
|
A basic version of |
|
I'm finding this diff somewhat difficult to digest. I'm going to split off the |
|
OK I think this PR should be good. I feel happy about deleting https://github.com/dask/dask-ml/pull/258/files#diff-eaec819577a74de3b3af2ece0ac4dce9L353, and should have noticed that needing those in the first place was a code smell. Postponing discussion of |
|
I'm on board with this now. I think
I think I would default to This should depend on model complexity but I'm okay leaving that. e.g., fitting a linear model with twice as many features will require about |
This changes Incremental.fit to clone before fitting.
Alternative to #207
This implements the ideas from #207 (comment)