Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capabilities notebooks #312

Merged
merged 16 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions nbs/docs/2_capabilities/anomaly_detection/01_quickstart.ipynb

Large diffs are not rendered by default.

171 changes: 171 additions & 0 deletions nbs/docs/2_capabilities/anomaly_detection/02_confidence_levels.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

173 changes: 173 additions & 0 deletions nbs/docs/2_capabilities/anomaly_detection/04_anomaly_exogenous.ipynb

Large diffs are not rendered by default.

166 changes: 166 additions & 0 deletions nbs/docs/2_capabilities/forecast/01_quickstart.ipynb

Large diffs are not rendered by default.

139 changes: 139 additions & 0 deletions nbs/docs/2_capabilities/forecast/02_holidays_special_dates.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Add holidays and special dates"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 1: Create an instance of `NixtlaClient`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from nixtla import NixtlaClient"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"nixtla_client = NixtlaClient(\n",
" # defaults to os.environ.get(\"NIXTLA_API_KEY\")\n",
" api_key = 'my_api_key_provided_by_nixtla'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"from dotenv import load_dotenv"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"load_dotenv()\n",
"nixtla_client = NixtlaClient()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 2: Get country holidays"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from nixtla.date_features import CountryHolidays"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"c_holidays = CountryHolidays(countries=['US'])\n",
"periods = 365 * 1\n",
"dates = pd.date_range(end='2023-09-01', periods=periods)\n",
"holidays_df = c_holidays(dates)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 3: Specify special dates"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from nixtla.date_features import SpecialDates"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"special_dates = SpecialDates(\n",
" special_dates={\n",
" 'Important Dates': ['2021-02-26', '2020-02-26'],\n",
" 'Very Important Dates': ['2021-01-26', '2020-01-26', '2019-01-26']\n",
" }\n",
")\n",
"periods = 365 * 1\n",
"dates = pd.date_range(end='2023-09-01', periods=periods)\n",
"special_dates_df = special_dates(dates)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
145 changes: 145 additions & 0 deletions nbs/docs/2_capabilities/forecast/03_exogenous_variables.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Add exogenous variables"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 1: Create an instance of `NixtlaClient`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from nixtla import NixtlaClient"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"nixtla_client = NixtlaClient(\n",
" # defaults to os.environ.get(\"NIXTLA_API_KEY\")\n",
" api_key = 'my_api_key_provided_by_nixtla'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"from dotenv import load_dotenv"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"load_dotenv()\n",
"nixtla_client = NixtlaClient()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 2: Load data with exogenous variables"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-with-ex-vars.csv')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 3: Load dataset with future values of exogenous variables"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"future_ex_vars_df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-future-ex-vars.csv')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 4: Forecast"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:nixtla.nixtla_client:Validating inputs...\n",
"INFO:nixtla.nixtla_client:Preprocessing dataframes...\n",
"INFO:nixtla.nixtla_client:Inferred freq: H\n",
"INFO:nixtla.nixtla_client:Using the following exogenous variables: Exogenous1, Exogenous2, day_0, day_1, day_2, day_3, day_4, day_5, day_6\n",
"INFO:nixtla.nixtla_client:Calling Forecast Endpoint...\n"
]
}
],
"source": [
"forecast_df = nixtla_client.forecast(\n",
" df=df, \n",
" X_df=future_ex_vars_df, \n",
" h=24,\n",
" id_col='unique_id',\n",
" target_col='y',\n",
" time_col='ds'\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading