--- 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 ![mlmodel][mlmodel] The task `ML Prediction` is a Task that calculates a prediction based on an ML Model and returns its result. ![mlprediction_01][mlprediction_01] ## Settings On the `General` Tab, you have the usual settings and the following options settings: | Name | Data Type | Values | Default | Description | | ------------- | --------- | -------- | -------- | ------------------------------------------------------------ | | ML Model | `ML Model` | | **ML Model** entity from MES | | IoT Event Definition | `IoT Event Definition` | | **IoT Event Definition** entity from MES | ![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 | Values | 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 | Values | 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. [mlmodel]: ./images/mlmodel-lg.svg [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