Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc/Adding basic usage example in each model docstring #1956

Merged
merged 16 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update leftover lambda mentions in model docs
  • Loading branch information
dennisbader committed Sep 14, 2023
commit cca58fddddafcc5536478b4278b674e1dd8051b6
5 changes: 4 additions & 1 deletion darts/models/forecasting/arima.py
madtoinou marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more points (this time with N for New ;) ):

  • N1: I'd try to make it more obvious that the usage of future covariates is optional, not the encoding itselve (here and everywhere else when covariates are used). E.g.
>>> # optionally, encode the holidays as a future covariates
to 
>>> # optionally, use some future covariates; e.g. the value of the month encoded as a sine and cosine series
  • N2: the air passengers series has a monthly frequency. Adding holidays as covariates is not the best choice for this frequency (here and in the other examples).
    Maybe we could use the value of the month or something? E.g.
from darts.utils.timeseries_generation import datetime_attribute_timeseries
future_cov = datetime_attribute_timeseries(series, "month", cyclic=True, add_length=6)
  • N3 The indentation should 4 whitespaces and the last ")" should be at 0 indentation
    E.g.
# right now it looks like this:
>>> model = BlockRNNModel(
>>>   input_chunk_length=12,
>>>   output_chunk_length= 6,
>>>   n_rnn_layers=2,
>>>   n_epochs=50,
>>>   )

# it should look like this
>>> model = BlockRNNModel(
>>>     input_chunk_length=12,
>>>     output_chunk_length=6,
>>>     n_rnn_layers=2,
>>>     n_epochs=50,
>>> )
  • N4 the predicted values of the torch models are mostly really bad. We should explain that those are simple usage examples and for better performance user should transform the input data, more epochs, validation set, etc.. Ideally we could reference some notebook or something

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have missing models:

sf_auto_arima.py
sf_auto_ces.py
sf_auto_ets.py
sf_auto_theta.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was already simple example for these models, I did not change them but I could so that everything is homogeneous.

Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ def __init__(
.. highlight:: python
.. code-block:: python

def encode_year(idx):
return (idx.year - 1950) / 50

add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Expand Down
5 changes: 4 additions & 1 deletion darts/models/forecasting/auto_arima.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ def __init__(
.. highlight:: python
.. code-block:: python

def encode_year(idx):
return (idx.year - 1950) / 50

add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Expand Down
5 changes: 4 additions & 1 deletion darts/models/forecasting/croston.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ def __init__(
.. highlight:: python
.. code-block:: python

def encode_year(idx):
return (idx.year - 1950) / 50

add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Expand Down
5 changes: 4 additions & 1 deletion darts/models/forecasting/kalman_forecaster.py
madtoinou marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ def __init__(
.. highlight:: python
.. code-block:: python

def encode_year(idx):
return (idx.year - 1950) / 50

add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Expand Down
5 changes: 4 additions & 1 deletion darts/models/forecasting/prophet_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ def __init__(
.. highlight:: python
.. code-block:: python

def encode_year(idx):
return (idx.year - 1950) / 50

add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Expand Down
5 changes: 4 additions & 1 deletion darts/models/forecasting/sf_auto_arima.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ def __init__(
.. highlight:: python
.. code-block:: python

def encode_year(idx):
return (idx.year - 1950) / 50

add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Expand Down
5 changes: 4 additions & 1 deletion darts/models/forecasting/sf_auto_ets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ def __init__(
.. highlight:: python
.. code-block:: python

def encode_year(idx):
return (idx.year - 1950) / 50

add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Expand Down
5 changes: 4 additions & 1 deletion darts/models/forecasting/varima.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ def __init__(
.. highlight:: python
.. code-block:: python

def encode_year(idx):
return (idx.year - 1950) / 50

add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Expand Down