Skip to content Skip to sidebar Skip to footer

Sklearn Pipeline: Argument Of Type 'columntransformer' Is Not Iterable

I am attempting to use a pipeline to feed an ensemble voting classifier as I want the ensemble learner to use models that train on different feature sets. For this purpose, I follo

Solution 1:

The estimators parameter of VotingClassifier should be a list of pairs (name, estimator), so e.g.

ens = VotingClassifier(estimators=[('phy', pipe_phy),
                                   ('fa', pipe_fa)])

(In your code, the check is trying to find the second element of the pair, hence the complaint that ColumnTransformer is not iterable.)

Solution 2:

I did manage to get the code to run using a workaround, which is bit ugly.

It seems like that the library is attempting to search for '__' substring of the ColumnTransform object, which it is unable to perform.

Since this name check doesn't have a significant effect on my functionality, I commented the following snippet at sklearn\utils\metaestimators.py.

invalid_names = [name for name in names if'__'in name]
if invalid_names:
    raise ValueError('Estimator names must not contain __: got ''{0!r}'.format(invalid_names))

Post a Comment for "Sklearn Pipeline: Argument Of Type 'columntransformer' Is Not Iterable"