Aggregation Functions

For an explanation of nested functions, see the guide here.

Average

Take the average of a property.

Query Request:

{
    "select": [
        {
            "function": "avg",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string or nested]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<avg_value> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "avg",
            "alias": "avgAge",
            "parameters": {
                "property": "age"
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "avgAge": 55.45
        }
    ]
}

back to top

Average of Absolute Values

Take the average of a absolute values of a property.

Query Request:

{
    "select": [
        {
            "function": "avgAbs",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string or nested]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<avg_abs_value> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "avgAbs",
            "alias": "avgafloat",
            "parameters": {
                "property": "afloat"
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "avgafloat": 55.45
        }
    ]
}

back to top

Max

Take the max of a property.

Query Request:

{
    "select": [
        {
            "function": "max",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string or nested]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<max_value> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "max",
            "alias": "maxAge",
            "parameters": {
                "property": "age"
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "maxAge": 55.45
        }
    ]
}

back to top

Min

Take the min of a property.

Query Request:

{
    "select": [
        {
            "function": "min",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string or nested]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<min_value> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "min",
            "alias": "minAge",
            "parameters": {
                "property": "age"
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "minAge": 17
        }
    ]
}

back to top

Sum

Take the sum of a property.

Query Request:

{
    "select": [
        {
            "function": "sum",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string or nested]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<sum_value> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "sum",
            "alias": "sumAge",
            "parameters": {
                "property": "age"
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "sumAge": 1745
        }
    ]
}

back to top

Variance

Take the variance of a property.

Query Request:

{
    "select": [
        {
            "function": "variance",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string or nested]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<variance> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "variance",
            "alias": "varAge",
            "parameters": {
                "property": "age"
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "varAge": 10.234
        }
    ]
}

back to top

Count

Count a property.

Query Request:

{
    "select": [
        {
            "function": "count",
            "alias": "<alias_name> [optional string]"
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<count> [int]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "count"
        }
    ],
    "filter": [
        {
            "property": "income",
            "comparator": "lt",
            "value": 90000
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "count": 5432
        }
    ]
}

back to top

Count If

Conditionally count a property.

Query Request:

{
    "select": [
        {
            "function": "countIf",
            "alias": "<alias_name> [optional string]",
            "parameters": {
              "property": "<attribute_name> [string or nested]",
              "comparator": "[gt|lt|gte|lte|eq|ne]",
              "value": "<string or number to compare with property>"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<count> [int]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "countIf",
            "alias": "michigan_count",
            "parameter": {
                "property": "state",
                "comparator": "eq",
                "value": "michigan"
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "michigan_count": 5432
        }
    ]
}

back to top

Categories Count

Count the number of categories of a property. To be used for discrete features.

Query Request:

{
    "select": [
        {
            "function": "categoriesCount",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<categories_count> [int]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "categoriesCount",
            "alias": "categoriesCountZipcode",
            "parameters": {
                "property": "zipcode"
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "categoriesCountZipcode": 732
        }
    ]
}

back to top

Rate

Calculates the rate of a condition on a column.

Query Request:

{
    "select": [
        {
            "function": "rate",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string or nested]",
                "comparator": "[gt|lt|gte|lte|eq|ne]",
                "value": "<string or number to compare with property>"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<rate_value> [float]"
        }
    ]
}

Sample Request: Calculate the positive predictive rate, with predictions classified as positive when pos_class above .5 (standard definition of positive predictive rate).

{
    "select": [
        {
            "function": "rate",
            "alias": "pos_rate",
            "parameters": {
                "property": "pos_class",
                "comparator": "gt",
                "value": 0.5
            }
        }
    ]
}

Response:

{
    "query_result": [
        {
            "pos_rate": "0.1"
        }
    ]
}

back to top

Distribution

Return the distribution of a column with a specified number of bins. If there is not enough data, fewer than the specified number of bins will be returned.

Query Request:

{
    "select": [
        {
            "function": "distribution",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "property": "<attribute_name> [string or nested]",
                "num_bins": "<number_of_bins> [int]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": [
                {
                    "lower": "<bin_lower_bound> [float]",
                    "upper": "<bin_upper_bound> [float]",
                    "count": "<bin_count> [float]"
                }
            ]
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "distribution",
            "parameters": {
                "property": "FICO_predicted",
                "num_bins": 50
            }
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "distribution": [
                {
                    "lower": 500,
                    "upper": 600,
                    "count": 1000
                },
                {
                    "lower": 600,
                    "upper": 700,
                    "count": 5000
                },
                {
                    "lower": 700,
                    "upper": 800,
                    "count": 2000
                },
                {
                    "lower": 800,
                    "upper": 850,
                    "count": 550
                }
            ]
        }
    ]
}

back to top

Regional Feature Importance

Returns the regional importance score for a particular attribute. This is the average of the absolute value of the explainability value for all the inferences. This is only available if explainability has been enabled for the model.

Query Request:

{
    "select": [
        {
            "function": "regionalFeatureImportance",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "attribute_name": "<pipeline_input_attribute_name> [string]",
                "predicted_attribute_name": "<predicted_attribute_name> [string]",
                "explanation_algorithm": "[lime|shap]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<function_name/alias_name>": "<feature_importance_value> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "regionalFeatureImportance",
            "parameters": {
                "attribute_name": "AGE",
                "predicted_attribute_name": "prediction_0",
                "explanation_algorithm": "lime"
            }
        }
    ],
    "filter": [
        {
            "property": "inference_timestamp",
            "comparator": "gte",
            "value": "2020-12-01T10:00:00Z"
        },
        {
            "property": "inference_timestamp",
            "comparator": "lt",
            "value": "2020-12-22T11:00:00Z"
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "AGE": 0.001406118694451489
        }
    ]
}

back to top

Regional Feature Importances

Returns the regional importance scores for all of the pipeline input attributes. This is the average of the absolute value of the explainability value for all the inferences for each pipeline input attribute. This is only available if explainability has been enabled for the model.

Query Request:

{
    "select": [
        {
            "function": "regionalFeatureImportances",
            "alias": "<alias_name> [optional string]",
            "parameters": {
                "predicted_attribute_name": "<predicted_attribute_name> [string]",
                "explanation_algorithm": "[lime|shap]"
            }
        }
    ]
}

Query Response:

{
    "query_result": [
        {
            "<attribute_name>": "<feature_importance_value> [float]",
            "<attribute_name>": "<feature_importance_value> [float]",
            "<attribute_name>": "<feature_importance_value> [float]",
            "<attribute_name>": "<feature_importance_value> [float]",
            "<attribute_name>": "<feature_importance_value> [float]"
        }
    ]
}

Sample Request:

{
    "select": [
        {
            "function": "regionalFeatureImportances",
            "parameters": {
                "predicted_attribute_name": "prediction_0",
                "explanation_algorithm": "lime"
            }
        }
    ],
    "filter": [
        {
            "property": "inference_timestamp",
            "comparator": "gte",
            "value": "2020-12-01T10:00:00Z"
        },
        {
            "property": "inference_timestamp",
            "comparator": "lt",
            "value": "2020-12-22T11:00:00Z"
        }
    ]
}

Sample Response:

{
    "query_result": [
        {
            "explainer_attribute": "PAY_0",
            "regionalFeatureImportance": 0.055036517803945396
        },
        {
            "explainer_attribute": "PAY_2",
            "regionalFeatureImportance": 0.026880464089676884
        },
        {
            "explainer_attribute": "PAY_3",
            "regionalFeatureImportance": 0.024027941129616155
        },
        {
            "explainer_attribute": "LIMIT_BAL",
            "regionalFeatureImportance": 0.022367882999425544
        },
        {
            "explainer_attribute": "PAY_AMT2",
            "regionalFeatureImportance": 0.019145911247181836
        },
        {
            "explainer_attribute": "PAY_AMT1",
            "regionalFeatureImportance": 0.019052984358794038
        },
        {
            "explainer_attribute": "PAY_AMT3",
            "regionalFeatureImportance": 0.012942233755875516
        },
        {
            "explainer_attribute": "PAY_5",
            "regionalFeatureImportance": 0.011911442095349226
        },
        {
            "explainer_attribute": "PAY_4",
            "regionalFeatureImportance": 0.010464962507962139
        },
        {
            "explainer_attribute": "PAY_6",
            "regionalFeatureImportance": 0.00891260261770653
        },
        {
            "explainer_attribute": "BILL_AMT4",
            "regionalFeatureImportance": 0.007211523900878019
        },
        {
            "explainer_attribute": "BILL_AMT5",
            "regionalFeatureImportance": 0.006279087267628024
        },
        {
            "explainer_attribute": "BILL_AMT1",
            "regionalFeatureImportance": 0.006221344024007549
        },
        {
            "explainer_attribute": "PAY_AMT4",
            "regionalFeatureImportance": 0.005310133724715099
        },
        {
            "explainer_attribute": "PAY_AMT6",
            "regionalFeatureImportance": 0.004135643379284112
        },
        {
            "explainer_attribute": "MARRIAGE",
            "regionalFeatureImportance": 0.004089899824740581
        },
        {
            "explainer_attribute": "EDUCATION",
            "regionalFeatureImportance": 0.003931984513777395
        },
        {
            "explainer_attribute": "PAY_AMT5",
            "regionalFeatureImportance": 0.0033734464617669853
        },
        {
            "explainer_attribute": "SEX",
            "regionalFeatureImportance": 0.0029222783744727687
        },
        {
            "explainer_attribute": "BILL_AMT6",
            "regionalFeatureImportance": 0.002707692309829875
        },
        {
            "explainer_attribute": "BILL_AMT2",
            "regionalFeatureImportance": 0.001955133839877692
        },
        {
            "explainer_attribute": "BILL_AMT3",
            "regionalFeatureImportance": 0.001779632159224476
        },
        {
            "explainer_attribute": "AGE",
            "regionalFeatureImportance": 0.001406118694451494
        }
    ]
}

back to top