Skip to content

Commit

Permalink
Registry lookup - all_estimators refactor, and new all_tags (#1196)
Browse files Browse the repository at this point in the history
This PR consolidates registry lookup in the `registry` module:

* `all_estimators` is moved to the `registry`, with all dependencies referencing the new location
* `all_estimators` has a new argument `filter_tags`, which allows to filter by tags (incl scitypes, capabilities, etc); order of arguments has been changed so filtering is first, output format args last
* new lookup function `all_tags`, which allows to lookup tags, possibly filtered by estimator type
* both lookups have a new argument `as_dataframe`, which allows for pretty printing in jupyter notebooks, useful for the standard user archetype
  • Loading branch information
fkiraly committed Jul 26, 2021
1 parent d296230 commit d1b5ffa
Show file tree
Hide file tree
Showing 16 changed files with 352 additions and 197 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def find_source():
def _make_estimator_overview(app):
"""Make estimator overview table."""
import pandas as pd
from sktime.utils import all_estimators
from sktime.registry import all_estimators

def _process_author_info(author_info):
"""
Expand Down
4 changes: 2 additions & 2 deletions examples/01_forecasting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@
"metadata": {},
"outputs": [],
"source": [
"from sktime.utils import all_estimators"
"from sktime.registry import all_estimators"
]
},
{
Expand All @@ -1360,7 +1360,7 @@
"outputs": [],
"source": [
"# all_estimators returns list of pairs - data frame conversion for pretty printing\n",
"pd.DataFrame(all_estimators(\"forecaster\"), columns=[\"name\", \"class\"])"
"all_estimators(\"forecaster\", as_dataframe=True)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/02_classification_univariate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1458,9 +1458,9 @@
}
],
"source": [
"from sktime.utils import all_estimators\n",
"from sktime.registry import all_estimators\n",
"\n",
"all_estimators(estimator_types=\"classifier\")"
"all_estimators(estimator_types=\"classifier\", as_dataframe=True)"
]
}
],
Expand Down
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 @@ -3,7 +3,7 @@

import pytest
from sktime.utils._testing.estimator_checks import _construct_instance, _make_args
from sktime.utils import all_estimators
from sktime.registry import all_estimators

ALL_ANNOTATORS = all_estimators(estimator_types="series-annotator", return_names=False)

Expand Down
2 changes: 1 addition & 1 deletion sktime/dists_kernels/tests/test_all_dist_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import pytest

from sktime.utils import all_estimators
from sktime.registry import all_estimators
from sktime.utils._testing.panel import make_transformer_problem
from sktime.tests._config import ESTIMATOR_TEST_PARAMS

Expand Down
2 changes: 1 addition & 1 deletion sktime/dists_kernels/tests/test_compose_tab_to_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sktime.dists_kernels.compose_tab_to_panel import AggrDist
from sktime.dists_kernels.scipy_dist import ScipyDist
from sktime.utils._testing.panel import make_transformer_problem
from sktime.utils import all_estimators
from sktime.registry import all_estimators

PAIRWISE_TRANSFORMERS_TAB = all_estimators(
estimator_types="transformer-pairwise", return_names=False
Expand Down
2 changes: 1 addition & 1 deletion sktime/forecasting/tests/test_all_forecasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from sktime.performance_metrics.forecasting import (
mean_absolute_percentage_error,
)
from sktime.utils import all_estimators
from sktime.registry import all_estimators
from sktime.utils._testing.estimator_checks import _construct_instance
from sktime.utils._testing.forecasting import _assert_correct_pred_time_index
from sktime.utils._testing.forecasting import _get_expected_index_for_update_predict
Expand Down
2 changes: 1 addition & 1 deletion sktime/forecasting/tests/test_sktime_forecasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from sktime.forecasting.base import BaseForecaster
from sktime.forecasting.base._sktime import _BaseWindowForecaster
from sktime.forecasting.model_selection import temporal_train_test_split
from sktime.utils import all_estimators
from sktime.registry import all_estimators
from sktime.utils._testing.estimator_checks import _construct_instance
from sktime.utils._testing.forecasting import make_forecasting_problem

Expand Down
14 changes: 13 additions & 1 deletion sktime/registry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# -*- coding: utf-8 -*-
"""Sktime registry module exports."""

from sktime.registry._tags import (
ESTIMATOR_TAG_REGISTER,
ESTIMATOR_TAG_LIST,
check_tag_is_valid,
)

from sktime.registry._tags import ESTIMATOR_TAG_REGISTER, ESTIMATOR_TAG_LIST
from sktime.registry._base_classes import (
BASE_CLASS_REGISTER,
BASE_CLASS_LIST,
Expand All @@ -12,7 +18,13 @@
TRANSFORMER_MIXIN_SCITYPE_LIST,
)

from sktime.registry._lookup import all_estimators, all_tags


__all__ = [
"all_estimators",
"all_tags",
"check_tag_is_valid",
"ESTIMATOR_TAG_LIST",
"ESTIMATOR_TAG_REGISTER",
"BASE_CLASS_REGISTER",
Expand Down

0 comments on commit d1b5ffa

Please sign in to comment.