How to build an ML Model.
Tutorials → Technology Learning Tutorial → ML.NET Tutorial | Concept | How-to Guide | Reference
This Tutorial Teaches you to:
This tutorial demonstrates how to use machine learning for real-time anomaly detection on sensor data using FrameworX Script Classes.
Prerequisites:
Step 1: Create Tag
In Unified Namespace → Tags create the following tag
Name | Type | Array |
|---|---|---|
AnomalyBuffer | Text | 9 |
Step 2: Create Value Simulator
With these tags created: Pressure (Integer) and AnomalyBuffer (Text Array 9 position)
In Devices → Protocols, select the Value Simulator and click the "New Channel..." button.
In Devices → Points, create points to generate simulated data.
TagName | Node | Address | DataType | AccessType |
|---|---|---|---|---|
Tag.Pressure | Node.ValueSimulator1Node1 | INTEGER:0,100,1 | Native | AccessType.Read |
For more information about the Value Simulator, see: Value Simulator Connector
Step 3: Create ML Anomaly Detection Script Class
Navigate to Scripts → Classes
Click the "Create a New Class" button
In "Import code from Library:", select AnomalyML
Open the script and uncomment the line that returns the detection to the AnomalyBuffer tag in Check() method.
Step 4: Create an Expression
This expression will check for anomalies each time the tag value changes.
Go to Scripts → Expressions
Create the following expression:
ObjectName | Expression | Execution |
|---|---|---|
Script.Class.AnomalyML.Check(<DesiredTag>) | OnChange |
Where:
<DesiredTag> is the tag you want to monitor for anomalies
Example:
ObjectName | Expression | Execution |
|---|---|---|
Script.Class.AnomalyML.Check(Tag.Pressure) | OnChange |
Step 5: Test the System
Go in Runtime → “Run Startup”
Wait a couple minutes to have some data in the model.
Open the PropertyWatch
See the values in the AnomalyBuffer, to see the predictions.
In this section...