Predict

ML Commons can predict new data with your trained model either from indexed data or a data frame. To use the Predict API, the model_id is required.

For information about user access for this API, see Model access control considerations.

Path and HTTP methods

  1. POST /_plugins/_ml/_predict/<algorithm_name>/<model_id>

Example request

  1. POST /_plugins/_ml/_predict/kmeans/<model-id>
  2. {
  3. "input_query": {
  4. "_source": ["petal_length_in_cm", "petal_width_in_cm"],
  5. "size": 10000
  6. },
  7. "input_index": [
  8. "iris_data"
  9. ]
  10. }

copy

Example response

  1. {
  2. "status" : "COMPLETED",
  3. "prediction_result" : {
  4. "column_metas" : [
  5. {
  6. "name" : "ClusterID",
  7. "column_type" : "INTEGER"
  8. }
  9. ],
  10. "rows" : [
  11. {
  12. "values" : [
  13. {
  14. "column_type" : "INTEGER",
  15. "value" : 1
  16. }
  17. ]
  18. },
  19. {
  20. "values" : [
  21. {
  22. "column_type" : "INTEGER",
  23. "value" : 1
  24. }
  25. ]
  26. },
  27. {
  28. "values" : [
  29. {
  30. "column_type" : "INTEGER",
  31. "value" : 0
  32. }
  33. ]
  34. },
  35. {
  36. "values" : [
  37. {
  38. "column_type" : "INTEGER",
  39. "value" : 0
  40. }
  41. ]
  42. },
  43. {
  44. "values" : [
  45. {
  46. "column_type" : "INTEGER",
  47. "value" : 0
  48. }
  49. ]
  50. },
  51. {
  52. "values" : [
  53. {
  54. "column_type" : "INTEGER",
  55. "value" : 0
  56. }
  57. ]
  58. }
  59. ]
  60. }
  61. }