Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor sub modules #78

Merged
merged 22 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update naming of _HeterogenousMetaEstimator
  • Loading branch information
RNKuhns committed Nov 30, 2022
commit a048fa5a0f97e260eb594af67ac186ec4991047d
20 changes: 13 additions & 7 deletions skbase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
sktime design principles in your project.
"""
import warnings
from typing import List

from skbase.base import BaseEstimator, BaseObject, _HeterogenousMetaEstimator
from skbase.base import BaseEstimator, BaseMetaEstimator, BaseObject
from skbase.base._meta import _HeterogenousMetaEstimator
from skbase.lookup import all_objects, get_package_metadata

__version__ = "0.2.0"
__version__: str = "0.2.0"

__author__ = ["mloning", "RNKuhns", "fkiraly"]
__all__ = [
__author__: List[str] = ["mloning", "RNKuhns", "fkiraly"]
__all__: List[str] = [
"BaseObject",
"BaseEstimator",
"BaseMetaEstimator",
"_HeterogenousMetaEstimator",
"all_objects",
"get_package_metadata",
Expand All @@ -26,10 +29,13 @@
" ".join(
[
"Importing from the `skbase` module is deprecated as of version 0.3.0.",
"Ability to import from `skbase` will be removed in version 0.5.0."
"Import BaseObject, BaseEstimator, and _HeterogenousMetaEstimator"
"from skbase.base. Import lookup functionality "
"Ability to import from `skbase` will be removed in version 0.5.0.",
"Import BaseObject, BaseEstimator, and HeterogenousMetaEstimator",
"from skbase.base. Import lookup functionality ",
"(all_objects, get_package_metadata) from skbase.lookup.",
"_HeterogenousMetaEstimator has been depracated as of version 0.3.0.",
"Functionality is available as part of BaseMetaEstimator.",
"_HeterogenousMetaEstimator will be removed in version 0.5.0.",
]
),
DeprecationWarning,
Expand Down
13 changes: 7 additions & 6 deletions skbase/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
The included functionality makes it easy to re-use scikit-learn and
sktime design principles in your project.
"""
from typing import List

__author__ = ["mloning", "RNKuhns", "fkiraly"]
__all__ = [
from skbase.base._base import BaseEstimator, BaseObject
from skbase.base._meta import BaseMetaEstimator

__author__: List[str] = ["mloning", "RNKuhns", "fkiraly"]
__all__: List[str] = [
"BaseObject",
"BaseEstimator",
"_HeterogenousMetaEstimator",
"BaseMetaEstimator",
]

from skbase.base._base import BaseEstimator, BaseObject
from skbase.base._meta import _HeterogenousMetaEstimator
31 changes: 26 additions & 5 deletions skbase/base/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
# are copyrighted by the scikit-learn developers, BSD-3-Clause License. For
# conditions see https://github.com/scikit-learn/scikit-learn/blob/main/COPYING
"""Implements meta estimator for estimators composed of other estimators."""

__author__ = ["mloning", "fkiraly"]
__all__ = ["_HeterogenousMetaEstimator"]

import warnings
from inspect import isclass
from typing import List

from skbase.base._base import BaseEstimator

__author__: List[str] = ["mloning", "fkiraly"]
__all__: List[str] = ["BaseMetaEstimator"]


class _HeterogenousMetaEstimator(BaseEstimator):
class BaseMetaEstimator(BaseEstimator):
"""Handles parameter management for estimators composed of named estimators.

Partly adapted from sklearn utils.metaestimator.py.
Expand Down Expand Up @@ -656,3 +657,23 @@ def unflat_len(obj):
def is_flat(obj):
"""Check whether list or tuple is flat, returns true if yes, false if nested."""
return not any(isinstance(x, (list, tuple)) for x in obj)


class _HeterogenousMetaEstimator(BaseMetaEstimator):
"""Handles parameter management for estimators composed of named estimators.

Partly adapted from sklearn utils.metaestimator.py.
"""

def __init__(self):
super().__init__()
warnings.warn(
" ".join(
[
"_HeterogenousMetaEstimator has been depracated. Functionality is",
"available as part of BaseMetaEstimator.",
"_HeterogenousMetaEstimator will be removed in version 0.5.0.",
]
),
DeprecationWarning,
)