Skip to content

Instantly share code, notes, and snippets.


sararob/ Secret

Created Jan 15, 2020
What would you like to do?
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