07 Univariate anomaly detection - gloveboxes/HealthySpacesAnomalyDetection GitHub Wiki

Detecting anomalies with Azure Anomaly Detection Univariate API

In this unit you will create an Azure Anomaly Detection API service, and install support for Jupyter Notebooks.

To learn more about Azure Anomaly Detector API, refer to the Anomaly Detector API Documentation.

Generate workspace health data

The Azure Sphere Healthy workspaces app generates data for anomaly detection.

Create an Anomaly Detector resource in Azure portal

Install Jupyter notebook support

Ensure that you have the latest pip; older versions may have trouble with some dependencies:

  1. Download and install Python3 from python.org

  2. Update to the latest pip

    python.exe -m pip install --upgrade pip
    
  3. Install required Python libraries

    pip3 install jupyter pandas numpy bokeh ipywidgets azure.storage.blob matplotlib
    
  4. Install Visual Studio Code Python Extension

References:

Open the Anomaly Detector Jupyter Notebook

From Visual Studio Code, open the Altair8800/AnomalyDetector/AnomalyDetection.ipynb file.

Configure the Anomaly Detector Jupyter Notebook

You need to update the following variables in the first Jupyter Notebook cell.

apikey = "REPLACE_WITH_YOUR_AZURE_ANOMALY_DETECTOR_API_KEY"
endpoint = "REPLACE_WITH_YOUR_AZURE_ANOMALY_DETECTOR_API_ENDPOINT"
device_id = "REPLACE_WITH_YOUR_IOT_CENTRAL_DEVICE_ID"
blob_conn_str="REPLACE_WITH_YOUR_STORAGE_ACCOUNT_CONNECTION_STRING"

Blob filter

blob_filter = "REPLACE_WITH_YOUR_BLOB_FILTER/"

blob_filter = "d89eef5e-6e74-43cf-aa04-2f36e81b91da/25/2022/07/19/"

Run the Anomaly Detector Jupyter Notebook

Select Run All from the Jupyter Notebook menu.

The image shows where the Run All button is displayed in VS Code

The Jupyter Notebook will take approx 2 to 5 minutes to execute depending on how long you have been running the CO2 monitor for and what level of filtering you are using.

When the Jupyter Notebook has completed, a chart similar to the following image will be displayed.

CO2 Anomaly Chart

The image shows the output from from running the Anomaly Detector Jupyter Notebook.

References

  1. How to spot time-series issues in real-time with Anomaly Detection

  2. Identify abnormal time-series data with Anomaly Detector

  3. https://docs.microsoft.com/en-us/learn/modules/identify-abnormal-time-series-data-anomaly-detector/4-exercise-send-data-to-cloud

Install Azure Storage Explorer

  1. Install Azure Storage Explorer.
  2. Sign in to Storage Explorer