mirror of
https://github.com/iSharkFly-Docs/opensearch-docs-cn
synced 2025-03-09 14:38:01 +00:00
* Refactor ML section - local and remote models Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added command to calculate checksum Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add ONNX format to register API Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add sparse encoding predict example Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add API section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Refactor the API section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Typo Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented Vale comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add get connector API Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Reword heading Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Addressed tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com>
82 lines
1.5 KiB
Markdown
82 lines
1.5 KiB
Markdown
---
|
|
layout: default
|
|
title: Train
|
|
parent: Train and Predict APIs
|
|
grand_parent: ML Commons API
|
|
has_children: true
|
|
nav_order: 10
|
|
---
|
|
|
|
# Train
|
|
|
|
The train API operation trains a model based on a selected algorithm. Training can occur both synchronously and asynchronously.
|
|
|
|
#### Example request
|
|
|
|
The following examples use the k-means algorithm to train index data.
|
|
|
|
**Train with k-means synchronously**
|
|
|
|
```json
|
|
POST /_plugins/_ml/_train/kmeans
|
|
{
|
|
"parameters": {
|
|
"centroids": 3,
|
|
"iterations": 10,
|
|
"distance_type": "COSINE"
|
|
},
|
|
"input_query": {
|
|
"_source": ["petal_length_in_cm", "petal_width_in_cm"],
|
|
"size": 10000
|
|
},
|
|
"input_index": [
|
|
"iris_data"
|
|
]
|
|
}
|
|
```
|
|
{% include copy-curl.html %}
|
|
|
|
**Train with k-means asynchronously**
|
|
|
|
```json
|
|
POST /_plugins/_ml/_train/kmeans?async=true
|
|
{
|
|
"parameters": {
|
|
"centroids": 3,
|
|
"iterations": 10,
|
|
"distance_type": "COSINE"
|
|
},
|
|
"input_query": {
|
|
"_source": ["petal_length_in_cm", "petal_width_in_cm"],
|
|
"size": 10000
|
|
},
|
|
"input_index": [
|
|
"iris_data"
|
|
]
|
|
}
|
|
```
|
|
{% include copy-curl.html %}
|
|
|
|
#### Example response
|
|
|
|
**Synchronous**
|
|
|
|
For synchronous responses, the API returns the `model_id`, which can be used to get or delete a model.
|
|
|
|
```json
|
|
{
|
|
"model_id" : "lblVmX8BO5w8y8RaYYvN",
|
|
"status" : "COMPLETED"
|
|
}
|
|
```
|
|
|
|
**Asynchronous**
|
|
|
|
For asynchronous responses, the API returns the `task_id`, which can be used to get or delete a task.
|
|
|
|
```json
|
|
{
|
|
"task_id" : "lrlamX8BO5w8y8Ra2otd",
|
|
"status" : "CREATED"
|
|
}
|
|
``` |