Skip to content

Commit

Permalink
Fixed README and chenged version for release
Browse files Browse the repository at this point in the history
  • Loading branch information
deatinor committed Dec 20, 2019
2 parents 8bea403 + 37c68f6 commit e39ae80
Show file tree
Hide file tree
Showing 10 changed files with 851 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ target/

# Jupyter NB Checkpoints
.ipynb_checkpoints/
Untitled*

# exclude data from source control by default
/data/
Expand Down
78 changes: 66 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Giotto-time provide the GAR class (Generalize Auto Regressive model). It operate
.. raw:: html

<p align="center">
<img width="460" src="https://storage.googleapis.com/l2f-open-models/giotto-time/images/gar.png">
<img width="600" src="https://storage.googleapis.com/l2f-open-models/giotto-time/images/gar.png">
</p>

This model allows the full force of machine learning regressors (compatible with the fit-transform framework ok scikit-learn) to be combined with advanced feature creation stratagies to forecast time series in a convienent api.
Expand Down Expand Up @@ -67,28 +67,26 @@ Time Series Preparation

To transform an input array-like structure into a DataFrame with a PeriodIndex we provide the classes:

To transform an input array-like structure into a DataFrame with a PeriodIndex we provide the classes:

* TimeSeriesPreparation
* TimeSeriesConversion
* SequenceToTimeIndexSeries
* PandasSeriesToTimeIndexSeries
* TimeIndexSeriesToPeriodIndexSeries


Feature Creation
================

The following time series features are currently supported:

CalendarFeature
PeriodicSeasonalFeature
ShiftFeature
MovingAverageFeature
ConstantFeature
PolynomialFeature
ExogenousFeature
CustomFeature
* CalendarFeature
* PeriodicSeasonalFeature
* ShiftFeature
* MovingAverageFeature
* ConstantFeature
* PolynomialFeature
* ExogenousFeature
* CustomFeature

These features all have a scikit-learn-like interface and behave as transformers.

The class FeatureCreation wraps a list of features together and returns the X and y matrices from a time series given as input.
Expand Down Expand Up @@ -136,5 +134,61 @@ Specifically, giotto-time includes ExponentialTrend, PolynomialTrend model class

Before the detrending tranformer, a clear quadratic trend is present in the data. For additional information on trend stationarity, see: Trend stationarity: Wikipedia - https://en.wikipedia.org/wiki/Trend_stationary.

Custom Regressors
=================

LinearRegressor is a linear regressor class that minimizes a custom loss function (compatitble with all scikit-learn metrics).

.. raw:: html

<p align="center">
<img width="800" src="https://storage.googleapis.com/l2f-open-models/giotto-time/images/custom_error.png">
</p>

In time series forecasting, it can be essential to minimize error metrics other than the standard R squared. Using this regressor class, it is possible to fit smape, max error and a range of other time series forecasting metrics easily with a simple interface via the GAR class.

>>> from giottotime.models.regressors.linear_regressor import LinearRegressor
>>> from giottotime.loss_functions import max_error
>>> import numpy as np
>>> import pandas as pd
>>> X = np.random.random((100, 10))
>>> y = np.random.random(100)
>>> lr = LinearRegressor(loss=max_error)
>>> X_train, y_train = X[:90], y[:90]
>>> X_test, y_test = X[90:], y[90:]
>>> x0 = [0]*11
>>> lr.fit(X_train, y_train, x0=x0)
>>> y_pred = lr.predict(X_test)

Causality Tests
===============

We provide two tests: ShiftedLinearCoefficient and ShiftedPearsonCorrelation.

These tests (which are impliemnted as scikit-learn compatible transformers) determine which shift of each time series maximizes the correlation to each other input time series. This is a very similar construction tothe granger test.

An example use is shown below.

>>> from giottotime.causality_tests.shifted_linear_coefficient import ShiftedLinearCoefficient
>>> import pandas.util.testing as testing
>>> data = testing.makeTimeDataFrame(freq="s")
>>> slc = ShiftedLinearCoefficient(target_col="A")
>>> slc.fit(data)
>>> slc.best_shifts_
y A B C D
x
A 3 6 8 5
B 9 9 4 1
C 8 2 4 9
D 3 9 4 3
>>> slc.max_corrs_
y A B C D
x
A 0.460236 0.420005 0.339370 0.267143
B 0.177856 0.300350 0.367150 0.550490
C 0.484860 0.263036 0.456046 0.251342
D 0.580068 0.344688 0.253626 0.256220

The target-col input variable to the constructor is used in the transform method. It determins which set of shifts are applied to all inputs. For example, if 'A' is selected, each column will be transform by a shift corresponding to the 'A' row of the bests_shifts_ pivot table.


27 changes: 27 additions & 0 deletions examples/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.. image:: https://www.giotto.ai/static/vector/logo.svg
:width: 850

Examples and Tutorials
======================

In this folder you can find basic tutorials and examples: you can read through them to
understand how `giotto-time` works.

Quick start
-----------

This tutorial is about giving an overview on the basic features of `giotto-time`.
You will learn how to train a simple time series model with custom features.
Some considerations on input-output are presented.

Details and advanced features
-----------------------------

This tutorial details more advanced features of `giotto-time`.
You will learn more details on the feature generation and on custom linear regressor
model for time series forecasting.

Causality Tests
---------------

This tutorial details the causality tests built-in in `giotto-time`.
Loading

0 comments on commit e39ae80

Please sign in to comment.