evaluate-dfanalytics.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[evaluate-dfanalytics]]
  4. === Evaluate {dfanalytics} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Evaluate {dfanalytics}</titleabbrev>
  8. ++++
  9. Evaluates the {dfanalytics} for an annotated index.
  10. experimental[]
  11. [[ml-evaluate-dfanalytics-request]]
  12. ==== {api-request-title}
  13. `POST _ml/data_frame/_evaluate`
  14. [[ml-evaluate-dfanalytics-prereq]]
  15. ==== {api-prereq-title}
  16. * You must have `monitor_ml` privilege to use this API. For more
  17. information, see {stack-ov}/security-privileges.html[Security privileges] and
  18. {stack-ov}/built-in-roles.html[Built-in roles].
  19. [[ml-evaluate-dfanalytics-desc]]
  20. ==== {api-description-title}
  21. This API evaluates the executed analysis on an index that is already annotated
  22. with a field that contains the results of the analytics (the `ground truth`)
  23. for each {dataframe} row.
  24. Evaluation is typically done by calculating a set of metrics that capture various aspects of the quality of the results over the data for which you have the
  25. `ground truth`.
  26. For different types of analyses different metrics are suitable. This API
  27. packages together commonly used metrics for various analyses.
  28. [[ml-evaluate-dfanalytics-request-body]]
  29. ==== {api-request-body-title}
  30. `index` (Required)::
  31. (object) Defines the `index` in which the evaluation will be performed.
  32. `evaluation` (Required)::
  33. (object) Defines the type of evaluation you want to perform. For example:
  34. `binary_soft_classification`. See <<ml-evaluate-dfanalytics-resources>>.
  35. [[ml-evaluate-dfanalytics-results]]
  36. ==== {api-response-body-title}
  37. `binary_soft_classification`::
  38. (object) If you chose to do binary soft classification, the API returns the
  39. following evaluation metrics:
  40. `auc_roc`::: TBD
  41. `confusion_matrix`::: TBD
  42. `precision`::: TBD
  43. `recall`::: TBD
  44. [[ml-evaluate-dfanalytics-example]]
  45. ==== {api-examples-title}
  46. [source,js]
  47. --------------------------------------------------
  48. POST _ml/data_frame/_evaluate
  49. {
  50. "index": "my_analytics_dest_index",
  51. "evaluation": {
  52. "binary_soft_classification": {
  53. "actual_field": "is_outlier",
  54. "predicted_probability_field": "ml.outlier_score"
  55. }
  56. }
  57. }
  58. --------------------------------------------------
  59. // CONSOLE
  60. // TEST[skip:TBD]
  61. The API returns the following results:
  62. [source,js]
  63. ----
  64. {
  65. "binary_soft_classification": {
  66. "auc_roc": {
  67. "score": 0.92584757746414444
  68. },
  69. "confusion_matrix": {
  70. "0.25": {
  71. "tp": 5,
  72. "fp": 9,
  73. "tn": 204,
  74. "fn": 5
  75. },
  76. "0.5": {
  77. "tp": 1,
  78. "fp": 5,
  79. "tn": 208,
  80. "fn": 9
  81. },
  82. "0.75": {
  83. "tp": 0,
  84. "fp": 4,
  85. "tn": 209,
  86. "fn": 10
  87. }
  88. },
  89. "precision": {
  90. "0.25": 0.35714285714285715,
  91. "0.5": 0.16666666666666666,
  92. "0.75": 0
  93. },
  94. "recall": {
  95. "0.25": 0.5,
  96. "0.5": 0.1,
  97. "0.75": 0
  98. }
  99. }
  100. }
  101. ----
  102. // TESTRESPONSE