Skip to content

Instantly share code, notes, and snippets.

@Nanthini10
Created June 3, 2021 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nanthini10/3173bea91bdc50d8a851535f080c913f to your computer and use it in GitHub Desktop.
Save Nanthini10/3173bea91bdc50d8a851535f080c913f to your computer and use it in GitHub Desktop.
Retrieve explanation from client on Azure
from azureml.interpret import ExplanationClient
# Get model explanation data
client = ExplanationClient.from_run(run)
global_explanation = client.download_model_explanation()
local_importance_values = global_explanation.local_importance_values
expected_values = global_explanation.expected_values
# Or you can use the saved run.id to retrive the feature importance values
client = ExplanationClient.from_run_id(ws, experiment_name, run.id)
global_explanation = client.download_model_explanation()
local_importance_values = global_explanation.local_importance_values
expected_values = global_explanation.expected_values
# Get the top k (e.g., 4) most important features with their importance values
global_explanation_topk = client.download_model_explanation(top_k=4)
global_importance_values = global_explanation_topk.get_ranked_global_values()
global_importance_names = global_explanation_topk.get_ranked_global_names()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment