Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/split-ci' into test-change-in-fo…
Browse files Browse the repository at this point in the history
…recasting

* origin/split-ci:
  control pytest configuration
  [MNT] [Dependabot](deps-dev): Update arch requirement from <6.2.0,>=5.6.0 to >=5.6.0,<6.3.0 (sktime#5392)
  [BUG] `statsforecast 1.6.0` compatibility - fix argument differences between `sktime` and `statsforecast` (sktime#5393)
  [BUG] `statsforecast 1.6.0` compatibility - in `statsforecast` adapter, fixing `RuntimeError: dictionary changed size during iteration` (sktime#5317)
  [DOC] fix typo in classification notebook (sktime#5390)
  [DOC] fix broken docstring example of `AlignerDtwNumba` (sktime#5374)
  [ENH] incremental testing to also test if any parent class in sktime has changed (sktime#5379)
  [ENH] simplified delegator interface to `dtw-python` based dynamic time warping distances (sktime#5348)
  [ENH] `YfromX` - probabilistic forecasts (sktime#5271)
  [ENH] removed py37.dockerfile and update doc entry for CI (sktime#5356)
  [ENH] lucky dynamic time warping distance and aligner (sktime#5341)
  [ENH] sensible default `_get_distance_matrix` for time series aligners (sktime#5347)
  [ENH] delegator for pairwise time series distances and kernels (sktime#5340)
  • Loading branch information
yarnabrina committed Oct 10, 2023
2 parents 2c35a9d + a2711be commit 8eb36b5
Show file tree
Hide file tree
Showing 28 changed files with 1,036 additions and 284 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Expand Up @@ -2405,6 +2405,15 @@
"bug",
"code"
]
},
{
"login": "pirnerjonas",
"name": "Jonas Pirner",
"avatar_url": "https://avatars.githubusercontent.com/u/48887249?v=4",
"profile": "https://github.com/pirnerjonas",
"contributions": [
"doc"
]
}
]
}
8 changes: 7 additions & 1 deletion .github/actions/test-base/action.yml
Expand Up @@ -4,6 +4,12 @@ inputs:
python-version-identifier:
description: python version to run tests
required: true
sub-sample-estimators:
description: test only subset of estimators
required: true
test-affected-estimators:
description: test only modified estimators
required: true
runs:
using: composite
steps:
Expand All @@ -17,7 +23,7 @@ runs:
run: python3 -m pip install .[tests]
shell: bash
- name: unit test step
run: python3 -m pytest sktime/base
run: python3 -m pytest sktime/base --matrixdesign ${{ inputs.sub-sample-estimators }} --only_changed_modules ${{ inputs.test-affected-estimators }}
shell: bash
- name: test coverage step
uses: codecov/codecov-action@v3
Expand Down
8 changes: 7 additions & 1 deletion .github/actions/test-component/action.yml
Expand Up @@ -7,6 +7,12 @@ inputs:
python-version-identifier:
description: python version to run tests
required: true
sub-sample-estimators:
description: test only subset of estimators
required: true
test-affected-estimators:
description: test only modified estimators
required: true
runs:
using: composite
steps:
Expand All @@ -20,7 +26,7 @@ runs:
run: python3 -m pip install .[${{ inputs.sktime-component-identifier }},tests]
shell: bash
- name: unit test step
run: python3 -m pytest sktime/${{ inputs.sktime-component-identifier }}
run: python3 -m pytest sktime/${{ inputs.sktime-component-identifier }} --matrixdesign ${{ inputs.sub-sample-estimators }} --only_changed_modules ${{ inputs.test-affected-estimators }}
shell: bash
- name: test coverage step
uses: codecov/codecov-action@v3
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_all.yml
Expand Up @@ -24,6 +24,8 @@ jobs:
uses: ./.github/actions/test-base
with:
python-version-identifier: ${{ matrix.python-version }}
sub-sample-estimators: "False"
test-affected-estimators: "False"
test_components:
name: test individual components
strategy:
Expand Down Expand Up @@ -55,3 +57,5 @@ jobs:
with:
sktime-component-identifier: ${{ matrix.sktime-component }}
python-version-identifier: ${{ matrix.python-version }}
sub-sample-estimators: "False"
test-affected-estimators: "False"
2 changes: 2 additions & 0 deletions .github/workflows/test_base.yml
Expand Up @@ -42,3 +42,5 @@ jobs:
uses: ./.github/actions/test-base
with:
python-version-identifier: ${{ matrix.python-version }}
sub-sample-estimators: "True"
test-affected-estimators: "True"
2 changes: 2 additions & 0 deletions .github/workflows/test_components.yml
Expand Up @@ -59,3 +59,5 @@ jobs:
with:
sktime-component-identifier: ${{ matrix.sktime-component }}
python-version-identifier: ${{ matrix.python-version }}
sub-sample-estimators: "True"
test-affected-estimators: "True"
8 changes: 0 additions & 8 deletions build_tools/docker/py37.dockerfile

This file was deleted.

8 changes: 8 additions & 0 deletions docs/source/api_reference/alignment.rst
Expand Up @@ -38,6 +38,14 @@ Dynamic time warping

AlignerDtwNumba

.. currentmodule:: sktime.alignment.lucky

.. autosummary::
:toctree: auto_generated/
:template: class.rst

AlignerLuckyDtw


Edit distance based aligners
----------------------------
Expand Down
9 changes: 9 additions & 0 deletions docs/source/api_reference/dists_kernels.rst
Expand Up @@ -113,6 +113,7 @@ Dynamic Time Warping Distances
:template: class.rst

DtwDist
DtwPythonDist
DtwDistTslearn
SoftDtwDistTslearn

Expand All @@ -124,6 +125,14 @@ Dynamic Time Warping Distances

CtwDistTslearn

.. currentmodule:: sktime.dists_kernels.lucky

.. autosummary::
:toctree: auto_generated/
:template: class.rst

LuckyDtwDist

Time warping distances can also be obtained by composing ``DistFromAligner`` with
a time warping aligner, see docstring of ``DistFromAligner``:

Expand Down
6 changes: 2 additions & 4 deletions docs/source/developer_guide/continuous_integration.rst
Expand Up @@ -157,8 +157,6 @@ with the image of name ``PYTHON_VERSION`` based on the following python versions
+----------------+----------------+
| Python version | PYTHON_VERSION |
+================+================+
| 3.7.16 | py37 |
+----------------+----------------+
| 3.8.16 | py38 |
+----------------+----------------+
| 3.9.16 | py39 |
Expand All @@ -171,8 +169,8 @@ with the image of name ``PYTHON_VERSION`` based on the following python versions
The dockerized tests can be also executed via `make <https://www.gnu.org/software/make/>`_,
via the command ``make dockertest PYTHON_VERSION=<python version>``.
The ``PYTHON_VERSION`` argument specifies the python version and is the same string as in the table above.
For example, to execute the tests in the Python version ``3.7.16``,
use ``make dockertest PYTHON_VERSION=py37``.
For example, to execute the tests in the Python version ``3.8.16``,
use ``make dockertest PYTHON_VERSION=py38``.
Continuous integration
Expand Down
2 changes: 1 addition & 1 deletion examples/02_classification.ipynb
Expand Up @@ -1061,7 +1061,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Evaluation is simila to `sklearn` classifiers - we split a dataset and evaluate performance on the test set.\n",
"Evaluation is similar to `sklearn` classifiers - we split a dataset and evaluate performance on the test set.\n",
"\n",
"This includes as additional steps:\n",
"\n",
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Expand Up @@ -80,7 +80,7 @@ forecasting = [
"statsforecast>=0.5.2,<1.7",
"statsmodels>=0.12.1,<0.15",
"tbats>=1.1,<1.2",
"arch>=5.6.0,<6.2.0",
"arch>=5.6.0,<6.3.0",
]
networks = [
"keras-self-attention>=0.51,<0.52",
Expand Down Expand Up @@ -139,15 +139,15 @@ all_extras = [
"seaborn>=0.11.0",
"seasonal",
"skpro>=2.0.0,<2.1.0",
"statsforecast>=0.5.2,<1.6.0; python_version < '3.11'",
"statsforecast>=0.5.2,<1.7.0",
"statsmodels>=0.12.1",
"stumpy>=1.5.1; python_version < '3.11'",
"tbats>=1.1.0",
"tensorflow; python_version < '3.11'",
"tsfresh>=0.17.0",
"tslearn>=0.5.2,<0.6.0; python_version < '3.11'",
"xarray",
"arch>=5.6.0,<6.2.0",
"arch>=5.6.0,<6.3.0",
]

all_extras_pandas2 = [
Expand Down Expand Up @@ -175,15 +175,15 @@ all_extras_pandas2 = [
"seaborn>=0.11.0",
"seasonal",
"skpro>=2.0.0,<2.1.0",
"statsforecast>=0.5.2,<1.6.0; python_version < '3.11'",
"statsforecast>=0.5.2,<1.7.0",
"statsmodels>=0.12.1",
"stumpy>=1.5.1; python_version < '3.11'",
"tbats>=1.1.0",
"tensorflow; python_version < '3.11'",
"tsfresh>=0.17.0",
"tslearn>=0.5.2,<0.6.0; python_version < '3.11'",
"xarray",
"arch>=5.6.0,<6.2.0",
"arch>=5.6.0,<6.3.0",
]

cython_extras = [
Expand Down
15 changes: 14 additions & 1 deletion sktime/alignment/base.py
Expand Up @@ -337,4 +337,17 @@ def _get_distance_matrix(self):
distmat: an (n x n) np.array of floats, where n is length of X passed to fit
[i,j]-th entry is alignment distance between X[i] and X[j] passed to fit
"""
raise NotImplementedError
# the default implementation assumes
# that the aligner can only align two sequences
if self.get_tag("capability:multiple-alignment", False):
raise NotImplementedError

import numpy as np

dist = self.get_distance()

distmat = np.zeros((2, 2), dtype="float")
distmat[0, 1] = dist
distmat[1, 0] = dist

return distmat
4 changes: 2 additions & 2 deletions sktime/alignment/dtw_numba.py
Expand Up @@ -110,8 +110,8 @@ class AlignerDtwNumba(BaseAligner):
>>> from sktime.utils._testing.series import _make_series
>>> from sktime.alignment.dtw_numba import AlignerDtwNumba
>>>
>>> X0 = _make_series() # doctest: +SKIP
>>> X1 = _make_series() # doctest: +SKIP
>>> X0 = _make_series(return_mtype="pd.DataFrame") # doctest: +SKIP
>>> X1 = _make_series(return_mtype="pd.DataFrame") # doctest: +SKIP
>>> d = AlignerDtwNumba(weighted=True, derivative=True) # doctest: +SKIP
>>> align = d.fit([X0, X1]).get_alignment() # doctest: +SKIP
"""
Expand Down
65 changes: 27 additions & 38 deletions sktime/alignment/dtw_python.py
Expand Up @@ -9,7 +9,6 @@
import pandas as pd

from sktime.alignment.base import BaseAligner
from sktime.utils.validation._dependencies import _check_soft_dependencies


class AlignerDTW(BaseAligner):
Expand All @@ -18,30 +17,31 @@ class AlignerDTW(BaseAligner):
Behaviour: computes the full alignment between X[0] and X[1]
assumes pairwise alignment (only two series) and univariate
if multivariate series are passed:
alignment is computed on univariate series with variable_to_align;
if this is not set, defaults to the first variable of X[0]
alignment is computed on univariate series with variable_to_align;
if this is not set, defaults to the first variable of X[0]
raises an error if variable_to_align is not present in X[0] or X[1]
Parameters
----------
dist_method : str, optional, default = "euclidean"
distance function to use, a distance on real n-space
one of the functions in `scipy.spatial.distance.cdist`
one of the functions in `scipy.spatial.distance.cdist`
step_pattern : str, optional, or dtw_python stepPattern object, optional
step pattern to use in time warping
one of: 'symmetric1', 'symmetric2' (default), 'asymmetric',
and dozens of other more non-standard step patterns;
list can be displayed by calling help(stepPattern) in dtw
and dozens of other more non-standard step patterns;
list can be displayed by calling help(stepPattern) in dtw
window_type : string, the chosen windowing function
"none", "itakura", "sakoechiba", or "slantedband"
"none" (default) - no windowing
"sakoechiba" - a band around main diagonal
"slantedband" - a band around slanted diagonal
"itakura" - Itakura parallelogram
open_begin, open_end : boolean, optional, default=False
"none" (default) - no windowing
"sakoechiba" - a band around main diagonal
"slantedband" - a band around slanted diagonal
"itakura" - Itakura parallelogram
open_begin : boolean, optional, default=False
open_end: boolean, optional, default=False
whether to perform open-ended alignments
open_begin = whether alignment open ended at start (low index)
open_end = whether alignment open ended at end (high index)
open_begin = whether alignment open ended at start (low index)
open_end = whether alignment open ended at end (high index)
variable_to_align : string, default = first variable in X[0] as passed to fit
which variable to use for univariate alignment
"""
Expand Down Expand Up @@ -203,39 +203,38 @@ def get_test_params(cls, parameter_set="default"):
class AlignerDTWfromDist(BaseAligner):
"""Aligner interface for dtw-python using pairwise transformer.
uses transformer for computation of distance matrix passed to alignment
Uses transformer for computation of distance matrix passed to alignment.
Components
Parameters
----------
dist_trafo: estimator following the pairwise transformer template
i.e., instance of concrete class implementing template BasePairwiseTransformer
Parameters
----------
step_pattern : str, optional, default = "symmetric2",
or dtw_python stepPattern object, optional
or dtw_python stepPattern object, optional
step pattern to use in time warping
one of: 'symmetric1', 'symmetric2' (default), 'asymmetric',
and dozens of other more non-standard step patterns;
list can be displayed by calling help(stepPattern) in dtw
and dozens of other more non-standard step patterns;
list can be displayed by calling help(stepPattern) in dtw
window_type: str optional, default = "none"
the chosen windowing function
"none", "itakura", "sakoechiba", or "slantedband"
"none" (default) - no windowing
"sakoechiba" - a band around main diagonal
"slantedband" - a band around slanted diagonal
"itakura" - Itakura parallelogram
open_begin, open_end: boolean, optional, default=False
"none" (default) - no windowing
"sakoechiba" - a band around main diagonal
"slantedband" - a band around slanted diagonal
"itakura" - Itakura parallelogram
open_begin : boolean, optional, default=False
open_end: boolean, optional, default=False
whether to perform open-ended alignments
open_begin = whether alignment open ended at start (low index)
open_end = whether alignment open ended at end (high index)
open_begin = whether alignment open ended at start (low index)
open_end = whether alignment open ended at end (high index)
"""

_tags = {
"capability:multiple-alignment": False, # can align more than two sequences?
"capability:distance": True, # does compute/return overall distance?
"capability:distance-matrix": True, # does compute/return distance matrix?
"python_dependencies": "dtw-python",
"python_dependencies_alias": {"dtw-python": "dtw"},
}

def __init__(
Expand All @@ -246,16 +245,6 @@ def __init__(
open_begin=False,
open_end=False,
):
"""Construct instance."""
# added manually since dtw-python has an import alias
# default check from super.__init__ does not allow aliases
_check_soft_dependencies(
"dtw-python",
package_import_alias={"dtw-python": "dtw"},
severity="error",
obj=self,
suppress_import_stdout=True,
)
super().__init__()

self.dist_trafo = dist_trafo
Expand Down

0 comments on commit 8eb36b5

Please sign in to comment.