08 Multivariate anomaly detection - gloveboxes/HealthySpacesAnomalyDetection GitHub Wiki

Detecting anomalies with Azure Anomaly Detection Multivariate API

In this unit you will run the climate anomaly BASIC application, 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 climate data with anomalies

Climate change is gradual. To generate a climate change data set run the following BASIC application from the Altair web terminal for at least two hours. The anomaly application will generate climate data, injecting some some random temperate data which will be detected by the Azure Anomaly Detector API service.

mbasic anomaly

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

    pip3 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"

Run the Anomaly Detector Jupyter Notebook

Select Run All from the Jupyter Notebook memu.

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 anomaly BASIC application.

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

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