Evaluate data frame analytics Added in 7.3.0

POST /_ml/data_frame/_evaluate

The API packages together commonly used evaluation metrics for various types of machine learning features. This has been designed for use on indexes created by data frame analytics. Evaluation requires both a ground truth field and an analytics result field to be present.

application/json

Body Required

  • evaluation object Required

    Additional properties are allowed.

    Hide evaluation attributes Show evaluation attributes object
    • Additional properties are allowed.

      Hide classification attributes Show classification attributes object
      • actual_field string Required

        Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • metrics object

        Additional properties are allowed.

        Hide metrics attributes Show metrics attributes object
        • auc_roc object

          Additional properties are allowed.

          Hide auc_roc attributes Show auc_roc attributes object
          • Whether or not the curve should be returned in addition to the score. Default value is false.

        • Precision of predictions (per-class and average).

          Hide precision attribute Show precision attribute object
          • * object Additional properties

            Additional properties are allowed.

        • recall object

          Recall of predictions (per-class and average).

          Hide recall attribute Show recall attribute object
          • * object Additional properties

            Additional properties are allowed.

        • accuracy object

          Accuracy of predictions (per-class and overall).

          Hide accuracy attribute Show accuracy attribute object
          • * object Additional properties

            Additional properties are allowed.

        • Multiclass confusion matrix.

          Hide multiclass_confusion_matrix attribute Show multiclass_confusion_matrix attribute object
          • * object Additional properties

            Additional properties are allowed.

    • Additional properties are allowed.

      Hide outlier_detection attributes Show outlier_detection attributes object
      • actual_field string Required

        Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • metrics object

        Additional properties are allowed.

        Hide metrics attributes Show metrics attributes object
        • auc_roc object

          Additional properties are allowed.

          Hide auc_roc attributes Show auc_roc attributes object
          • Whether or not the curve should be returned in addition to the score. Default value is false.

        • Precision of predictions (per-class and average).

          Hide precision attribute Show precision attribute object
          • * object Additional properties

            Additional properties are allowed.

        • recall object

          Recall of predictions (per-class and average).

          Hide recall attribute Show recall attribute object
          • * object Additional properties

            Additional properties are allowed.

        • Accuracy of predictions (per-class and overall).

          Hide confusion_matrix attribute Show confusion_matrix attribute object
          • * object Additional properties

            Additional properties are allowed.

    • Additional properties are allowed.

      Hide regression attributes Show regression attributes object
      • actual_field string Required

        Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • predicted_field string Required

        Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • metrics object

        Additional properties are allowed.

        Hide metrics attributes Show metrics attributes object
        • mse object

          Average squared difference between the predicted values and the actual (ground truth) value. For more information, read this wiki article.

          Hide mse attribute Show mse attribute object
          • * object Additional properties

            Additional properties are allowed.

        • msle object

          Additional properties are allowed.

          Hide msle attribute Show msle attribute object
          • offset number

            Defines the transition point at which you switch from minimizing quadratic error to minimizing quadratic log error. Defaults to 1.

        • huber object

          Additional properties are allowed.

          Hide huber attribute Show huber attribute object
          • delta number

            Approximates 1/2 (prediction - actual)2 for values much less than delta and approximates a straight line with slope delta for values much larger than delta. Defaults to 1. Delta needs to be greater than 0.

        • Proportion of the variance in the dependent variable that is predictable from the independent variables.

          Hide r_squared attribute Show r_squared attribute object
          • * object Additional properties

            Additional properties are allowed.

  • index string Required
  • query object

    Additional properties are allowed.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • Additional properties are allowed.

      Hide classification attributes Show classification attributes object
    • Additional properties are allowed.

      Hide outlier_detection attributes Show outlier_detection attributes object
      • auc_roc object

        Additional properties are allowed.

        Hide auc_roc attributes Show auc_roc attributes object
      • Set the different thresholds of the outlier score at where the metric is calculated.

        Hide precision attribute Show precision attribute object
        • * number Additional properties
      • recall object

        Set the different thresholds of the outlier score at where the metric is calculated.

        Hide recall attribute Show recall attribute object
        • * number Additional properties
      • Set the different thresholds of the outlier score at where the metrics (tp - true positive, fp - false positive, tn - true negative, fn - false negative) are calculated.

        Hide confusion_matrix attribute Show confusion_matrix attribute object
        • * object Additional properties

          Additional properties are allowed.

          Hide * attributes Show * attributes object
          • tp number Required

            True Positive

          • fp number Required

            False Positive

          • tn number Required

            True Negative

          • fn number Required

            False Negative

    • Additional properties are allowed.

      Hide regression attributes Show regression attributes object
      • huber object

        Additional properties are allowed.

        Hide huber attribute Show huber attribute object
      • mse object

        Additional properties are allowed.

        Hide mse attribute Show mse attribute object
      • msle object

        Additional properties are allowed.

        Hide msle attribute Show msle attribute object
      • Additional properties are allowed.

        Hide r_squared attribute Show r_squared attribute object
POST /_ml/data_frame/_evaluate
curl \
 -X POST http://api.example.com/_ml/data_frame/_evaluate \
 -H "Content-Type: application/json" \
 -d '{"evaluation":{"classification":{"actual_field":"string","predicted_field":"string","top_classes_field":"string","":{"auc_roc":{"class_name":"string","include_curve":true},"precision":{"additionalProperty1":{},"additionalProperty2":{}},"recall":{"additionalProperty1":{},"additionalProperty2":{}},"accuracy":{"additionalProperty1":{},"additionalProperty2":{}},"multiclass_confusion_matrix":{"additionalProperty1":{},"additionalProperty2":{}}}},"outlier_detection":{"actual_field":"string","predicted_probability_field":"string","":{"auc_roc":{"class_name":"string","include_curve":true},"precision":{"additionalProperty1":{},"additionalProperty2":{}},"recall":{"additionalProperty1":{},"additionalProperty2":{}},"confusion_matrix":{"additionalProperty1":{},"additionalProperty2":{}}}},"regression":{"actual_field":"string","predicted_field":"string","metrics":{"mse":{"additionalProperty1":{},"additionalProperty2":{}},"msle":{"offset":42.0},"huber":{"delta":42.0},"r_squared":{"additionalProperty1":{},"additionalProperty2":{}}}}},"index":"string","query":{}}'
Request examples
{
  "evaluation": {
    "classification": {
      "actual_field": "string",
      "predicted_field": "string",
      "top_classes_field": "string",
      "": {
        "auc_roc": {
          "class_name": "string",
          "include_curve": true
        },
        "precision": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        },
        "recall": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        },
        "accuracy": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        },
        "multiclass_confusion_matrix": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        }
      }
    },
    "outlier_detection": {
      "actual_field": "string",
      "predicted_probability_field": "string",
      "": {
        "auc_roc": {
          "class_name": "string",
          "include_curve": true
        },
        "precision": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        },
        "recall": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        },
        "confusion_matrix": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        }
      }
    },
    "regression": {
      "actual_field": "string",
      "predicted_field": "string",
      "metrics": {
        "mse": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        },
        "msle": {
          "offset": 42.0
        },
        "huber": {
          "delta": 42.0
        },
        "r_squared": {
          "additionalProperty1": {},
          "additionalProperty2": {}
        }
      }
    }
  },
  "index": "string",
  "query": {}
}
Response examples (200)
{
  "classification": {
    "": {
      "value": 42.0,
      "curve": [
        {
          "tpr": 42.0,
          "fpr": 42.0,
          "threshold": 42.0
        }
      ]
    },
    "accuracy": {
      "classes": [
        {
          "value": 42.0,
          "class_name": "string"
        }
      ],
      "overall_accuracy": 42.0
    },
    "multiclass_confusion_matrix": {
      "confusion_matrix": [
        {
          "actual_class": "string",
          "actual_class_doc_count": 42.0,
          "predicted_classes": [
            {}
          ],
          "other_predicted_class_doc_count": 42.0
        }
      ],
      "other_actual_class_count": 42.0
    },
    "precision": {
      "classes": [
        {
          "value": 42.0,
          "class_name": "string"
        }
      ],
      "avg_precision": 42.0
    },
    "recall": {
      "classes": [
        {
          "value": 42.0,
          "class_name": "string"
        }
      ],
      "avg_recall": 42.0
    }
  },
  "outlier_detection": {
    "": {
      "value": 42.0,
      "curve": [
        {
          "tpr": 42.0,
          "fpr": 42.0,
          "threshold": 42.0
        }
      ]
    },
    "precision": {
      "additionalProperty1": 42.0,
      "additionalProperty2": 42.0
    },
    "recall": {
      "additionalProperty1": 42.0,
      "additionalProperty2": 42.0
    },
    "confusion_matrix": {
      "additionalProperty1": {
        "tp": 42.0,
        "fp": 42.0,
        "tn": 42.0,
        "fn": 42.0
      },
      "additionalProperty2": {
        "tp": 42.0,
        "fp": 42.0,
        "tn": 42.0,
        "fn": 42.0
      }
    }
  },
  "regression": {
    "huber": {
      "value": 42.0
    },
    "mse": {
      "value": 42.0
    },
    "msle": {
      "value": 42.0
    },
    "r_squared": {
      "value": 42.0
    }
  }
}