Skip to content

Incompatibility with scikit-learn model selection module #32

@nguigs

Description

@nguigs

It is currently not possible to use the scikit-learn GridSearchCV module with estimators from Parsimony because the method get_params is not compatible:

import parsimony.estimators as estimators
from sklearn.model_selection import GridSearchCV

rr = estimators.RidgeRegression(l=1.0)
param = {'ridgeregression__l': [0.2 * k for k in range(6)]}
grid_search = GridSearchCV(estimator=rr, param_grid=param, cv=5)

grid_search.fit(Xtr, ytr)

Traceback (most recent call last):

  File "<ipython-input-51-4f6ebd276276>", line 8, in <module>
    grid_search.fit(Xtr, ytr)

  File "/home/python-environments/env/lib/python2.7/site-packages/sklearn/model_selection/_search.py", line 625, in fit
    base_estimator = clone(self.estimator)

  File "/home/python-environments/env/lib/python2.7/site-packages/sklearn/base.py", line 60, in clone
    new_object_params = estimator.get_params(deep=False)

TypeError: get_params() got an unexpected keyword argument 'deep'

This could be fixed adding the parameter deep and as in scikit-learn:

https://github.com/scikit-learn/scikit-learn/blob/f0ab589f1541b1ca4570177d93fd7979613497e3/sklearn/base.py#L244-L248

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions