evaluate-dfanalytics.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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`::
  31. (Required, object) Defines the `index` in which the evaluation will be
  32. performed.
  33. `evaluation`::
  34. (Required, object) Defines the type of evaluation you want to perform. For example:
  35. `binary_soft_classification`. See <<ml-evaluate-dfanalytics-resources>>.
  36. ////
  37. [[ml-evaluate-dfanalytics-results]]
  38. ==== {api-response-body-title}
  39. `binary_soft_classification`::
  40. (object) If you chose to do binary soft classification, the API returns the
  41. following evaluation metrics:
  42. `auc_roc`::: TBD
  43. `confusion_matrix`::: TBD
  44. `precision`::: TBD
  45. `recall`::: TBD
  46. ////
  47. [[ml-evaluate-dfanalytics-example]]
  48. ==== {api-examples-title}
  49. [source,js]
  50. --------------------------------------------------
  51. POST _ml/data_frame/_evaluate
  52. {
  53. "index": "my_analytics_dest_index",
  54. "evaluation": {
  55. "binary_soft_classification": {
  56. "actual_field": "is_outlier",
  57. "predicted_probability_field": "ml.outlier_score"
  58. }
  59. }
  60. }
  61. --------------------------------------------------
  62. // CONSOLE
  63. // TEST[skip:TBD]
  64. The API returns the following results:
  65. [source,js]
  66. ----
  67. {
  68. "binary_soft_classification": {
  69. "auc_roc": {
  70. "score": 0.92584757746414444
  71. },
  72. "confusion_matrix": {
  73. "0.25": {
  74. "tp": 5,
  75. "fp": 9,
  76. "tn": 204,
  77. "fn": 5
  78. },
  79. "0.5": {
  80. "tp": 1,
  81. "fp": 5,
  82. "tn": 208,
  83. "fn": 9
  84. },
  85. "0.75": {
  86. "tp": 0,
  87. "fp": 4,
  88. "tn": 209,
  89. "fn": 10
  90. }
  91. },
  92. "precision": {
  93. "0.25": 0.35714285714285715,
  94. "0.5": 0.16666666666666666,
  95. "0.75": 0
  96. },
  97. "recall": {
  98. "0.25": 0.5,
  99. "0.5": 0.1,
  100. "0.75": 0
  101. }
  102. }
  103. }
  104. ----
  105. // TESTRESPONSE