@@ -11,14 +11,14 @@ Overview
11
11
compared to traditional time series libraries are the following:
12
12
13
13
- feature creation, model selection, model assessment and prediction pipeline for time series models.
14
- - plug-and-play availability of any scikit-learn-compatible regression or classification model for forecasting.
15
- - minimization of standard custom loss functions for time series (SMAPE, max error, etc..)
16
- - easy-to-use scikit-learn-familiar API.
14
+ - plug-and-play availability of any scikit-learn-compatible (i.e., in the fit-transform framework) regression or classification models for forecasting.
15
+ - minimization of standard and custom loss functions for time series (SMAPE, max error, etc..).
16
+ - easy-to-use scikit-learn-familiar and pandas-familiar API.
17
17
18
- Additionally we provide standard causality tests with a scikit-learn-like interface.
18
+ Additionally we provide a causality tests with a scikit-learn-like transformer interface.
19
19
20
20
21
- Input-Output specifications
21
+ Input-Output Specifications
22
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~
23
23
24
24
**Input: ** `pd.Series `, `pd.DataFrame ` (single column), `np.array `, `list `
@@ -28,31 +28,6 @@ Input-Output specifications
28
28
**Additional input parameters: ** the user can pass a list of features and a scikit-learn
29
29
compatible model to giotto-time.
30
30
31
- Example of Usage
32
- ~~~~~~~~~~~~~~~~
33
-
34
- .. code-block :: python
35
-
36
- from giottotime.feature_creation import FeaturesCreation
37
- from giottotime.feature_creation.index_independent_features import ShiftFeature, MovingAverageFeature
38
- from giottotime.model_selection.train_test_splitter import TrainTestSplitter
39
- from giottotime.regressors import LinearRegressor
40
- from giottotime.models.time_series_models import GAR
41
-
42
- time_series = get_time_series()
43
-
44
- features_creation = FeaturesCreation(
45
- horizon = 4 ,
46
- features = [ShiftFeature(1 ), ShiftFeature(2 ), MovingAverageFeature(5 )]
47
- )
48
- train_test_splitter = TrainTestSplitter()
49
- time_series_model = GAR(base_model = LinearRegressor())
50
-
51
- X, y = features_creation.transform(time_series)
52
- X_train, y_train, X_test, y_test = train_test_splitter.transform(X, y)
53
-
54
- time_series_model.fit(X_train, y_train)
55
- predictions = time_series_model.predict(X_test)
56
31
57
32
Time Series Preparation
58
33
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -79,28 +54,108 @@ We support the following features:
79
54
- `ExogenousFeature `
80
55
- `CustomFeature `
81
56
82
- The features have a scikit-learn-like interface.
57
+ These features all have a scikit-learn-like interface and behave as transformers .
83
58
84
59
The class FeatureCreation wraps a list of features together and returns the X and y
85
60
matrices from a time series given as input.
86
61
87
62
Time Series Model
88
63
~~~~~~~~~~~~~~~~~
89
- We provide the `GAR ` class (Generalize Auto Regressive).
64
+ Giotto-time provide the `GAR ` class (Generalize Auto Regressive model ).
90
65
It operates in a similar way to the standard AR, but with an arbitrary number of
91
- features and with an arbitrary regression model.
66
+ features and with an arbitrary underlying regression model.
67
+
68
+ .. image :: ../../../../images/gar.png
69
+ :width: 60%
70
+ :align: center
71
+
72
+ .. code-block :: python
73
+
74
+ from giottotime.feature_creation import FeaturesCreation
75
+ from giottotime.feature_creation.index_independent_features import ShiftFeature, MovingAverageFeature
76
+ from giottotime.model_selection.train_test_splitter import TrainTestSplitter
77
+ from giottotime.regressors import LinearRegressor
78
+ from giottotime.models.time_series_models import GAR
79
+
80
+ time_series = get_time_series()
81
+
82
+ features_creation = FeaturesCreation(
83
+ horizon = 4 ,
84
+ features = [ShiftFeature(1 ), ShiftFeature(2 ), MovingAverageFeature(5 )]
85
+ )
86
+ train_test_splitter = TrainTestSplitter()
87
+ time_series_model = GAR(base_model = LinearRegressor())
88
+
89
+ X, y = features_creation.transform(time_series)
90
+ X_train, y_train, X_test, y_test = train_test_splitter.transform(X, y)
91
+
92
+ time_series_model.fit(X_train, y_train)
93
+ predictions = time_series_model.predict(X_test)
92
94
93
95
Time Series Trend Model
94
96
~~~~~~~~~~~~~~~~~~~~~~~
95
- We provide three main classes to analyze and remove trends from time series:
96
- - `FunctionTrend `
97
- - `ExponentialTrend `
98
- - `PolynomialTrend `
97
+ We provide main classes to analyze and remove trends from time series in order to create trend stationary time series.
98
+
99
+ Specifically, giotto-time includes `ExponentialTrend `, `PolynomialTrend ` model classes and de-trending transformers.
100
+
101
+ Example of Usage
102
+ ~~~~~~~~~~~~~~~~
103
+
104
+ .. code-block :: python
105
+
106
+ import numpy as np
107
+ import pandas as pd
108
+
109
+ import matplotlib.pyplot as plt
110
+
111
+ from giottotime.models.regressors.linear_regressor import LinearRegressor
112
+ from giottotime.loss_functions.loss_functions import max_error, smape
113
+
114
+ from giottotime.models.trend_models.polynomial_trend import PolynomialTrend
115
+
116
+ from math import pi
117
+
118
+ d = pd.read_csv(' trend.csv' , index_col = 0 , parse_dates = True )
119
+ tm = PolynomialTrend(order = 3 )
120
+
121
+ tm.fit(d)
122
+
123
+ d.plot(figsize = (10 , 10 ))
124
+ plt.show()
125
+
126
+ detrended = tm.transform(d)
127
+
128
+ detrended.plot(figsize = (10 , 10 ))
129
+ plt.show()
130
+
131
+ Before the detrending tranformer, a clear quadratic trend is present in the data:
132
+
133
+ .. image :: ../../../../images/trend.png
134
+ :width: 60%
135
+ :align: center
136
+
137
+ After fitting and applying the detrending tranformer, a the transformed data is 'trend stationary':
138
+
139
+ .. image :: ../../../../images/no_trend.png
140
+ :width: 60%
141
+ :align: center
142
+
143
+ For additional information on trend stationarity, see:
144
+ Trend stationarity: `Wikipedia - Trend stationarity <https://en.wikipedia.org/wiki/Trend_stationary / >`_.
145
+
99
146
100
147
Model Selection and Cross Validation
101
148
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149
+ - `trim_feature_nans `
150
+
151
+ .. image :: ../../../../images/trimmer.png
152
+ :width: 60%
153
+ :align: center
154
+
102
155
- `TrainTestSplitter `
103
156
157
+
158
+
104
159
Custom Regressors
105
160
~~~~~~~~~~~~~~~~~
106
161
@@ -110,6 +165,18 @@ Causality Tests
110
165
~~~~~~~~~~~~~~~
111
166
We provide two tests: `ShiftedLinearCoefficient ` and `ShiftedPearsonCorrelation `.
112
167
168
+ .. code-block :: python
169
+
170
+ import numpy as np
171
+ import pandas as pd
172
+
173
+ import matplotlib.pyplot as plt
174
+
175
+ from giottotime.causality_tests import ShiftedPearsonCorrelation
176
+
177
+ # TODO
178
+
179
+
113
180
Release 0.2.0 (to be discussed)
114
181
-------------------------------
115
182
To be discussed.
0 commit comments