UserErrorException when trying to use the explain model
I was using the azureml locally for testing purpose but when I use the following code for understanding the feature importances it throws as error as mentioned below:
shap_values, expected_values, overall_summary, overall_imp, per_class_summary, per_class_imp =
retrieve_model_explanation(best_run)
UserErrorException: File with path explanation/shap_values.json was not found, available files include: accuracy_table,confusion_matrix,outputs/model.pkl.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 36c9ed64-01c3-d7d5-bbdb-8ede3f69d02e
- Version Independent ID: 01df3a5d-c87d-b629-4cfe-2ddee7f2eb06
- Content: azureml.train.automl.automlexplainer module - Azure Machine Learning Python
- Content Source: AzureML/docs-ref-autogen/azureml-train-automl/azureml.train.automl.automlexplainer.yml
- Service: machine-learning
- GitHub Login: @j-martens
- Microsoft Alias: jmartens
Hi @shivsn, Can you please provide us with more details on how you used AutoML and what parameters were used in your AutoML configurations so that we can reproduce the error?
I get the same error when I have used GPU in AzureML Compute. I am running the auto-ml-remote-batchai azure notebook and then using the explanation component of the the auto-ml-model-explanation azure notebook. My AutoML configuration is: automl_settings = { "iteration_timeout_minutes": 2, "iterations": 20, "n_cross_validations": 5, "primary_metric": 'AUC_weighted', "preprocess": False, "max_concurrent_iterations": 5, "verbosity": logging.INFO }
automl_config = AutoMLConfig(task = 'classification', debug_log = 'automl_errors.log', path = project_folder, run_configuration=conda_run_config, data_script = project_folder + "/get_data.py", **automl_settings )
@
Hi @shivsn, Can you please provide us with more details on how you used AutoML and what parameters were used in your AutoML configurations so that we can reproduce the error?
Hi @mesameki this was the AutoMLConfig used if you need more details I can share them: AutoMLConfig(task = 'classification', debug_log = 'automl_errors.log', primary_metric = 'accuracy', iteration_timeout_minutes = 5, iterations = 10, n_cross_validations = 3, verbosity = logging.INFO, X = X_train, y = y_train, path = project_folder, preprocess=True).
Hi @shivsn and @amcib, it looks like you didn't actually run the model explanation - AutoML requires you to set model_explainability=True when you create the config. There is an example in the notebook here: https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/model-explanation/auto-ml-model-explanation.ipynb
Because that parameter wasn't passed in, the explanation didn't happen, and so the files associated with the explanation don't exist.
I'm having an issue where turning on model_explainability causes the experiments to run for an absurdly long amount of time, even when iteration_timeout_minutes is set.
Hi @ktebbe, what version of Automated ML are you using? There have been some big performance improvements in our most recent version.
Hi @wamartin-aml - How do I find what version I'm using?
From within your environment, I believe you should be able to run pip show azureml-train-automl. The version number should be near the top of what prints out.
@wamartin-aml I'm using version 1.0.6. What's the latest version?
Based on the pypi package, it looks like 1.0.21.1 is the latest. You can either specifically pip install azureml-train-automl==1.0.21.1 or just pip install azureml-train-automl --upgrade for whatever the latest is.
A word of warning - for large datasets, particularly ones with many features (or text which Automated ML may convert into many features), model explainability is a somewhat expensive operation, which may take longer than you initially expect.
I have the same issue as well. I'm following all the step by steps on this sample notebook: https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/model-explanation/auto-ml-model-explanation.ipynb When I get to the part where I ask for model explain ability, I get error: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last)
~/anaconda3_501/lib/python3.6/site-packages/azureml/train/automl/automlexplainer.py in retrieve_model_explanation(child_run) 124 explanation = get_model_explanation(child_run) 125 # Get explanation summary information --> 126 explanation = explanation + get_model_summary(child_run) 127 return _convert_explanation(explanation) 128 except ImportError:
~/anaconda3_501/lib/python3.6/site-packages/azureml/explain/model/_internal/results.py in get_model_summary(run, global_importance_only, top_k) 256 if feature_names is not None: 257 global_importance = _sort_feature_list_single(feature_names, global_importance_rank) --> 258 return global_importance_values, global_importance 259 260
~/anaconda3_501/lib/python3.6/site-packages/azureml/_async/task_queue.py in exit(self, *args) 51 def exit(self, *args): 52 self._logger.debug("[Stop] - waiting default timeout") ---> 53 self.flush(self.identity) 54 55 def add(self, func, *args, **kwargs):
~/anaconda3_501/lib/python3.6/site-packages/azureml/_async/task_queue.py in flush(self, source, timeout_seconds) 117 time.sleep(.1) 118 --> 119 self._results.extend((task.wait() for task in completed_tasks)) 120 121 self._logger.debug(message)
~/anaconda3_501/lib/python3.6/site-packages/azureml/_async/task_queue.py in
~/anaconda3_501/lib/python3.6/site-packages/azureml/_async/async_task.py in wait(self) 53 """Wait until the future is done""" 54 with self._log_context("WaitingTask"): ---> 55 res = self._handler(self._future, self._logger) 56 return res 57
~/anaconda3_501/lib/python3.6/site-packages/azureml/_async/async_task.py in basic_handler(future, _) 14 def basic_handler(future, _): 15 """Returns future's result directly with no error handling""" ---> 16 return future.result() 17 18
~/anaconda3_501/lib/python3.6/concurrent/futures/_base.py in result(self, timeout) 423 raise CancelledError() 424 elif self._state == FINISHED: --> 425 return self.__get_result() 426 427 self._condition.wait(timeout)
~/anaconda3_501/lib/python3.6/concurrent/futures/_base.py in __get_result(self) 382 def __get_result(self): 383 if self._exception: --> 384 raise self._exception 385 else: 386 return self._result
~/anaconda3_501/lib/python3.6/site-packages/azureml/explain/model/_internal/results.py in get_model_summary(run, global_importance_only, top_k) 233 task = task_queue.add(_download_model_summary, run, download_dir, summary_name, top_k) 234 results.append(task) --> 235 results = list(map(lambda task: task.wait(), results)) 236 global_importance_values, global_importance_rank, per_class_values, per_class_rank = results 237 global_importance = global_importance_rank
~/anaconda3_501/lib/python3.6/site-packages/azureml/explain/model/_internal/results.py in
~/anaconda3_501/lib/python3.6/site-packages/azureml/_async/async_task.py in wait(self) 53 """Wait until the future is done""" 54 with self._log_context("WaitingTask"): ---> 55 res = self._handler(self._future, self._logger) 56 return res 57
~/anaconda3_501/lib/python3.6/site-packages/azureml/_async/async_task.py in basic_handler(future, _) 14 def basic_handler(future, _): 15 """Returns future's result directly with no error handling""" ---> 16 return future.result() 17 18
~/anaconda3_501/lib/python3.6/concurrent/futures/_base.py in result(self, timeout) 423 raise CancelledError() 424 elif self._state == FINISHED: --> 425 return self.__get_result() 426 427 self._condition.wait(timeout)
~/anaconda3_501/lib/python3.6/concurrent/futures/_base.py in __get_result(self) 382 def __get_result(self): 383 if self._exception: --> 384 raise self._exception 385 else: 386 return self._result
~/anaconda3_501/lib/python3.6/concurrent/futures/thread.py in run(self) 54 55 try: ---> 56 result = self.fn(*self.args, **self.kwargs) 57 except BaseException as exc: 58 self.future.set_exception(exc)
~/anaconda3_501/lib/python3.6/site-packages/azureml/explain/model/_internal/results.py in _download_model_summary(run, download_dir, summary_name, top_k) 51 explanation_asset = explanation_assets[0] 52 metadata_artifact_name = explanation_asset.meta[History.METADATA_ARTIFACT] ---> 53 storage_metadata = _download_artifact(run, download_dir, metadata_artifact_name) 54 meta_keys = storage_metadata.keys() 55 for key in meta_keys:
~/anaconda3_501/lib/python3.6/site-packages/azureml/explain/model/_internal/results.py in _download_artifact(run, download_dir, artifact_name, explanation_id) 38 with open(path, 'rb') as f: 39 json_string = f.read() ---> 40 values = json.loads(json_string.decode('utf-8')) 41 return values 42
~/anaconda3_501/lib/python3.6/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 352 parse_int is None and parse_float is None and 353 parse_constant is None and object_pairs_hook is None and not kw): --> 354 return _default_decoder.decode(s) 355 if cls is None: 356 cls = JSONDecoder
~/anaconda3_501/lib/python3.6/json/decoder.py in decode(self, s, _w) 337 338 """ --> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 340 end = _w(s, end).end() 341 if end != len(s):
~/anaconda3_501/lib/python3.6/json/decoder.py in raw_decode(self, s, idx) 355 obj, end = self.scan_once(s, idx) 356 except StopIteration as err: --> 357 raise JSONDecodeError("Expecting value", s, err.value) from None 358 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I have the same issue as well. I'm following all the step by steps on this sample notebook: https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/model-explanation/auto-ml-model-explanation.ipynb When I get to the part where I ask for model explain ability, I get error: Expecting value: line 1 column 1 (char 0)
BTW - I'm using local compute context with an Azure Notebook.
@cdotzenrod could you please post the full error message (eg the full stack trace in the notebook above) you are seeing in the notebook? Thanks!
I posted that dump. Any insights?
Get Outlook for Androidhttps://aka.ms/ghei36
From: Ilya Matiach [email protected] Sent: Friday, April 12, 2019 4:20:43 PM To: Azure/MachineLearningNotebooks Cc: Chad Dotzenrod; Mention Subject: Re: [Azure/MachineLearningNotebooks] UserErrorException when trying to use the explain model (#221)
@cdotzenrodhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcdotzenrod&data=02%7C01%7CChad.Dotzenrod%40microsoft.com%7Ca8249be69ca14ecdd2a408d6bf8cb961%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636907008452063084&sdata=DOCCoHLDiOO6s5S8FauYiR5lQ%2BqcTzWBLBavcYutOL0%3D&reserved=0 could you please post the full error message you are seeing in the notebook? Thanks!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2FMachineLearningNotebooks%2Fissues%2F221%23issuecomment-482726989&data=02%7C01%7CChad.Dotzenrod%40microsoft.com%7Ca8249be69ca14ecdd2a408d6bf8cb961%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636907008452063084&sdata=I47KJha%2Fq%2BAOz5P9KtsRM5mYnzj7%2FJAu4raQzEwtD5g%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAiYj_c45h9Pi4F3YUZO4p17fnpDewh3hks5vgPirgaJpZM4bEjNW&data=02%7C01%7CChad.Dotzenrod%40microsoft.com%7Ca8249be69ca14ecdd2a408d6bf8cb961%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636907008452073080&sdata=fYp1%2BUNU74nPvEUZOnhTZ7qt27ql8uzH5XmljDonE60%3D&reserved=0.
@cdotzenrod could you please post the full error message (eg the full stack trace in the notebook above) you are seeing in the notebook? Thanks!
Did you figure out what the issue is? I'm trying to get a customer demo ready and can't proceed. Are there other walk-throughs I could do that will work with Azure Notebooks and include model explainability? Or should I use Databricks instead of Azure Notebooks?
@cdotzenrod sorry, I'm not sure what the issue is yet. Could you please run: "pip show azureml-explain-model" and post the results here? Also, could you try upgrading the package to latest: pip install --upgrade azureml-explain-model The notebook is passing our builds so I'm not quite sure what is wrong. Are you modifying the notebook in any way, eg using a different dataset?
also, if you are still having issues maybe we could discuss on a teams or skype call and you could share screen?
A teams call would be good. Let me know when you are free. I could run those PIP commands locally but I was in the understanding that Azure Notebooks don't execute on my local machine. Am I mistaken? I'll go ahead and run those right now to see what I get.
Chad Dotzenrod Data & AI Specialist Microsoft Corp - US Health and Life Sciences
630.669.6095 [email protected]
From: Ilya Matiach [email protected] Sent: Tuesday, April 16, 2019 8:56:32 AM To: Azure/MachineLearningNotebooks Cc: Chad Dotzenrod; Mention Subject: Re: [Azure/MachineLearningNotebooks] UserErrorException when trying to use the explain model (#221)
also, if you are still having issues maybe we could discuss on a teams or skype call and you could share screen?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2FMachineLearningNotebooks%2Fissues%2F221%23issuecomment-483670050&data=02%7C01%7CChad.Dotzenrod%40microsoft.com%7Ce76da37d2ef944d3696108d6c2735823%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636910197986732313&sdata=%2B1KDpobE8o8gFWQV8MNJLqiHQO%2F4nWL1EVQ5Qls0wzg%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAiYj_VfZKh2tyCx3d_tr2YT_lYz8PKWCks5vhdaQgaJpZM4bEjNW&data=02%7C01%7CChad.Dotzenrod%40microsoft.com%7Ce76da37d2ef944d3696108d6c2735823%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636910197986732313&sdata=I8MLW2FoRkq4hiHoAcfLmceXgJOiLcStTFLtnyih3xU%3D&reserved=0.
When I read the overview of Azure Notebooks, I'm given the impression that I don't need anything installed locally and that I have access to a virtual python env in the cloud. Am I mistaken?
https://docs.microsoft.com/en-us/azure/notebooks/azure-notebooks-overview
[https://docs.microsoft.com/en-us/media/logos/logo-ms-social.png]https://docs.microsoft.com/en-us/azure/notebooks/azure-notebooks-overview
Overview of Azure Notebooks | Microsoft Docshttps://docs.microsoft.com/en-us/azure/notebooks/azure-notebooks-overview docs.microsoft.com Overview of Azure Notebooks. 04/05/2019; 4 minutes to read; Contributors. In this article. Azure Notebooks is a free hosted service to develop and run Jupyter notebooks in the cloud with no installation.
Chad Dotzenrod Data & AI Specialist Microsoft Corp - US Health and Life Sciences
630.669.6095 [email protected]
From: Chad Dotzenrod Sent: Tuesday, April 16, 2019 9:16:59 AM To: Azure/MachineLearningNotebooks Subject: Re: [Azure/MachineLearningNotebooks] UserErrorException when trying to use the explain model (#221)
A teams call would be good. Let me know when you are free. I could run those PIP commands locally but I was in the understanding that Azure Notebooks don't execute on my local machine. Am I mistaken? I'll go ahead and run those right now to see what I get.
Chad Dotzenrod Data & AI Specialist Microsoft Corp - US Health and Life Sciences
630.669.6095 [email protected]
From: Ilya Matiach [email protected] Sent: Tuesday, April 16, 2019 8:56:32 AM To: Azure/MachineLearningNotebooks Cc: Chad Dotzenrod; Mention Subject: Re: [Azure/MachineLearningNotebooks] UserErrorException when trying to use the explain model (#221)
also, if you are still having issues maybe we could discuss on a teams or skype call and you could share screen?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2FMachineLearningNotebooks%2Fissues%2F221%23issuecomment-483670050&data=02%7C01%7CChad.Dotzenrod%40microsoft.com%7Ce76da37d2ef944d3696108d6c2735823%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636910197986732313&sdata=%2B1KDpobE8o8gFWQV8MNJLqiHQO%2F4nWL1EVQ5Qls0wzg%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAiYj_VfZKh2tyCx3d_tr2YT_lYz8PKWCks5vhdaQgaJpZM4bEjNW&data=02%7C01%7CChad.Dotzenrod%40microsoft.com%7Ce76da37d2ef944d3696108d6c2735823%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636910197986732313&sdata=I8MLW2FoRkq4hiHoAcfLmceXgJOiLcStTFLtnyih3xU%3D&reserved=0.
@cdotzenrod thank you for helping me repro the issue on teams. I was able to repro and fix the issue. It ended up being a python environment issue. Can you please run the following:
from pip._internal import main as pip
pip(["install", "--upgrade", "numpy"])
pip(["install", "--upgrade", "scikit-image"])
And restart the kernel before rerunning the notebook? That fixed the error for me.