Skip to content

Commit

Permalink
Fixed comments and typings
Browse files Browse the repository at this point in the history
Signed-off-by: Stefano Savare <[email protected]>
  • Loading branch information
deatinor committed Apr 7, 2020
1 parent 940ea7f commit 1d4524d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions gtime/model_selection/horizon_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def horizon_shift(
2020-01-03 3.0 4.0
2020-01-04 4.0 NaN
2020-01-05 NaN NaN
>>> horizon_shift(X, horizon=[2])
y_2
2020-01-01 2.0
2020-01-02 3.0
2020-01-03 4.0
2020-01-04 NaN
2020-01-05 NaN
"""
horizon = range(1, horizon + 1) if isinstance(horizon, (int, float)) else horizon
Expand Down
4 changes: 3 additions & 1 deletion gtime/time_series_models/ar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List, Union

import numpy as np
from sklearn.compose import make_column_selector
from sklearn.linear_model import LinearRegression
Expand Down Expand Up @@ -34,7 +36,7 @@ class AR(TimeSeriesForecastingModel):
2000-01-01 00:00:19 -0.107707 0.052031 -0.105526
"""

def __init__(self, p: int, horizon: int):
def __init__(self, p: int, horizon: Union[int, List[int]]):
features = [
tuple((f"s{i}", Shift(i), make_column_selector(dtype_include=np.number)))
for i in range(1, p + 1)
Expand Down
6 changes: 3 additions & 3 deletions gtime/time_series_models/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Tuple
from typing import List, Tuple, Union

import sklearn
from sklearn.base import BaseEstimator, RegressorMixin
Expand Down Expand Up @@ -26,7 +26,7 @@ class TimeSeriesForecastingModel(BaseEstimator, RegressorMixin):
input of class FeatureCreation, which inherits from
``sklearn.compose.ColumnTransformer``. It is
used internally to instantiate FeatureCreation
horizon : int, required
horizon : Union[int, List[int], required
how many steps to predict in the future
model: RegressorMixin, required
forecasting model used for predictions
Expand Down Expand Up @@ -57,7 +57,7 @@ class TimeSeriesForecastingModel(BaseEstimator, RegressorMixin):
def __init__(
self,
features: List[Tuple],
horizon: int,
horizon: Union[int, List[int]],
model: RegressorMixin,
cache_features: bool = False,
):
Expand Down

0 comments on commit 1d4524d

Please sign in to comment.