Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Skar0/time_series
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienLegay committed Jan 22, 2020
2 parents 8864b5a + cd2f040 commit 4dfbf77
Show file tree
Hide file tree
Showing 15 changed files with 926 additions and 3,947 deletions.
44 changes: 29 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,42 @@ functions as legible as possible. We also made sure to create functions that cou
give us visualisation of our progress. The code is organized as follows :

```bash
├── find_submission_models.py
├── tools.py
── utils.py
├── data/
├── arima_models
│   ├── arima_forecasting.py
│   └── __init__.py
├── data
│   └── train.csv
├── neural_networks_models/
├── find_submission_models.py
├── neural_networks_models
│   ├── __init__.py
│   ├── lstm_multi_step_forecasting.py
│   ├── nn_multi_step_forecasting.py
│   └── nn_single_step_forecasting.py
├── arima_models/
│   └── arima_forecasting.py
├── regression_models/
│   └── simple_regression.py
├── notebooks/
│   └── nn_single_step_forecasting.py
├── notebooks
│   ├── good_regression_forecasting.ipynb
│   └── xgboost_plus_weights.ipynb
├── submissions/
│   ├── submission_1.csv
│   └── submission_2.csv
├── one_step_regression.py
├── README.md
├── regression_models
│   ├── __init__.py
│   ├── regression_forecasting.py
│   ├── regression_preprocessing.py
│   └── regression_tools.py
├── submissions
│   ├── sarima_scaled.csv
│   ├── sarima_scaled_exog_all.csv
│   ├── sarima_scaled_exog.csv
│   ├── submission_arima.csv
│   ├── submission_arima_outliers2.csv
│   ├── submission_arima_outliers.csv
│   └── submission_prophet.csv
├── tools.py
├── utils.py
└── xgboost_plus_weights.ipynb
```

For this competition, we evaluated three types of models. Each model was tested on a validation series provided while fitting.
First, ARIMA-based models were tested. We estimated ARIMA parameters using auto arima from pmdarima. Then we used regression-based techniques such as linear regression and gradientboosting using xgbboost.
First, ARIMA-based models were tested. We estimated ARIMA parameters using auto arima from pmdarima. Then we used regression-based techniques such as linear regression and gradientboosting using xgboost.
Lastly, we tried neural network models. First by predicting several steps at the time and then one step at the time. Finaly, LSTM were tried.
find_submission_models performed model fitting and evaluation on each series and selected best models for submission.

Expand Down
File renamed without changes.
11 changes: 6 additions & 5 deletions arima_forecasting.py → arima_models/arima_forecasting.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pandas as pd
from matplotlib import pyplot as plt
from pmdarima import auto_arima, arima

from utils import remove_outliers, normalize_series, smape


Expand All @@ -16,7 +15,7 @@ def auto_arima_forecast(series, validation_series, horizon, del_outliers=False,
:param del_outliers:
:param normalize:
:param plot:
:return: SMAPE for the validation series, the forecast validation series
:return: SMAPE for the validation series, the forecast validation series, order, seasonal_order
"""

# whether to remove outliers in the training series
Expand Down Expand Up @@ -88,10 +87,12 @@ def auto_arima_forecast(series, validation_series, horizon, del_outliers=False,

plt.show()

return smape(validation_series, forecast_dataframe['forecast']), forecast_dataframe['forecast'], order, seasonal_order
return smape(validation_series, forecast_dataframe['forecast']), forecast_dataframe[
'forecast'], order, seasonal_order


def arima_forecast(series, validation_series, horizon, order, seasonal_order, del_outliers=False, normalize=False, plot=False):
def arima_forecast(series, validation_series, horizon, order, seasonal_order, del_outliers=False, normalize=False,
plot=False):
"""
Creates an arima model with the provided order and seasonal order and assess performance of the model is on a
validation series.
Expand Down Expand Up @@ -164,7 +165,7 @@ def arima_forecast(series, validation_series, horizon, order, seasonal_order, de

plt.legend(["Train series", "Validation series", "Predicted series"])

plt.title("Validation of arima model with order "+str(order)+" seasonal order "+str(seasonal_order))
plt.title("Validation of arima model with order " + str(order) + " seasonal order " + str(seasonal_order))

plt.show()

Expand Down
7 changes: 4 additions & 3 deletions find_submission_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import pandas as pd
from matplotlib import pyplot as plt
from neural_networks_models.nn_single_step_forecasting import nn_single_step_forecast, nn_with_past_outliers_single_step_forecast, \
nn_with_past_single_step_forecast

from arima_forecasting import auto_arima_forecast, arima_forecast
from arima_models.arima_forecasting import auto_arima_forecast, arima_forecast
from neural_networks_models.nn_multi_step_forecasting import nn_multi_step_forecast, nn_with_past_multi_step_forecast, \
nn_with_past_outliers_multi_step_forecast
from neural_networks_models.nn_single_step_forecasting import nn_single_step_forecast, \
nn_with_past_outliers_single_step_forecast, \
nn_with_past_single_step_forecast
# These models and parameters have been chosen through experiments
from utils import remove_outliers, keyvalue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,7 @@
" for i in range(series):\n",
" scores[i] = loss_function(y_validation_array[i, :], pred_array[i, :])\n",
"\n",
" return scores\n",
"\n",
"\n",
"\n",
"\n"
" return scores"
]
},
{
Expand Down Expand Up @@ -3470,7 +3466,9 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
""
]
}
],
"metadata": {
Expand All @@ -3482,7 +3480,7 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
"version": 3.0
},
"file_extension": ".py",
"mimetype": "text/x-python",
Expand All @@ -3493,5 +3491,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 4
}
"nbformat_minor": 0
}
240 changes: 0 additions & 240 deletions predictor.py

This file was deleted.

Empty file added regression_models/__init__.py
Empty file.
Loading

0 comments on commit 4dfbf77

Please sign in to comment.