This is supported by European Metrology Programme for Innovation and Research (EMPIR) under the project Metrology for the Factory of the Future (Met4FoF), project number 17IND12.
With the provided code we showcase an agent-based machine learning approach for online anomaly detection of (in our case simulated) sensor readings.
In case you are using PyCharm, you will already find proper run configurations at the appropriate place in the IDE. It expects that you have prepared and defined a default interpreter.
If you are not using PyCharm, of course you can run the script files as usual.
If you have any questions please get in touch with the author.
To install all dependencies in virtual environment based on Python version 3.7 first
install pip-tools
and afterwards use our prepared requirements.txt
to get
everything ready.
In your Windows command prompt execute the following to set up a virtual environment in a folder of your choice.
> python -m venv my_anomaly_detection_use_case_env
> my_anomaly_detection_use_case_env\Scripts\activate.bat
(my_anomaly_detection_use_case_env) > pip install --upgrade pip setuptools pip-tools
(my_anomaly_detection_use_case_env) > pip-sync
In your terminal execute the following to set up a virtual environment in a folder of your choice.
$ python3.7 -m venv my_anomaly_detection_use_case_env
$ source my_anomaly_detection_use_case_env/bin/activate
(my_anomaly_detection_use_case_env) $ pip install --upgrade pip setuptools pip-tools
(my_anomaly_detection_use_case_env) $ pip-sync
The interesting parts you find in the file
agentMET4FOF_anomaly_detection/anomaly_detection.py
In the event of agents not terminating cleanly, you can end all Python processes running on your system (caution: the following commands affect all running Python processes, not just those that emerged from the agents).
In your Windows command prompt execute the following to terminate all python processes.
> taskkill /f /im python.exe /t
>
In your terminal execute the following to terminate all python processes.
$ pkill python
$
For details about the agents refer to the upstream repository agentMET4FOF
For development and testing you should as well install the development dependencies provided in the dev-requirements.txt for Python 3.8 as well.
$ source my_anomaly_detection_use_case_env/bin/activate
(my_anomaly_detection_use_case_env) $ pip-sync dev-requirements.txt requirements.txt
You will find another run configuration for the test suite in your PyCharm IDE.