{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "52af59bb-083c-46c6-989a-bd4c65137a1a", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "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": "d6fc731f-3f50-4e9a-a24c-b2ab01d4fa31", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "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": "670316b8-460c-4009-a5da-94278f4ac9a9", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "status": "completed" }, "tags": [] }, "source": [ "# Time Series\n", "\n", "a `TimeSeries` is the basic object in onTime. It is basically an extended version of Darts TimeSeries. Therefore, it is multivariate by default and all Darts methods can be used." ] }, { "cell_type": "markdown", "id": "831f1944-599b-4761-a071-2a682346610a", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "status": "completed" }, "tags": [] }, "source": [ "## Get some data\n", "\n", "Let's generate a random walk time series" ] }, { "cell_type": "code", "execution_count": 4, "id": "ef3e03e1-c247-4b5a-a27a-a13361e673b0", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "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": "markdown", "id": "52f41907-8b48-4427-8a44-5f45ab6196b0", "metadata": {}, "source": [ "The TimeSeries can be sliced and its data structure is an xarray." ] }, { "cell_type": "code", "execution_count": 5, "id": "01962643-33af-4adf-8bfa-7d0163e4e41c", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
<TimeSeries (DataArray) (time: 5, component: 1, sample: 1)>\n", "array([[[-0.36981256]],\n", "\n", " [[-1.89552543]],\n", "\n", " [[-3.58416814]],\n", "\n", " [[-4.19590597]],\n", "\n", " [[-3.08642833]]])\n", "Coordinates:\n", " * time (time) datetime64[ns] 2022-01-01 2022-01-02 ... 2022-01-05\n", " * component (component) object 'random_walk'\n", "Dimensions without coordinates: sample\n", "Attributes:\n", " static_covariates: None\n", " hierarchy: None