{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "9286e0b8-3c78-4b0f-943c-d219e9840dfe", "metadata": { "papermill": { "duration": 0.014825, "end_time": "2024-01-31T17:50:26.847199", "exception": false, "start_time": "2024-01-31T17:50:26.832374", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Import to be able to import python package from src\n", "import sys\n", "sys.path.insert(0, '../src')" ] }, { "cell_type": "code", "execution_count": 3, "id": "2028eed7-b1c3-4c9e-b6a0-00433caa7d0f", "metadata": { "papermill": { "duration": 2.515115, "end_time": "2024-01-31T17:50:29.365394", "exception": false, "start_time": "2024-01-31T17:50:26.850279", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "The `LightGBM` module could not be imported. To enable LightGBM support in Darts, follow the detailed instructions in the installation guide: https://github.com/unit8co/darts/blob/master/INSTALL.md\n", "The `Prophet` module could not be imported. To enable Prophet support in Darts, follow the detailed instructions in the installation guide: https://github.com/unit8co/darts/blob/master/INSTALL.md\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "import ontime as on" ] }, { "cell_type": "markdown", "id": "41296cc6-9d84-47c5-8a92-2d292f6f3c4a", "metadata": { "papermill": { "duration": 0.008378, "end_time": "2024-01-31T17:50:26.827798", "exception": false, "start_time": "2024-01-31T17:50:26.819420", "status": "completed" }, "tags": [] }, "source": [ "# Detectors" ] }, { "cell_type": "markdown", "id": "48992359-bd13-4347-8344-8bfb42fb126c", "metadata": {}, "source": [ "Detectors allow you to get a signal given a condition. The condition can be :\n", "\n", "- an absolute threshold or,\n", "- a statistical threshold with a quantile.\n", "\n", "Let's make an example." ] }, { "cell_type": "markdown", "id": "e24da8ab-6a83-4c2f-9ff0-c633d4693a91", "metadata": { "papermill": { "duration": 0.001714, "end_time": "2024-01-31T17:50:29.375771", "exception": false, "start_time": "2024-01-31T17:50:29.374057", "status": "completed" }, "tags": [] }, "source": [ "## Generate a TimeSeries\n", "\n", "This is only to have some data for the purpose of the example." ] }, { "cell_type": "code", "execution_count": 4, "id": "e9a96d79-0423-4d79-b01d-726193216238", "metadata": { "papermill": { "duration": 0.006608, "end_time": "2024-01-31T17:50:29.384080", "exception": false, "start_time": "2024-01-31T17:50:29.377472", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "ts = on.generators.random_walk().generate(start=pd.Timestamp('2022-01-01'), end=pd.Timestamp('2022-12-31'))" ] }, { "cell_type": "code", "execution_count": 5, "id": "d463df9c-4f02-4c1e-b1a5-7162b9ea8c63", "metadata": { "papermill": { "duration": 0.009125, "end_time": "2024-01-31T17:50:29.394914", "exception": false, "start_time": "2024-01-31T17:50:29.385789", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
<TimeSeries (DataArray) (time: 3, component: 1, sample: 1)>\n", "array([[[-0.00377122]],\n", "\n", " [[ 0.40349093]],\n", "\n", " [[ 2.47072711]]])\n", "Coordinates:\n", " * time (time) datetime64[ns] 2022-01-01 2022-01-02 2022-01-03\n", " * component (component) object 'random_walk'\n", "Dimensions without coordinates: sample\n", "Attributes:\n", " static_covariates: None\n", " hierarchy: None
\n", " | Timestamp | \n", "Description | \n", "Value | \n", "
---|---|---|---|
0 | \n", "2022-01-01 | \n", "QuantileDetector | \n", "True | \n", "
1 | \n", "2022-01-02 | \n", "QuantileDetector | \n", "False | \n", "
2 | \n", "2022-01-03 | \n", "QuantileDetector | \n", "False | \n", "
3 | \n", "2022-01-04 | \n", "QuantileDetector | \n", "False | \n", "
4 | \n", "2022-01-05 | \n", "QuantileDetector | \n", "False | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "
360 | \n", "2022-12-27 | \n", "QuantileDetector | \n", "False | \n", "
361 | \n", "2022-12-28 | \n", "QuantileDetector | \n", "False | \n", "
362 | \n", "2022-12-29 | \n", "QuantileDetector | \n", "False | \n", "
363 | \n", "2022-12-30 | \n", "QuantileDetector | \n", "False | \n", "
364 | \n", "2022-12-31 | \n", "QuantileDetector | \n", "False | \n", "
365 rows × 3 columns
\n", "