用sklearn的网格搜索报错
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import ShuffleSplit
from sklearn.pipeline import Pipeline
from msmbuilder.feature_selection import FeatureSelector
from msmbuilder.featurizer import DihedralFeaturizer, ContactFeaturizer
from msmbuilder.decomposition import tICA
from msmbuilder.cluster import MiniBatchKMeans
from msmbuilder.msm import MarkovStateModel
features = FeatureSelector([
('Dihedrals', DihedralFeaturizer(types=['phi', 'psi'], sincos=True)),
('Contacts', ContactFeaturizer(scheme='ca')),
])
pipeline = Pipeline([
('featurizer', features),
('tica', tICA(n_components=2)),
('cluster', MiniBatchKMeans(n_clusters=250)),
('msm', MarkovStateModel(n_timescales=3))
])
ss = ShuffleSplit(28, test_size=0.5)
cv = GridSearchCV(pipeline, cv=ss, param_grid= {
'featurizer__which_feat': features.feat_list,
'tica__lag_time': [1, 4, 16, 64],
})
cv.fit(trajs)
RuntimeError Traceback (most recent call last)
12-7f343219fa0f> in ()
24 'tica__lag_time': [1, 4, 16, 64],
25 })
---> 26 cv.fit(trajs)
~/miniconda3/envs/msmb1/lib/python3.5/site-packages/sklearn/model_selection/_search.py in fit(self, X, y, groups, **fit_params)
675 n_splits = cv.get_n_splits(X, y, groups)
676
--> 677 base_estimator = clone(self.estimator)
678
679 parallel = Parallel(n_jobs=self.n_jobs, verbose=self.verbose,
~/miniconda3/envs/msmb1/lib/python3.5/site-packages/sklearn/base.py in clone(estimator, safe)
60 new_object_params = estimator.get_params(deep=False)
61 for name, param in six.iteritems(new_object_params):
---> 62 new_object_params[name] = clone(param, safe=False)
63 new_object = klass(**new_object_params)
64 params_set = new_object.get_params(deep=False)
~/miniconda3/envs/msmb1/lib/python3.5/site-packages/sklearn/base.py in clone(estimator, safe)
48 # XXX: not handling dictionaries
49 if estimator_type in (list, tuple, set, frozenset):
---> 50 return estimator_type([clone(e, safe=safe) for e in estimator])
51 elif not hasattr(estimator, 'get_params'):
52 if not safe:
~/miniconda3/envs/msmb1/lib/python3.5/site-packages/sklearn/base.py in (.0)
48 # XXX: not handling dictionaries
49 if estimator_type in (list, tuple, set, frozenset):
---> 50 return estimator_type([clone(e, safe=safe) for e in estimator])
51 elif not hasattr(estimator, 'get_params'):
52 if not safe:
~/miniconda3/envs/msmb1/lib/python3.5/site-packages/sklearn/base.py in clone(estimator, safe)
48 # XXX: not handling dictionaries
49 if estimator_type in (list, tuple, set, frozenset):
---> 50 return estimator_type([clone(e, safe=safe) for e in estimator])
51 elif not hasattr(estimator, 'get_params'):
52 if not safe:
~/miniconda3/envs/msmb1/lib/python3.5/site-packages/sklearn/base.py in (.0)
48 # XXX: not handling dictionaries
49 if estimator_type in (list, tuple, set, frozenset):
---> 50 return estimator_type([clone(e, safe=safe) for e in estimator])
51 elif not hasattr(estimator, 'get_params'):
52 if not safe:
~/miniconda3/envs/msmb1/lib/python3.5/site-packages/sklearn/base.py in clone(estimator, safe)
71 raise RuntimeError('Cannot clone object %s, as the constructor '
72 'either does not set or modifies parameter %s' %
---> 73 (estimator, name))
74 return new_object
75
RuntimeError: Cannot clone object FeatureSelector(features=OrderedDict([('Dihedrals', DihedralFeaturizer(sincos=True, types=['phi', 'psi'])), ('Contacts', ContactFeaturizer(contacts='all', ignore_nonprotein=True, scheme='ca',
soft_min=False, soft_min_beta=20))]),
which_feat=['Dihedrals', 'Contacts']), as the constructor either does not set or modifies parameter features
请问为什么呢,应该怎么解决呢