Explainability#

Tabular Explainability#

Returns per datapoint explanations on a model with tabular input data for a specific attribute. For aggregate explainability across datapoints, see Regional Feature Importance if interested in one property of your model or Regional Feature Importances if interested in all properties of your model. This is only available if explainability has been enabled for the model.

Query Request:

{
    "select": [
        {
            "property": "explainer_algo"
        },
        {
            "property": "explainer_predicted_attribute"
        },
        {
            "property": "explainer_attribute"
        },
        {
            "property": "explainer_score"
        }
    ],
    "filter": [
        {
            "property": "[inference_id|partner_inference_id]",
            "comparator": "eq",
            "value": "<id> [string]"
        }
    ],
    "from": "enriched"
}

Query Response:

{
    "query_result": [
        {
            "explainer_algo": "[lime|shap]",
            "explainer_attribute": "<attribute_name> [string]",
            "explainer_predicted_attribute": "<predicted_attribute_name> [string]",
            "explainer_score": "<feature_importance_value> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "property": "explainer_algo"
        },
        {
            "property": "explainer_predicted_attribute"
        },
        {
            "property": "explainer_attribute"
        },
        {
            "property": "explainer_score"
        }
    ],
    "filter": [
        {
            "property": "partner_inference_id",
            "comparator": "eq",
            "value": "1617235140000"
        }
    ],
    "order_by": [
        {
            "property": "explainer_algo",
            "direction": "asc"
        },
        {
            "property": "explainer_predicted_attribute",
            "direction": "asc"
        },
        {
            "property": "explainer_attribute",
            "direction": "asc"
        }
    ],
    "from": "enriched"
}

Sample Response:

{
    "query_result": [
        {
            "explainer_algo": "lime",
            "explainer_attribute": "AGE",
            "explainer_predicted_attribute": "prediction_0",
            "explainer_score": 0.0016485283063465874
        },
        {
            "explainer_algo": "lime",
            "explainer_attribute": "BILL_AMT1",
            "explainer_predicted_attribute": "prediction_0",
            "explainer_score": 0.0032036810960691183
        },
        {
            "explainer_algo": "lime",
            "explainer_attribute": "BILL_AMT2",
            "explainer_predicted_attribute": "prediction_0",
            "explainer_score": 0.002008238656596662
        },
        {
            "explainer_algo": "lime",
            "explainer_attribute": "AGE",
            "explainer_predicted_attribute": "prediction_1",
            "explainer_score": -0.0016485283063465892
        },
        {
            "explainer_algo": "lime",
            "explainer_attribute": "BILL_AMT1",
            "explainer_predicted_attribute": "prediction_1",
            "explainer_score": -0.0032036810960691126
        },
        {
            "explainer_algo": "lime",
            "explainer_attribute": "BILL_AMT2",
            "explainer_predicted_attribute": "prediction_1",
            "explainer_score": -0.0020082386565966667
        }
    ]
}

back to top

NLP Explainability#

The nlp_explanation function can be used to query and filter explanations for tokens in NLP inferences. In using this function the user can filter and order tokens by importance. The following are available optional properties:

  • nlp_explanation.token - References a token within a specific inference.

  • nlp_explanation.location - References a token’s absolute location within a specific inference.

  • nlp_explanation.value - References a token’s explanation value within a specific inference.

Query Request:

{
    "select": [
        {
            "function": "nlp_explanation",
            "alias": "<alias_name> [Optional]",
            "parameters": {
                "attribute_name": "<text_input_attribute_name> [string]",
                "nlp_predicted_attribute": "<predicted_attribute_name> [string]",
                "nlp_explainer": "[lime|shap]"
            }
        }
    ],
    "filter": [
        {
            "property": "nlp_explanation.token",
            "comparator": "eq",
            "value": "<token>"
        },
        {
            "property": "nlp_explanation.location",
            "comparator": "eq",
            "value": "<location>"
        }
    ],
    "order_by": [
        {
            "property": "nlp_explanation.value",
            "direction": "desc"
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "inference_id": "<id> [string]",
            "nlp_explanation": [
                {
                    "algorithm": "[lime|shap]",
                    "predicted_attribute_name": "<predicted_attribute_name> [string]",
                    "importance_scores": [
                        {
                            "attribute_name": "<input_attribute_name> [string]",
                            "tokens": [
                                {
                                    "token": "<token> [string]",
                                    "position": "<position_in_text> [int]",
                                    "value": "<explanation_score> [float]"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "nlp_explanation",
            "parameters": {
                "attribute_name": "transcription",
                "nlp_predicted_attribute": "cardiovascular__pulmonary",
                "nlp_explainer": "lime"
            }
        }
    ],
    "filter": [
        {
            "property": "partner_inference_id",
            "comparator": "eq",
            "value": "1617321572000"
        },
        {
            "property": "nlp_explanation.token",
            "comparator": "eq",
            "value": "dog"
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "inference_id": "0b40e801-6f04-47aa-94d7-99b5f86a6bc4",
            "nlp_explanation": {
                "algorithm": "lime",
                "predicted_attribute_name": "cardiovascular__pulmonary",
                "importance_scores": [
                    {
                        "attribute_name": "",
                        "tokens": [
                            {
                                "token": "postoperative",
                                "position": 10,
                                "explanation_value": 0.007326229429931506
                            },
                            {
                                "token": "postoperative",
                                "position": 24,
                                "explanation_value": 0.002047999807176794
                            }
                        ]
                    }
                ]
            }
        }
    ]
}

back to top