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
- Create an Azure subscription if you don't have one - Create one for free
- Once you have your Azure subscription, create an Anomaly Detector resource in the Azure portal to get your API key and API endpoint.
Install Jupyter notebook support
Ensure that you have the latest pip; older versions may have trouble with some dependencies:
-
Download and install Python3 from python.org
-
Update to the latest pip
python.exe -m pip install --upgrade pip -
Install required Python libraries
pip3 install jupyter pandas numpy bokeh ipywidgets azure.storage.blob matplotlib -
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 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

References
Install Azure Storage Explorer
- Install Azure Storage Explorer.
- Sign in to Storage Explorer