Use the Anomaly Detection Function
The Anomaly Detection function applies the three-sigma rule to identify outliers by comparing data points against a dynamic threshold of standard deviations from the mean, allowing for real-time adjustment to emerging patterns.
This function operates by maintaining a rolling window of data, calculating the average and standard deviation within this window, and flagging values that deviate beyond the user-defined standard deviation range as anomalies.
Review the following scenario for the anomaly detection processor function. Then, using an input processor, you will simulate PLC data and detect anomalies from the window of generated values.
In a large-scale manufacturing factory, the Anomaly Detection function is used to monitor the machine's temperatures. It calculates a moving average and standard deviation of temperature readings, flagging any readings that significantly deviate as potential cooling system failures. By defining the number of standard deviations from the average as the threshold for normal operation, factory engineers can quickly identify and respond to overheating risks, ensuring site reliability and uptime.
Follow the steps to Connect a Device and configure the following parameters:
- Device Type: Simulator
- Driver Name: Generator
- Enable Alias Topics: Select the checkbox.
After connecting the device, add the following tag. See Add Tags to learn more.
- Name: Select S - Random value generator
- Value Type: Select float64
- Polling Interval: Enter 1
- Tag Name: Enter input1
- Min_value: Enter 1
- Max_value: Enter 50
You can now create the analytics flows using data from the device and tag you previously created.
To create an analytics flow with the Anomaly Detection Processor function:
- In Manufacturing Connect Edge, navigate to Analytics.
On the analytics canvas, click Add processor. The Create a processor dialog box displays.
- Select DataHub Subscribe.
In the Topic field, click the Search icon, select the device you previously created, and then select the alias topic for the input1 tag.
- Click Save.
- Click Add processor again and select the Anomaly Detection processor. The following information defines this function:
- Window Size: Enter a value that represents the range to observe before making each prediction. For this example, we input a value of 100.
- Deviations: Enter the number of standard deviations that would be considered normal, making everything outside that definition anomalous data. For this example, we input a value of 3.
- Topic Reset: Enable this option to reset the function on topic change.
- Control Chart Mode: If this option is enabled, there will be no modifications done to the moving window before calculation.
Click Save.
- Connect the DataHub Subscribe processor (tag: input1) to the Anomaly Detection processor with a wire and use the events connection.
On the analytics canvas, click Save. The configured analytics flows should look like the following:
Click the View icon in the Anomaly Detection processor to view the output values.
The output describes a situation where the current value of 1.86 is well above the lower limit of 0.13 and below the upper limit of approximately 2.33, suggesting no anomaly is detected at this timestamp within the moving average of 1.23 and a standard deviation of 0.36.