evaluate-dfanalytics.asciidoc 2.5 KB

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