> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebase.energy/llms.txt
> Use this file to discover all available pages before exploring further.

# How to train ML models

> Trigger the training of a site's ML forecast models

When you [upload](/api-guides/upload-power) the generation or consumption data to a site, a set of preconfigured machine learning (ML) models is created.
To start the training procedure of these models, you will need to provide a number of training parameters.
Currently the following parameters are supported.

**Site IDs** `site_ids`
<br /> Specify a list of site IDs for which ML models will be trained.
<br /> Example: `["8fa9ef1d-4s89-4waf-8g52-b1aww743by47"]`

**Training set splits** `splits`
<br /> Specify the starting and ending dates for the training data set splits. The ML model is trained only on the specific periods.
By making use of this parameter it is possible to exclude periods with low quality training data, e.g. curtailment or maintenance periods, outliers, etc.
<br /> If `splits` is omitted, then the whole training data set is used for training.

* **Starting period** `start_date`
  <br /> Specify the starting timestamp.
  <br /> Example: `"2022-01-01T00:00Z"`

* **Ending period** `end_date`
  <br /> Specify the ending timestamp.
  <br /> Example: `"2022-12-31T23:00Z"`

```python Train models theme={null}
import requests

api_key = "Your API key" # Set your API key

payload = {
    "site_ids": ["8fa9ef1d-4s89-4waf-8g52-b1aww743by47"], # Set the sites IDs
    "splits": [
        {
            "start_date": "2022-01-01T00:00Z",
			"end_date": "2022-12-31T23:00Z"
        },
        {
            "start_date": "2024-01-01T00:00Z",
			"end_date": "2024-06-30T23:00Z"
        }		
    ]
}

url = "https://api.rebase.energy/platform/v2/sites/models/train"
headers = {"Authorization": api_key, "Content-Type": "application/json"}			

response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
response = response.json()
```

The response message informs that the training process has started. This can take some time depending on the number of the sites, and the size of the training sets.

```python Response example theme={null}
{
    "message": "Training started"
}
```
