Skip to content

Commit 85932bf

Browse files
committed
Merge remote-tracking branch 'upstream/main' into opt
2 parents a7f6491 + e08f4e6 commit 85932bf

File tree

5 files changed

+222
-41
lines changed

5 files changed

+222
-41
lines changed

docs/source/contribute.rst

Lines changed: 0 additions & 31 deletions
This file was deleted.

docs/source/getting-started.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,32 @@ Installation
99

1010
.. _install:
1111

12-
If you are working windows, you need to first install PyTorch with
12+
If you are working Windows, you need to first install PyTorch with
1313

14-
``pip install torch -f https://download.pytorch.org/whl/torch_stable.html``.
14+
.. code-block:: bash
15+
16+
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
1517
1618
Otherwise, you can proceed with
1719

18-
``pip install pytorch-forecasting``
20+
.. code-block:: bash
21+
22+
pip install pytorch-forecasting
23+
1924
25+
Alternatively, to install the package via ``conda``:
2026

21-
Alternatively, to installl the package via conda:
27+
.. code-block:: bash
2228
23-
``conda install pytorch-forecasting pytorch>=1.7 -c pytorch -c conda-forge``
29+
conda install pytorch-forecasting pytorch>=1.7 -c pytorch -c conda-forge
2430
2531
PyTorch Forecasting is now installed from the conda-forge channel while PyTorch is install from the pytorch channel.
2632

2733
To use the MQF2 loss (multivariate quantile loss), also install
28-
`pip install pytorch-forecasting[mqf2]`
34+
35+
.. code-block:: bash
36+
37+
pip install pytorch-forecasting[mqf2]
2938
3039
3140
Usage

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The :ref:`Tutorials <tutorials>` section provides guidance on how to use models
6666
models
6767
metrics
6868
faq
69-
contribute
69+
installation
7070
api
7171
CHANGELOG
7272

docs/source/installation.rst

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
Installation
2+
============
3+
4+
``pytorch-forecasting`` currently supports:
5+
6+
* Python versions 3.8, 3.9, 3.10, 3.11, and 3.12.
7+
* Operating systems : Linux, macOS, and Windows
8+
9+
Installing pytorch-forecasting
10+
------------------------------
11+
12+
``pytorch-forecasting`` is a library built on top of the popular deep learning framework ``pytorch`` and
13+
heavily uses the Pytorch Lightning library ``lightning`` for ease of training and multiple GPU usage.
14+
15+
You'll need to install ``pytorch`` along or before with ``pytorch-forecasting`` in order to get a working
16+
install of this library.
17+
18+
If you are working Windows, you can install PyTorch with
19+
20+
.. code-block:: bash
21+
22+
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
23+
24+
.. note::
25+
It is recommended to visit the Pytorch official page https://pytorch.org/get-started/locally/#start-locally to
26+
figure out which version of ``pytorch`` best suits your machine if you are
27+
unfamiliar with the library.
28+
29+
Otherwise, you can proceed with:
30+
31+
.. code-block:: bash
32+
33+
pip install pytorch-forecasting --extra-index-url https://download.pytorch.org/whl/cpu
34+
35+
36+
Alternatively, to install the package via ``conda``:
37+
38+
.. code-block:: bash
39+
40+
conda install pytorch-forecasting pytorch>=2.0.0 -c pytorch -c conda-forge
41+
42+
PyTorch Forecasting is now installed from the conda-forge channel while PyTorch is install from the pytorch channel.
43+
44+
To install ``pytorch-forecasting`` with the use of the MQF2 loss (multivariate quantile loss), run:
45+
46+
.. code-block:: bash
47+
48+
pip install pytorch-forecasting[mqf2]
49+
50+
51+
To install the Pytorch Lightning library, please visit their `official page <https://lightning.ai/docs/pytorch/stable/starter/installation.html>`__ or run:
52+
53+
.. code-block:: bash
54+
55+
pip install lightning
56+
57+
58+
Obtaining a latest ``pytorch-forecasting`` version
59+
--------------------------------------------------
60+
61+
This type of installation obtains a latest static snapshot of the repository, with
62+
various features that are not published in a release. It is mainly intended for developers
63+
that wish to build or test code using a version of the repository that contains
64+
all of the latest or current updates.
65+
66+
.. code-block:: bash
67+
68+
pip install git+https://github.com/sktime/pytorch-forecasting.git
69+
70+
71+
To install from a specific branch, use the following command:
72+
73+
.. code-block:: bash
74+
75+
pip install git+https://github.com/sktime/pytorch-forecasting.git@<branch_name>
76+
77+
78+
Contributing to ``pytorch-forecasting``
79+
---------------------------------------
80+
81+
Contributions to PyTorch Forecasting are very welcome! You do not have to be an expert in deep learning
82+
to contribute. If you find a bug - fix it! If you miss a feature - propose it!
83+
84+
To obtain an editible version ``pytorch-forecasting`` for development or contributions,
85+
you will need to set up:
86+
87+
* a local clone of the ``pytorch-forecasting`` repository.
88+
* a virtual environment with an editable install of ``pytorch-forecasting`` and the developer dependencies.
89+
90+
The following steps guide you through the process:
91+
92+
Creating a fork and cloning the repository
93+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94+
95+
1. Fork the `project
96+
repository <https://github.com/sktime/pytorch-forecasting>`__ by
97+
clicking on the 'Fork' button near the top right of the page. This
98+
creates a copy of the code under your GitHub user account. For more
99+
details on how to fork a repository see `this
100+
guide <https://help.github.com/articles/fork-a-repo/>`__.
101+
102+
2. `Clone <https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository>`__
103+
your fork of the pytorch-forecasting repo from your GitHub account to your local
104+
disk:
105+
106+
.. code:: bash
107+
108+
git clone [email protected]:<username>/sktime/pytorch-forecasting.git
109+
cd pytorch-forecasting
110+
111+
where :code:`<username>` is your GitHub username.
112+
113+
3. Configure and link the remote for your fork to the upstream
114+
repository:
115+
116+
.. code:: bash
117+
118+
git remote -v
119+
git remote add upstream https://github.com/sktime/pytorch-forecasting.git
120+
121+
4. Verify the new upstream repository you've specified for your fork:
122+
123+
.. code:: bash
124+
125+
git remote -v
126+
> origin https://github.com/<username>/sktime/pytorch-forecasting.git (fetch)
127+
> origin https://github.com/<username>/sktime/pytorch-forecasting.git (push)
128+
> upstream https://github.com/sktime/pytorch-forecasting.git (fetch)
129+
> upstream https://github.com/sktime/pytorch-forecasting.git (push)
130+
131+
Setting up an editible virtual environment
132+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133+
134+
1. Set up a new virtual environment. Our instructions will go through the commands to set up a ``conda`` environment which is recommended for ``pytorch-forecasting`` development.
135+
The process will be similar for ``venv`` or other virtual environment managers.
136+
137+
.. warning::
138+
Using ``conda`` via one of the commercial distributions such as Anaconda
139+
is in general not free for commercial use and may incur significant costs or liabilities.
140+
Consider using free distributions and channels for package management,
141+
and be aware of applicable terms and conditions.
142+
143+
In the ``conda`` terminal:
144+
145+
2. Navigate to your local pytorch-forecasting folder, :code:`cd pytorch-forecasting` or similar
146+
147+
3. Create a new environment with a supported python version: :code:`conda create -n pytorch-forecasting-dev python=3.11` (or :code:`python=3.12` etc)
148+
149+
.. warning::
150+
If you already have an environment called ``pytorch-forecasting-dev`` from a previous attempt you will first need to remove this.
151+
152+
4. Activate the environment: :code:`conda activate pytorch-forecasting-dev`
153+
154+
5. Build an editable version of pytorch-forecasting.
155+
In order to install only the dev dependencies, :code:`pip install -e ".[dev]"`
156+
If you also want to install soft dependencies, install them individually, after the above,
157+
or instead use: :code:`pip install -e ".[all_extras,dev]"` to install all of them.
158+
159+
Contribution Guidelines and Recommendations
160+
-------------------------------------------
161+
162+
Submitting pull request best practices
163+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164+
165+
To ensure that maintainers and other developers are able to help your issues or
166+
review your contributions/pull requests, please read the following guidelines below.
167+
168+
* Open issues to discuss your proposed changes before starting pull requests.
169+
This ensures that other developers or maintainers have adequete context/knowledge
170+
about your future contribution so that it can be swiftly integrated into the code base.
171+
172+
* Adding context tags to the PR title.
173+
This will greatly help categorize different types of pull requests without having
174+
to look at the full title. Usually tags that start with either [ENH] - Enhancement:
175+
adding a feature, or improving code, [BUG] - Bugfixes, [MNT] - CI: test framework, [DOC] -
176+
Documentation: writing or improving documentation or docstrings.
177+
178+
* Adding references to other links or pull requests.
179+
This helps to add context about previous or current issues/prs that relate to
180+
your contribution. This is done usually by including a full link or a hash tag '#1234'.
181+
182+
Technical Design Principles
183+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
184+
185+
When writing code for your new feature, it is recommended to follow these
186+
technical design principles to ensure compatability between the feature and the library.
187+
188+
* Backward compatible API if possible to prevent breaking code.
189+
* Powerful abstractions to enable quick experimentation. At the same time, the abstractions should
190+
allow the user to still take full control.
191+
* Intuitive default values that do not need changing in most cases.
192+
* Focus on forecasting time-related data - specificially timeseries regression and classificiation.
193+
Contributions not directly related to this topic might not be merged. We want to keep the library as
194+
crisp as possible.
195+
* Install ``pre-commit`` and have it run on every commit that you make on your feature branches.
196+
This library requires strict coding and development best practices to ensure the highest code quality.
197+
Contributions or pull requests that do not adhere to these standards will not likely be merged until fixed.
198+
For more information on ``pre-commit`` you can visit `this page <https://www.sktime.net/en/stable/developer_guide/coding_standards.html#using-pre-commit>`__
199+
* Always add tests and documentation to new features.

pytorch_forecasting/data/timeseries.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class TimeSeriesDataSet(Dataset):
126126
* normalizing the target variable
127127
* efficiently converting timeseries in pandas dataframes to torch tensors
128128
* holding information about static and time-varying variables known and unknown in the future
129-
* holiding information about related categories (such as holidays)
129+
* holding information about related categories (such as holidays)
130130
* downsampling for data augmentation
131131
* generating inference, validation and test datasets
132132
* etc.
@@ -323,10 +323,14 @@ def __init__(
323323
distribution.
324324
If True, defaults to (0.2, 0.05), i.e. ~1/4 of samples around minimum encoder length.
325325
Defaults to False otherwise.
326-
predict_mode (bool): if to only iterate over each timeseries once (only the last provided samples).
327-
Effectively, this will take choose for each time series identified by ``group_ids``
326+
predict_mode (bool): If True, the TimeSeriesDataSet will only create one sequence
327+
per time series (i.e. only from the latest provided samples).
328+
Effectively, this will select each time series identified by ``group_ids``
328329
the last ``max_prediction_length`` samples of each time series as
329330
prediction samples and everthing previous up to ``max_encoder_length`` samples as encoder samples.
331+
If False, the TimeSeriesDataSet will create subsequences by sliding a window over the data samples.
332+
For training use cases, it's preferable to set predict_mode=False to get all subseries.
333+
On the other hand, predict_mode = True is ideal for validation cases.
330334
"""
331335
super().__init__()
332336
self.max_encoder_length = max_encoder_length

0 commit comments

Comments
 (0)