Skip to content

Commit

Permalink
polars support (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez authored Nov 27, 2023
1 parent 8884097 commit adccb2f
Show file tree
Hide file tree
Showing 15 changed files with 567 additions and 364 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
run: pip install ./

- name: Tests
run: nbdev_test --do_print --timing --n_workers 1
run: nbdev_test --do_print --timing --n_workers 0 --flags polars
5 changes: 3 additions & 2 deletions action_files/test_models/src/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytorch_lightning as pl
import torch

import neuralforecast
from neuralforecast.core import NeuralForecast

from neuralforecast.models.gru import GRU
Expand Down Expand Up @@ -34,6 +35,8 @@

from src.data import get_data

neuralforecast.config.id_as_index = False


def main(dataset: str = 'M3', group: str = 'Monthly') -> None:
train, horizon, freq, seasonality = get_data('data/', dataset, group)
Expand Down Expand Up @@ -82,7 +85,6 @@ def main(dataset: str = 'M3', group: str = 'Monthly') -> None:
end = time.time()
print(end - start)

forecasts = forecasts.reset_index()
forecasts.columns = ['unique_id', 'ds', model_name]
forecasts.to_csv(f'data/{model_name}-forecasts-{dataset}-{group}.csv', index=False)
time_df = pd.DataFrame({'time': [end - start], 'model': [model_name]})
Expand All @@ -97,7 +99,6 @@ def main(dataset: str = 'M3', group: str = 'Monthly') -> None:
end = time.time()
print(end - start)

forecasts = forecasts.reset_index()
forecasts = forecasts[['unique_id', 'ds', 'DeepAR-median']]
forecasts.columns = ['unique_id', 'ds', 'DeepAR']
forecasts.to_csv(f'data/{model_name}-forecasts-{dataset}-{group}.csv', index=False)
Expand Down
4 changes: 3 additions & 1 deletion action_files/test_models/src/models2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytorch_lightning as pl
import torch

import neuralforecast
from neuralforecast.core import NeuralForecast

from neuralforecast.models.gru import GRU
Expand Down Expand Up @@ -34,6 +35,8 @@

from src.data import get_data

neuralforecast.config.id_as_index = False


def main(dataset: str = 'M3', group: str = 'Monthly') -> None:
train, horizon, freq, seasonality = get_data('data/', dataset, group)
Expand Down Expand Up @@ -81,7 +84,6 @@ def main(dataset: str = 'M3', group: str = 'Monthly') -> None:
end = time.time()
print(end - start)

forecasts = forecasts.reset_index()
forecasts.columns = ['unique_id', 'ds', model_name]
forecasts.to_csv(f'data/{model_name}-forecasts-{dataset}-{group}.csv', index=False)
time_df = pd.DataFrame({'time': [end - start], 'model': [model_name]})
Expand Down
4 changes: 3 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ dependencies:
- numpy>=1.21.6
- optuna
- pandas>=1.3.5
- pyarrow
- pytorch>=2.0.0
- pytorch-lightning>=2.0.0
- pip
- utilsforecast>=0.0.6
- pip:
- nbdev
- black
- polars
- "ray[tune]>=2.2.0"
- utilsforecast>=0.0.17
34 changes: 34 additions & 0 deletions nbs/config.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "06dabc05-6dc5-4cb2-afde-62a1dd58f606",
"metadata": {},
"outputs": [],
"source": [
"#| default_exp config"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e84cc420-9d82-4e69-abe2-87564faeb159",
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"id_as_index = True"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit adccb2f

Please sign in to comment.