---
alias: user-guide-automation-task-dataplatform-mlprediction
tags:
- automation tasks
description: "This task calculates ML predictions using an ML Model and IoT event data"
---
# ML Prediction
:core-entitytypes-mlmodel-lg:{style="font-size: 100px"}
The task `ML Prediction` is a Task that calculates a prediction based on an ML Model and returns its result.
![mlprediction_01][mlprediction_01]
## Details
| Fields | Details |
| ----------------- | ---------------------------------------------------------------------------------- |
| Scope | Connect IoT
Factory Automation
Enterprise Integration
Data Platform |
| Workflow | Data flow
Control flow |
| `IsProtocol` flag | :material-close:{ style="color: #EF5350" } |
## Settings
On the `General` Tab, you have the usual settings and the following options settings:
| Name | Data Type | Default | Description |
| ------------- | --------- | -------- | ------------------------------------------------------------ |
| ML Model | `ML Model` | | **ML Model** entity from MES |
| IoT Event Definition | `IoT Event Definition` | |**IoT Event Definition** entity from MES |
| Endpoint| String | `http://mlplatformagent:8080` | **ML Model** Prediction Endpoint |
![mlprediction_02][mlprediction_02]
If an IoT Event Definition is selected, the `Inputs` Tab will be hidden and the `Features` Tab will show up. In there you need to map the IoT Event Definition Properties to the ML Model Features:
![mlprediction_03][mlprediction_03]
## Inputs
The inputs depend on the ML Model that was selected and on whether or not an IoT Event Definition was selected.
| Name | Data Type | Description |
| ------------ | --------- | ------------------------------------------ |
| iotEvent | `string` | The whole event. Appears when an IoT Event Definition was selected |
| eventId | `string` | The Id of the Event. Appears when no IoT Event Definition was selected |
| FeatureNames | `string` | An input for each Feature of the ML Model. Appears when no IoT Event Definition was selected |
| Activate | `Any` | Activates the task execution |
If no IoT Event Definition was selected, there will be an input for the Event Id and an input for each Feature:
![mlprediction_04][mlprediction_04]
If an IoT Event Definition was selected, there will be an input for the whole Event:
![mlprediction_05][mlprediction_05]
## Outputs
| Name | Data Type | Description |
| -------- | --------- | ---------------------------------------------------------- |
| result | `any` | The full result of the prediction. Includes info about the ML Model version that was used |
|prediction| `any` | The prediction itself. The data type depends on the ML Model Type |
| score | `Decimal` | The score of the prediction. This might be hidden depending on the ML Model Type |
| Success | `Boolean` | If there was no problem emits a true |
| Error | `Error` | Error that occurred during the processing of this task |
## Behavior
The task is used to calculate a prediction based on an **ML Model** when an **IoT Event** is received.
## Remarks
This tasks has **2 modes** depending on whether or not an **IoT Event Definition** is selected in the settings.
[mlprediction_01]: ./images/mlprediction_01.png
[mlprediction_02]: ./images/mlprediction_02.png
[mlprediction_03]: ./images/mlprediction_03.png
[mlprediction_04]: ./images/mlprediction_04.png
[mlprediction_05]: ./images/mlprediction_05.png