I'am using Pipeline and GridSearchCV of scikit learn library.
I know that for example feature selection methods can be combined by FeatureUnion. In this case the results are concatenated. What I'am looking for is an or-functionality, such that grid search performs things in parallel and doesn't combine at the end.
In the (not valid) example below SelectKBest() + SVC() and VarianceThreshold() + SVC() should be executed.
pipeline = Pipeline([
[('kbest', SelectKBest()),
('variance', VarianceThreshold())],
('svm', SVC())
])
parameters = {
'kbest__k': [3, 5],
'variance__threshold': [0.1, 0.2],
'svm__C': [1],
'svm__gamma': [0.1, 0.01]
}
grid_search = GridSearchCV(pipeline, parameters)
grid_search.fit(X, y)
If yes, can the same functionality be used to have multiple estimators?