Skip to content

Commit

Permalink
Merge branch 'main' into pr/7389
Browse files Browse the repository at this point in the history
  • Loading branch information
fkiraly committed Nov 16, 2024
2 parents 66b2f46 + 4ab0218 commit 0b109b3
Show file tree
Hide file tree
Showing 28 changed files with 1,091 additions and 824 deletions.
12 changes: 10 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3174,6 +3174,15 @@
"code"
]
},
{
"login": "jgyfutub",
"name": "Vedant Pandey",
"avatar_url": "https://avatars.githubusercontent.com/u/97391064?s=400&v=4",
"profile": "https://github.com/jgyfutub",
"contributions": [
"code"
]
},
{
"login": "manolotis",
"name": "Manuel Muñoz Sánchez",
Expand All @@ -3182,7 +3191,6 @@
"contributions": [
"doc"
]
}

}
]
}
16 changes: 16 additions & 0 deletions docs/source/api_reference/data_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ The ``Series`` mtype represents a single time series.

.. currentmodule:: sktime.datatypes._series._check

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

SeriesPdDataFrame
SeriesPdSeries
SeriesNp2D
Expand All @@ -93,6 +97,10 @@ The ``Panel`` mtype represents a flat collection of time series.

.. currentmodule:: sktime.datatypes._panel._check

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

PanelPdMultiIndex
PanelNp3D
PanelDfList
Expand All @@ -109,6 +117,10 @@ The ``Hierarchical`` mtype represents a hierarchical collection of time series.

.. currentmodule:: sktime.datatypes._hierarchical._check

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

HierarchicalPdMultiIndex
HierarchicalDask
HierarchicalPolarsEager
Expand All @@ -121,6 +133,10 @@ The ``Table`` mtype represents a (non-temporal) data frame table.

.. currentmodule:: sktime.datatypes._table._check

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

TablePdDataFrame
TablePdSeries
TableNp1D
Expand Down
41 changes: 24 additions & 17 deletions extension_templates/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
https://www.sktime.net/en/stable/developer_guide/add_estimators.html
Mandatory implements:
fitting - _fit(self, X, Y=None)
fitting - _fit(self, X, y=None)
annotating - _predict(self, X)
Optional implements:
updating - _update(self, X, Y=None)
updating - _update(self, X, y=None)
Testing - required for sktime test framework and check_estimator usage:
get default parameters for test instance(s) - get_test_params()
copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
"""

from sktime.annotation.base import BaseSeriesAnnotator
from sktime.detection.base import BaseDetector

# todo: add any necessary imports here


class MySeriesAnnotator(BaseSeriesAnnotator):
"""Custom series annotator.
class MyDetector(BaseDetector):
"""Custom time series detector for anomalies, change points, or segments.
todo: write docstring, describing your custom forecaster
Expand Down Expand Up @@ -106,21 +106,22 @@ def __init__(
# self.clone_tags(est2, ["enforce_index_type", "handles-missing-data"])

# todo: implement this, mandatory
def _fit(self, X, Y=None):
def _fit(self, X, y=None):
"""Fit to training data.
core logic
Parameters
----------
X : pd.DataFrame
training data to fit model to, time series
Y : pd.Series, optional
ground truth annotations for training if annotator is supervised
Training data to fit model to time series.
y : pd.Series, optional
Ground truth labels for training, if detector is supervised.
Returns
-------
self : returns a reference to self
self :
Reference to self.
State change
------------
Expand All @@ -138,30 +139,36 @@ def _predict(self, X):
Parameters
----------
X : pd.DataFrame - data to annotate, time series
X : pd.DataFrame
Time series subject to detection, which will be assigned labels or scores.
Returns
-------
Y : pd.Series - annotations for sequence X
exact format depends on annotation type
y : pd.Series with RangeIndex
Labels for sequence ``X``, in sparse format.
Values are ``iloc`` references to indices of ``X``.
* If ``task`` is ``"anomaly_detection"`` or ``"change_point_detection"``,
the values are integer indices of the changepoints/anomalies.
* If ``task`` is "segmentation", the values are ``pd.Interval`` objects.
"""

# implement here
# IMPORTANT: avoid side effects to X, fh

# todo: consider implementing this, optional
# if not implementing, delete the _update method
def _update(self, X, Y=None):
"""Update model with new data and optional ground truth annotations.
def _update(self, X, y=None):
"""Update model with new data and optional ground truth labels.
core logic
Parameters
----------
X : pd.DataFrame
training data to update model with, time series
Y : pd.Series, optional
ground truth annotations for training if annotator is supervised
y : pd.Series, optional
ground truth detection labels for training, if detector is supervised
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ all_extras_pandas2 = [
'autots<0.7,>=0.6.1; python_version < "3.13"',
'cloudpickle; python_version < "3.13"',
'dash!=2.9.0; python_version < "3.13"',
"dask<2024.10.1; extra == 'dataframe'",
"dask<2024.11.3; extra == 'dataframe'",
'dtaidistance<2.4; python_version < "3.13"',
'dtw-python; python_version < "3.13"',
'esig==0.9.7; python_version < "3.10"',
Expand Down
7 changes: 4 additions & 3 deletions sktime/annotation/adapters/_pyod.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import numpy as np
from sklearn.base import clone

from sktime.annotation.base._base import BaseSeriesAnnotator
from sktime.detection.base import BaseDetector
from sktime.utils.dependencies import _check_soft_dependencies

__author__ = ["mloning", "satya-pattnaik", "fkiraly"]

import pandas as pd


class PyODAnnotator(BaseSeriesAnnotator):
class PyODAnnotator(BaseDetector):
"""Transformer that applies outlier detector from pyOD.
Parameters
Expand Down Expand Up @@ -82,7 +82,8 @@ def _predict(self, X):
Parameters
----------
X : pd.DataFrame - data to annotate, time series
X : pd.DataFrame
Time series subject to detection, which will be assigned labels or scores.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion sktime/annotation/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__all__ = ["BaseSeriesAnnotator"]

from sktime.annotation.base._base import BaseSeriesAnnotator
from sktime.detection.base._base import BaseSeriesAnnotator
Loading

0 comments on commit 0b109b3

Please sign in to comment.