Skip to content

How can I use MimicExplainer with Voting Classifier? [Question] #544

Description

@RNakamura90

I'm building a Voting Ensemble Classifier model with transformation pipelines.

pipe_xgbc = Pipeline(steps=[
    ('transformer', variable_transformer),
    ('classifier', clf1)])

pipe_lgbc = Pipeline(steps=[
    ('transformer', variable_transformer),
    ('classifier', clf2)])

pipe_rf = Pipeline(steps=[
    ('transformer', variable_transformer),
    ('classifier', clf3)])

classifiers = [
    ('xgbc', pipe_xgbc),
    ('lgbc', pipe_lgbc),
    ('rf', pipe_rf)
]

voting = VotingClassifier(classifiers,
                        voting='soft',
                        weights=[1, 1, 1])

fited_soft_voting = voting.fit(X_train, y_train)

But when I try to use the MimicExplainer function with an LGBM surrogate model, I get the following error:


explainer = MimicExplainer(fited_soft_voting[-1][1],
                            X_train,
                            LGBMExplainableModel,
                            augment_data=True,
                            max_num_of_augmentations=10,
                            features=X_train.columns,
                            transformations=variable_transformer.transformers,
                            allow_all_transformations=True                  
)

---------------------------------------------------------------------------
TypeError: 'VotingClassifier' object is not subscriptable

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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