Describe the bug
BaseObject clone does not clone the config of nested BaseObjects.
The issue popped up when I was trying to set a {"backend:parallel": "joblib"} config to a forecaster but the config was getting removed when a wrapper pipeline object would get cloned (which seems to happen at various places throughout the sktime project)
To Reproduce
from sktime.forecasting.compose import TransformedTargetForecaster
from sktime.forecasting.naive import NaiveForecaster
pipeline = TransformedTargetForecaster(
[("forecaster", NaiveForecaster().set_config(foo="bar"))]
)
assert pipeline.forecaster_.get_config()["foo"] == "bar"
pipeline_clone = pipeline.clone()
assert pipeline_clone == pipeline
pipeline_clone.forecaster_.get_config()["foo"] == "bar"
# Traceback (most recent call last):
# ...
# KeyError: 'foo'
Expected behavior
Expected all configs from nested objects to get cloned on .clone()
Additional context
The fix would be an extension to the work done in #257
If you agree, I'd be happy to contribute the fix to the skbase project. For reference, I opened this PR with a proposed patch ---> #275
Versions
Details
System:
python: 3.10.13 (main, Aug 24 2023, 12:59:26) [Clang 15.0.0 (clang-1500.0.40.1)]
executable: .venv/bin/python
machine: macOS-14.2.1-arm64-arm-64bit
Python dependencies:
pip: 23.3.1
sktime: 0.26.0
sklearn: 1.4.0
skbase: 0.7.1
numpy: 1.26.3
scipy: 1.12.0
pandas: 2.1.4
matplotlib: 3.8.2
joblib: 1.3.2
numba: 0.58.1
statsmodels: 0.14.1
pmdarima: 2.0.4
statsforecast: 1.7.1
tsfresh: None
tslearn: None
torch: None
tensorflow: None
tensorflow_probability: None
Describe the bug
BaseObjectclone does not clone the config of nestedBaseObjects.The issue popped up when I was trying to set a
{"backend:parallel": "joblib"}config to a forecaster but the config was getting removed when a wrapper pipeline object would get cloned (which seems to happen at various places throughout the sktime project)To Reproduce
Expected behavior
Expected all configs from nested objects to get cloned on
.clone()Additional context
The fix would be an extension to the work done in #257
If you agree, I'd be happy to contribute the fix to the
skbaseproject. For reference, I opened this PR with a proposed patch ---> #275Versions
Details
System:
python: 3.10.13 (main, Aug 24 2023, 12:59:26) [Clang 15.0.0 (clang-1500.0.40.1)]
executable: .venv/bin/python
machine: macOS-14.2.1-arm64-arm-64bit
Python dependencies:
pip: 23.3.1
sktime: 0.26.0
sklearn: 1.4.0
skbase: 0.7.1
numpy: 1.26.3
scipy: 1.12.0
pandas: 2.1.4
matplotlib: 3.8.2
joblib: 1.3.2
numba: 0.58.1
statsmodels: 0.14.1
pmdarima: 2.0.4
statsforecast: 1.7.1
tsfresh: None
tslearn: None
torch: None
tensorflow: None
tensorflow_probability: None