102 lines
1.8 KiB
Markdown
102 lines
1.8 KiB
Markdown
---
|
|
layout: default
|
|
title: Predict
|
|
parent: Train and Predict APIs
|
|
grand_parent: ML Commons APIs
|
|
nav_order: 20
|
|
---
|
|
|
|
# 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]({{site.url}}{{site.baseurl}}/ml-commons-plugin/api/model-apis/index/#model-access-control-considerations).
|
|
|
|
## Path and HTTP methods
|
|
|
|
```json
|
|
POST /_plugins/_ml/_predict/<algorithm_name>/<model_id>
|
|
```
|
|
|
|
#### Example request
|
|
|
|
```json
|
|
POST /_plugins/_ml/_predict/kmeans/<model-id>
|
|
{
|
|
"input_query": {
|
|
"_source": ["petal_length_in_cm", "petal_width_in_cm"],
|
|
"size": 10000
|
|
},
|
|
"input_index": [
|
|
"iris_data"
|
|
]
|
|
}
|
|
```
|
|
{% include copy-curl.html %}
|
|
|
|
#### Example response
|
|
|
|
```json
|
|
{
|
|
"status" : "COMPLETED",
|
|
"prediction_result" : {
|
|
"column_metas" : [
|
|
{
|
|
"name" : "ClusterID",
|
|
"column_type" : "INTEGER"
|
|
}
|
|
],
|
|
"rows" : [
|
|
{
|
|
"values" : [
|
|
{
|
|
"column_type" : "INTEGER",
|
|
"value" : 1
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"values" : [
|
|
{
|
|
"column_type" : "INTEGER",
|
|
"value" : 1
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"values" : [
|
|
{
|
|
"column_type" : "INTEGER",
|
|
"value" : 0
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"values" : [
|
|
{
|
|
"column_type" : "INTEGER",
|
|
"value" : 0
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"values" : [
|
|
{
|
|
"column_type" : "INTEGER",
|
|
"value" : 0
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"values" : [
|
|
{
|
|
"column_type" : "INTEGER",
|
|
"value" : 0
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
```
|