Live Anomaly Detection

Running the AI via the web interface or API is useful, but it's slow. Every request has to load, run and unload the AI on the server, which takes a considerable amount of time.

If you want to have live alerts or feedback from your anomaly detector, you can instead download your model and run it via our modelhost system.

This keeps the AI in memory and re-runs the model whenever there's changes in the state of your assets, giving you up-to-the-second anomaly detection.

It also lets you use the information in a variety of places, making it available via OPC-UA, MQTT, Prometheus, REDIS, write it to databases etc.

Downloading your Model

When signed in as an Administrator, open the dashboard for the asset and click AI Anomaly Detector.

Click Live Model.

Then click Download Model Files.

This will give you a ZIP file containing the Python tools required to run your AI model live. This can be run on your ARDI server, or on any other system that has access to the ARDI server (ie, you might have a dedicated AI system).

Running your Model

You run your model by launching model.py in Python.

On linux, this can be done with the following command…

python3 model.py

or in Windows by running run.bat. If you don't have Python in your PATH, you might need to edit the run.bat file to give it the path to your installation of Python.

Viewing Outputs

You can view the outputs of your model using an OPC-UA client, such as UAExpert on Windows. The default port for the model is 5555 - when running on the local machine, the full address will be opc-tcp:/ /localhost:5555.

You'll have the following values…

PathUsage
<asset_name> Anomaly Detector/Constants/* ToleranceDifference thresholds for each property
<asset_name> Anomaly Detector/Inputs/*The real-world, live values for each property
<asset_name> Anomaly Detector/Outputs/Model *The output/modelled values for each property
<asset_name> Anomaly Detector/Outputs/* Error0 if the signal is normal, otherwise 1
<asset_name> Anomaly Detector/Outputs/Anomaly0 if the asset is normal, otherwise 1

For instance, if your asset was named 'Motor 1' and had the property 'Temperature', your OPC-UA output would include…

Motor 1 Anomaly Detector/Constants/Temperature Tolerance
Motor 1 Anomaly Detector/Inputs/Temperature
Motor 1 Anomaly Detector/Outputs/Model Temperature
Motor 1 Anomaly Detector/Outputs/Temperature Error
Motor 1 Anomaly Detector/Outputs/Anomaly

If the model temperature is ever more than temperature tolerance away from the real-world temperature, both the temperature error and anomaly values will be '1'.

Merging Multiple Models

Although you will download the models individually, it's possible to combine each of your anomaly detector AIs into a single, common script. This will make them all available from the one OPC-UA server, making it much simpler to record data and feed it back into ARDI or your control system(s).

Your model.py file will contain several functions.

AnyTrue and ExecuteModel are always exactly the same, so you only need to include them once in your shared script.

The AnomalyXXX function (for example, asset #12 will have a function called Anomaly12) can be copied into a common script. Remember to include the decoration (the line beginning with '@') as well.

This combined script can then be run as a service, giving you a constantly-running library of live anomaly detector AIs that can communicate directly with industrial systems.