Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tpvasconcelos
Copy link
Contributor

@tpvasconcelos tpvasconcelos commented Dec 17, 2023

Reference Issues/PRs

Fixes #4818

What does this implement/fix? Explain your changes.

Does your contribution introduce a new dependency? If yes, which one?

No.

What should a reviewer concentrate their feedback on?

Note that this implementation was heavily inspired by the existing FunctionTransformer implementation.

Did you add any tests for the change?

Doctests only

PR checklist

For all contributions
  • I've added myself to the list of contributors with any new badges I've earned :-)
    How to: add yourself to the all-contributors file in the sktime root directory (not the CONTRIBUTORS.md). Common badges: code - fixing a bug, or adding code logic. doc - writing or improving documentation or docstrings. bug - reporting or diagnosing a bug (get this plus code if you also fixed the bug in the PR).maintenance - CI, test framework, release.
    See here for full badge reference
  • Optionally, I've added myself and possibly others to the CODEOWNERS file - do this if you want to become the owner or maintainer of an estimator you added.
    See here for further details on the algorithm maintainer role.
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is great and I would approve it once docs are complete. Example in the docstring is also very nice and clear. Let's also separate out the base class refactor, this is a very good spot but separate topic and likely to lead to longer discussion

Docs:

  • should be added to API reference, docs/source/api_reference
  • docstring is incomplete, params are missing

Suggestions for improvement, non-blocking:

  • in the example, you could also use get_fitted_params to look at the selected_forecaster, and carry out the combination with the MultiplexForecaster to have a form of custom tuning!
  • let's not have too many estimators in one file, especially the compose modules have gotten bloated in the past. I would suggest, turn it into a folder with private files and export at the compose module level, similar to forecasting.compose.

@tpvasconcelos
Copy link
Contributor Author

@fkiraly Thanks for all the feedback! I belive all points have been addressed. I will open this PR for a full review now :)

@tpvasconcelos tpvasconcelos marked this pull request as ready for review December 17, 2023 21:10
@tpvasconcelos
Copy link
Contributor Author

fkiraly pushed a commit that referenced this pull request Dec 19, 2023
#### Reference Issues/PRs

Relates to #5630

#### What does this implement/fix? Explain your changes.

Small adjustment to `FunctionTransformer`'s docstring, related to
changed made in #5630
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, changes have been addressed. Thanks!

@fkiraly
Copy link
Collaborator

fkiraly commented Dec 20, 2023

One non-blocking comment, I am slightly wondering about the case of multiple fitted parameters, but none of the ways in which one could generalize makes me happy, so I would suggest to leave the signature as is.

@fkiraly fkiraly added enhancement Adding new functionality module:parameter-estimators parameter fitters and estimators labels Dec 20, 2023
@tpvasconcelos
Copy link
Contributor Author

tpvasconcelos commented Dec 20, 2023

One non-blocking comment, I am slightly wondering about the case of multiple fitted parameters, but none of the ways in which one could generalize makes me happy, so I would suggest to leave the signature as is.

hmm what about something like this:

class MultiParamFitter(BaseParamFitter):
    def __init__(self, fitters: dict[str, Callable]):
        self.fitters = fitters

    def _fit(self, X):
        for param, fitter in self.fitters.items():
            param = param.rstrip("_") + "_"
            setattr(self, param, self.func(X))
        return self

If passing kwargs to the functions is a requirement, I think the cleanest solution is to require users to use something like functools.partial. For instance:

MultiParamFitter({"my_param": partial(my_fitter, a="foo", b="bar")})

@fkiraly
Copy link
Collaborator

fkiraly commented Dec 21, 2023

yes, thought of that - do not like it since the user has to pass an iterable, which is confusing in the single fitter case.

Other option is returning dict, which is confusing in the single parameter case...

The optimal solution would have intuitive syntax in the simple cases, and consistent syntax in the more complicated ones.

@fkiraly fkiraly merged commit 5ce06b1 into sktime:main Dec 21, 2023
fkiraly pushed a commit that referenced this pull request Jan 12, 2024
…ter` inheritance of that method (#5633)

Relates to discussions had on #5630 

#### What does this implement/fix? Explain your changes.

See #5630 (comment)
@tpvasconcelos tpvasconcelos deleted the param-selector branch September 5, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Adding new functionality module:parameter-estimators parameter fitters and estimators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] conditional forecaster multiplexing by instance property, e.g., slow or fast moving goods

2 participants