Skip to content

Commit

Permalink
[ENH] Changed scitype name "series-annotator" to "detector" (skti…
Browse files Browse the repository at this point in the history
…me#7361)

#### Reference Issues/PRs
Fixes sktime#7352

Changes scitype name `series-annotator` to `detector`.

Deprecation management:
* `series-annotator` remains present in lookup
* classes now have both types with `series-annotator` as default when
coerced to a single type, but the default will change to `detector` in
0.37.0
* 1.0.0 will remove `series-annotator`
  • Loading branch information
jgyfutub authored Nov 15, 2024
1 parent 5c96fb8 commit dfcdcc5
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 11 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"
]
}

}
]
}
2 changes: 1 addition & 1 deletion sktime/annotation/tests/test_all_annotators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AnnotatorsFixtureGenerator(BaseFixtureGenerator):
# additional fixtures, parameters, etc should be added here
# TestAllAnnotators should contain the tests only

estimator_type_filter = "series-annotator"
estimator_type_filter = "detector"


class TestAllAnnotators(AnnotatorsFixtureGenerator, QuickTester):
Expand Down
4 changes: 3 additions & 1 deletion sktime/detection/base/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class BaseDetector(BaseEstimator):
"""

_tags = {
"object_type": "series-annotator", # type of object
# todo 0.37.0 switch order of series-annotator and detector
# todo 1.0.0 - remove series-annotator
"object_type": ["series-annotator", "detector"], # type of object
"learning_type": "None", # Tag to determine test in test_all_annotators
"task": "None", # Tag to determine test in test_all_annotators
#
Expand Down
28 changes: 24 additions & 4 deletions sktime/registry/_base_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ def get_base_class(cls):
return BaseRegressor


class series_annotator(_BaseScitypeOfObject):
"""Time series annotator."""
class detector(_BaseScitypeOfObject):
"""Detector of anomalies, outliers, or change points."""

_tags = {
"scitype_name": "series-annotator",
"short_descr": "time series annotator",
"scitype_name": "detector",
"short_descr": "detector - anomalies, outliers, change points",
"parent_scitype": "estimator",
}

Expand Down Expand Up @@ -519,6 +519,26 @@ def get_base_class_lookup(mixin=False, include_baseobjs=True):
return base_class_lookup


# LEGACY types - remove in 1.0.0
# ------------------------------


class series_annotator(_BaseScitypeOfObject):
"""Time series annotator."""

_tags = {
"scitype_name": "series-annotator",
"short_descr": "detector - anomalies, outliers, change points",
"parent_scitype": "estimator",
}

@classmethod
def get_base_class(cls):
from sktime.detection.base import BaseDetector

return BaseDetector


class transformer_series_to_primitives(_BaseScitypeOfObject):
"""LEGACY - time series to primitives transformer."""

Expand Down
4 changes: 4 additions & 0 deletions sktime/registry/_scitype_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ def _coerce_series_annotator_to_transformer(obj):
return AnnotatorAsTransformer(obj)


# todo 1.0.0 - remove series-annotator
_coerce_register[("series-annotator", "transformer")] = (
_coerce_series_annotator_to_transformer
)


_coerce_register[("detector", "transformer")] = _coerce_series_annotator_to_transformer


def _coerce_clusterer_to_transformer(obj):
from sktime.clustering.compose import ClustererAsTransformer

Expand Down
4 changes: 2 additions & 2 deletions sktime/registry/_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -1830,13 +1830,13 @@ class y_inner_mtype(_BaseTag):
),
(
"task",
"series-annotator",
"detector",
"str",
"subtype of series annotator, e.g., 'anomaly_detection', 'segmentation'",
),
(
"learning_type",
"series-annotator",
"detector",
"str",
"type of learning, e.g., 'supervised', 'unsupervised'",
),
Expand Down
10 changes: 9 additions & 1 deletion sktime/registry/tests/test_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,15 @@ def test_all_estimators_tag_filter(pred_int):
def test_scitype_inference(estimator_scitype):
"""Check that scitype inverts _check_estimator_types."""
base_class = _check_estimator_types(estimator_scitype)[0]
inferred_scitype = scitype(base_class)
all_scitypes = scitype(base_class, force_single_scitype=False, coerce_to_list=True)
inferred_scitype = all_scitypes[0]

# stepout for detector due to rename in scitype
# todo 0.37.0 - replace "detector" with "series-annotator"
# todo 1.0.0 - remove this stepout entirely
if estimator_scitype == "detector":
assert "detector" in all_scitypes
return None

assert (
inferred_scitype == estimator_scitype
Expand Down
2 changes: 2 additions & 0 deletions sktime/tests/test_class_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ def get_test_class_registry():
# so also imply estimator and object tests, or only object tests
testclass_dict["aligner"] = TestAllAligners
testclass_dict["classifier"] = TestAllClassifiers
testclass_dict["detector"] = TestAllAnnotators
testclass_dict["distribution"] = TestAllDistributions
testclass_dict["early_classifier"] = TestAllEarlyClassifiers
testclass_dict["forecaster"] = TestAllForecasters
testclass_dict["global_forecaster"] = TestAllGlobalForecasters
testclass_dict["param_est"] = TestAllParamFitters
testclass_dict["regressor"] = TestAllRegressors
# todo 1.0.0 - remove series-annotator
testclass_dict["series-annotator"] = TestAllAnnotators
testclass_dict["splitter"] = TestAllSplitters
testclass_dict["transformer"] = TestAllTransformers
Expand Down

0 comments on commit dfcdcc5

Please sign in to comment.