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

[ENH] forecasting pipeline get_fitted_params #3863

Merged
merged 1 commit into from Dec 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions sktime/forecasting/compose/_pipeline.py
Expand Up @@ -177,6 +177,43 @@ def _steps(self):
def _steps(self, value):
self.steps = value

def _components(self, base_class=None):
"""Return references to all state changing BaseObject type attributes.

This *excludes* the blue-print-like components passed in the __init__.

Caution: this method returns *references* and not *copies*.
Writing to the reference will change the respective attribute of self.

Parameters
----------
base_class : class, optional, default=None, must be subclass of BaseObject
if None, behaves the same as `base_class=BaseObject`
if not None, return dict collects descendants of `base_class`

Returns
-------
dict with key = attribute name, value = reference to attribute
dict contains all attributes of `self` that inherit from `base_class`, and:
whose names do not contain the string "__", e.g., hidden attributes
are not class attributes, and are not hyper-parameters (`__init__` args)
"""
import inspect

from sktime.base import BaseObject

if base_class is None:
base_class = BaseObject
if base_class is not None and not inspect.isclass(base_class):
raise TypeError(f"base_class must be a class, but found {type(base_class)}")
# if base_class is not None and not issubclass(base_class, BaseObject):
# raise TypeError("base_class must be a subclass of BaseObject")

fitted_estimator_tuples = self.steps_

comp_dict = {name: comp for (name, comp) in fitted_estimator_tuples}
return comp_dict

# both children use the same step params for testing, so putting it here
@classmethod
def get_test_params(cls, parameter_set="default"):
Expand Down