interpretml / interpret-community

Interpret Community extends Interpret repository with additional interpretability techniques and utility functions to handle real-world datasets and workflows.
https://interpret-community.readthedocs.io/en/latest/index.html
MIT License
422 stars 85 forks source link

Unable to run "explain_global" for a Tabular Explainer #369

Closed salva-02 closed 3 years ago

salva-02 commented 3 years ago

I'm trying to create explainable dashboards in Azure using azureml_interpret.

I have a dataset split into train and test(Multi class classification problem). A new ML model has been created on the train data.

Im trying to explain predictions on my local machine for the test data.

But I get the below error.

in ----> 1 global_explanation = explainer.explain_global(X_train[:5]) ~\.conda\envs\azure_env\lib\site-packages\interpret_community\dataset\decorator.py in explain_func_wrapper(self, evaluation_examples, *args, **kwargs) 20 self._logger.debug('Eval examples not wrapped, wrapping') 21 evaluation_examples = DatasetWrapper(evaluation_examples) ---> 22 return explain_func(self, evaluation_examples, *args, **kwargs) 23 return explain_func_wrapper 24 ~\.conda\envs\azure_env\lib\site-packages\interpret_community\tabular_explainer.py in explain_global(self, evaluation_examples, sampling_policy, include_local, batch_size) 219 ExplainParams.INCLUDE_LOCAL: include_local, 220 ExplainParams.BATCH_SIZE: batch_size} --> 221 return self.explainer.explain_global(evaluation_examples, **kwargs) 222 223 @tabular_decorator ~\.conda\envs\azure_env\lib\site-packages\interpret_community\dataset\decorator.py in explain_func_wrapper(self, evaluation_examples, *args, **kwargs) 20 self._logger.debug('Eval examples not wrapped, wrapping') 21 evaluation_examples = DatasetWrapper(evaluation_examples) ---> 22 return explain_func(self, evaluation_examples, *args, **kwargs) 23 return explain_func_wrapper 24 ~\.conda\envs\azure_env\lib\site-packages\interpret_community\shap\kernel_explainer.py in explain_global(self, evaluation_examples, sampling_policy, include_local, batch_size) 268 kwargs[ExplainParams.NUM_FEATURES] = evaluation_examples.num_features 269 --> 270 return self._explain_global(evaluation_examples, **kwargs) 271 272 def _get_explain_local_kwargs(self, evaluation_examples): ~\.conda\envs\azure_env\lib\site-packages\interpret_community\common\aggregate.py in _explain_global(self, evaluation_examples, sampling_policy, include_local, batch_size, **kwargs) 74 if include_local: 75 kwargs = self._get_explain_global_agg_kwargs(evaluation_examples, sampling_policy=sampling_policy, ---> 76 **kwargs) 77 # Aggregate local explanation to global 78 return _aggregate_global_from_local_explanation(**kwargs) ~\.conda\envs\azure_env\lib\site-packages\interpret_community\common\aggregate.py in _get_explain_global_agg_kwargs(self, evaluation_examples, sampling_policy, **kwargs) 48 kwargs[ExplainParams.CLASSES] = self.classes 49 # first get local explanation ---> 50 local_explanation = self.explain_local(evaluation_examples) 51 kwargs[ExplainParams.LOCAL_EXPLANATION] = local_explanation 52 return kwargs ~\.conda\envs\azure_env\lib\site-packages\interpret_community\dataset\decorator.py in explain_func_wrapper(self, evaluation_examples, *args, **kwargs) 20 self._logger.debug('Eval examples not wrapped, wrapping') 21 evaluation_examples = DatasetWrapper(evaluation_examples) ---> 22 return explain_func(self, evaluation_examples, *args, **kwargs) 23 return explain_func_wrapper 24 ~\.conda\envs\azure_env\lib\site-packages\interpret_community\shap\kernel_explainer.py in explain_local(self, evaluation_examples) 365 """ 366 kwargs = self._get_explain_local_kwargs(evaluation_examples) --> 367 explanation = _create_local_explanation(**kwargs) 368 369 if self._datamapper is None: ~\.conda\envs\azure_env\lib\site-packages\interpret_community\explanation\explanation.py in _create_local_explanation(expected_values, classification, explanation_id, init_data, eval_data, eval_ys_predicted, eval_ys_predicted_proba, model_id, **kwargs) 1355 kwargs[ExplainParams.MODEL_ID] = model_id 1356 DynamicLocalExplanation = type(Dynamic.LOCAL_EXPLANATION, tuple(mixins), {}) -> 1357 local_explanation = DynamicLocalExplanation(explanation_id=exp_id, **kwargs) 1358 return local_explanation 1359 ~\.conda\envs\azure_env\lib\site-packages\interpret_community\explanation\explanation.py in __init__(self, local_importance_values, **kwargs) 331 :type local_importance_values: numpy.array or scipy.sparse.csr_matrix or list[scipy.sparse.csr_matrix] 332 """ --> 333 super(LocalExplanation, self).__init__(**kwargs) 334 self._logger.debug('Initializing LocalExplanation') 335 self._local_importance_values = local_importance_values ~\.conda\envs\azure_env\lib\site-packages\interpret_community\explanation\explanation.py in __init__(self, features, num_features, is_raw, is_engineered, **kwargs) 247 :type is_engineered: bool 248 """ --> 249 super(FeatureImportanceExplanation, self).__init__(**kwargs) 250 self._logger.debug('Initializing FeatureImportanceExplanation') 251 self._features = features ~\.conda\envs\azure_env\lib\site-packages\interpret_community\explanation\explanation.py in __init__(self, method, model_task, model_type, explanation_id, **kwargs) 57 :type explanation_id: str 58 """ ---> 59 super(BaseExplanation, self).__init__(**kwargs) 60 self._logger.debug('Initializing BaseExplanation') 61 self._method = method ~\.conda\envs\azure_env\lib\site-packages\interpret_community\common\chained_identity.py in __init__(self, **kwargs) 15 self._logger = logging.getLogger("interpret_community").getChild(self.__class__.__name__) 16 self._identity = self.__class__.__name__ ---> 17 super(ChainedIdentity, self).__init__(**kwargs) ~\.conda\envs\azure_env\lib\site-packages\interpret_community\explanation\explanation.py in __init__(self, expected_values, **kwargs) 845 :type expected_values: np.array 846 """ --> 847 super(ExpectedValuesMixin, self).__init__(**kwargs) 848 self._expected_values = expected_values 849 ~\.conda\envs\azure_env\lib\site-packages\interpret_community\explanation\explanation.py in __init__(self, init_data, eval_data, eval_y_predicted, eval_y_predicted_proba, **kwargs) 1176 :type eval_y_predicted_proba: np.array or str 1177 """ -> 1178 super(_DatasetsMixin, self).__init__(**kwargs) 1179 self._init_data = init_data 1180 self._eval_data = eval_data TypeError: object.__init__() takes exactly one argument (the instance to initialize) **To Reproduce** Steps to reproduce the behavior: 1. I have used Azureml_interpret version 1.15.0 and also the latest version 1.21.0. oth the versions are throwing the same error
gaugup commented 3 years ago

@salva-02 what version of interpret-community are you using? Do you mind sharing the notebook and dataset?

Regards

gaugup commented 3 years ago

@salva-02 are you unblocked for this issue? If so, we could close this issue.

Regards,

gaugup commented 3 years ago

Closing this issue as no response. Please use internal microsoft aliases for issues related to azureml-interpret.

Regards,