Skip to content

Instantly share code, notes, and snippets.

@sararob
Created January 15, 2020 15:54
Show Gist options
  • Save sararob/58c1d48ba22a235f2904582b06b2a657 to your computer and use it in GitHub Desktop.
Save sararob/58c1d48ba22a235f2904582b06b2a657 to your computer and use it in GitHub Desktop.
Creating sample explanation metadata for Cloud AI Platform explainability
explain_metadata = {
"inputs": {
"amount": {
"input_tensor_name": "amount:0",
"input_baselines": [not_fraud['amount'].median()]
},
"newbalanceDest": {
"input_tensor_name": "newbalanceDest:0",
"input_baselines": [not_fraud['newbalanceDest'].median()]
},
"newbalanceOrig": {
"input_tensor_name": "newbalanceOrig:0",
"input_baselines": [not_fraud['newbalanceOrig'].median()]
},
"oldbalanceDest": {
"input_tensor_name": "oldbalanceDest:0",
"input_baselines": [not_fraud['oldbalanceDest'].median()]
},
"oldbalanceOrg": {
"input_tensor_name": "oldbalanceOrg:0",
"input_baselines": [not_fraud['oldbalanceOrg'].median()]
},
"step": {
"input_tensor_name": "step:0",
"input_baselines": [not_fraud['step'].median()]
},
"type": {
"input_tensor_name": "type_indicator:0",
"input_baselines": ["CASH_OUT"]
}
},
"outputs": {
"prob": {
"output_tensor_name": "boosted_trees/head/predictions/logistic:0"
}
},
"framework": "tensorflow"
}
# Write to a file
import json
with open('explanation_metadata.json', 'w') as output_file:
json.dump(explain_metadata, output_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment