scikit-base 0.11.0__tar.gz → 0.12.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scikit_base-0.11.0/scikit_base.egg-info → scikit_base-0.12.2}/PKG-INFO +18 -8
- {scikit_base-0.11.0 → scikit_base-0.12.2}/README.md +12 -2
- {scikit_base-0.11.0 → scikit_base-0.12.2}/pyproject.toml +4 -5
- {scikit_base-0.11.0 → scikit_base-0.12.2/scikit_base.egg-info}/PKG-INFO +18 -8
- {scikit_base-0.11.0 → scikit_base-0.12.2}/scikit_base.egg-info/SOURCES.txt +3 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/scikit_base.egg-info/requires.txt +2 -2
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/__init__.py +1 -1
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/_nopytest_tests.py +1 -1
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/_base.py +45 -112
- scikit_base-0.12.2/skbase/base/_clone_base.py +129 -0
- scikit_base-0.12.2/skbase/base/_clone_plugins.py +215 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/_meta.py +8 -3
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/testing/test_all_objects.py +1 -1
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/tests/conftest.py +18 -4
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/tests/test_base.py +39 -70
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/deep_equals/_deep_equals.py +1 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/dependencies/_dependencies.py +57 -15
- scikit_base-0.12.2/skbase/utils/dependencies/_import.py +28 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/dependencies/tests/test_check_dependencies.py +53 -1
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/tests/test_deep_equals.py +2 -1
- {scikit_base-0.11.0 → scikit_base-0.12.2}/LICENSE +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/docs/source/conf.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/scikit_base.egg-info/dependency_links.txt +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/scikit_base.egg-info/top_level.txt +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/scikit_base.egg-info/zip-safe +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/setup.cfg +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/_exceptions.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/_pretty_printing/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/_pretty_printing/_object_html_repr.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/_pretty_printing/_pprint.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/_pretty_printing/tests/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/_pretty_printing/tests/test_pprint.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/base/_tagmanager.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/lookup/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/lookup/_lookup.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/lookup/tests/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/lookup/tests/test_lookup.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/testing/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/testing/utils/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/testing/utils/_conditional_fixtures.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/testing/utils/inspect.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/tests/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/tests/mock_package/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/tests/mock_package/test_mock_package.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/tests/test_baseestimator.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/tests/test_exceptions.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/tests/test_meta.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/_check.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/_iter.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/_nested_iter.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/_utils.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/deep_equals/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/deep_equals/_common.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/dependencies/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/dependencies/tests/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/random_state.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/stderr_mute.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/stdout_mute.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/tests/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/tests/test_check.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/tests/test_iter.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/tests/test_nested_iter.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/tests/test_random_state.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/tests/test_std_mute.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/utils/tests/test_utils.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/validate/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/validate/_named_objects.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/validate/_types.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/validate/tests/__init__.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/validate/tests/test_iterable_named_objects.py +0 -0
- {scikit_base-0.11.0 → scikit_base-0.12.2}/skbase/validate/tests/test_type_validations.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: scikit-base
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.2
|
4
4
|
Summary: Base classes for sklearn-like parametric objects
|
5
5
|
Author-email: sktime developers <sktime.toolbox@gmail.com>
|
6
6
|
Maintainer: Franz Király
|
@@ -50,13 +50,12 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
50
50
|
Classifier: Operating System :: POSIX
|
51
51
|
Classifier: Operating System :: Unix
|
52
52
|
Classifier: Operating System :: MacOS
|
53
|
-
Classifier: Programming Language :: Python :: 3.8
|
54
53
|
Classifier: Programming Language :: Python :: 3.9
|
55
54
|
Classifier: Programming Language :: Python :: 3.10
|
56
55
|
Classifier: Programming Language :: Python :: 3.11
|
57
56
|
Classifier: Programming Language :: Python :: 3.12
|
58
57
|
Classifier: Programming Language :: Python :: 3.13
|
59
|
-
Requires-Python: <3.14,>=3.
|
58
|
+
Requires-Python: <3.14,>=3.9
|
60
59
|
Description-Content-Type: text/markdown
|
61
60
|
License-File: LICENSE
|
62
61
|
Provides-Extra: all-extras
|
@@ -90,8 +89,8 @@ Requires-Dist: myst-parser; extra == "docs"
|
|
90
89
|
Requires-Dist: nbsphinx>=0.8.6; extra == "docs"
|
91
90
|
Requires-Dist: numpydoc; extra == "docs"
|
92
91
|
Requires-Dist: pydata-sphinx-theme; extra == "docs"
|
93
|
-
Requires-Dist: sphinx-issues<
|
94
|
-
Requires-Dist: sphinx-gallery<0.
|
92
|
+
Requires-Dist: sphinx-issues<6.0.0; extra == "docs"
|
93
|
+
Requires-Dist: sphinx-gallery<0.20.0; extra == "docs"
|
95
94
|
Requires-Dist: sphinx-panels; extra == "docs"
|
96
95
|
Requires-Dist: sphinx-design<0.7.0; extra == "docs"
|
97
96
|
Requires-Dist: Sphinx!=7.2.0,<9.0.0; extra == "docs"
|
@@ -105,6 +104,7 @@ Requires-Dist: numpy; extra == "test"
|
|
105
104
|
Requires-Dist: scipy; extra == "test"
|
106
105
|
Requires-Dist: pandas; extra == "test"
|
107
106
|
Requires-Dist: scikit-learn>=0.24.0; extra == "test"
|
107
|
+
Dynamic: license-file
|
108
108
|
|
109
109
|
<a href="https://skbase.readthedocs.io/en/latest/"><img src="https://github.com/sktime/skbase/blob/main/docs/source/images/skbase-logo-with-name.png" width="175" align="right" /></a>
|
110
110
|
|
@@ -115,7 +115,7 @@ Requires-Dist: scikit-learn>=0.24.0; extra == "test"
|
|
115
115
|
`skbase` provides base classes for creating scikit-learn-like parametric objects,
|
116
116
|
along with tools to make it easier to build your own packages that follow these design patterns.
|
117
117
|
|
118
|
-
:rocket: Version 0.
|
118
|
+
:rocket: Version 0.12.2 is now available. Check out our
|
119
119
|
[release notes](https://skbase.readthedocs.io/en/latest/changelog.html).
|
120
120
|
|
121
121
|
| Overview | |
|
@@ -141,7 +141,7 @@ For trouble shooting or more information, see our
|
|
141
141
|
[detailed installation instructions](https://skbase.readthedocs.io/en/latest/user_documentation/installation.html).
|
142
142
|
|
143
143
|
- **Operating system**: macOS X · Linux · Windows 8.1 or higher
|
144
|
-
- **Python version**: Python 3.
|
144
|
+
- **Python version**: Python 3.9, 3.10, 3.11, 3.12, and 3.13
|
145
145
|
- **Package managers**: [pip]
|
146
146
|
|
147
147
|
[pip]: https://pip.pypa.io/en/stable/
|
@@ -161,3 +161,13 @@ or, if you want to install with the maximum set of dependencies, use:
|
|
161
161
|
```bash
|
162
162
|
pip install scikit-base[all_extras]
|
163
163
|
```
|
164
|
+
|
165
|
+
## Contributors ✨
|
166
|
+
|
167
|
+
This project follows the
|
168
|
+
[all-contributors](https://github.com/all-contributors/all-contributors) specification.
|
169
|
+
Contributions of any kind welcome!
|
170
|
+
|
171
|
+
Thanks go to these wonderful people:
|
172
|
+
|
173
|
+
[skbase contributors](https://github.com/sktime/skbase/graphs/contributors)
|
@@ -7,7 +7,7 @@
|
|
7
7
|
`skbase` provides base classes for creating scikit-learn-like parametric objects,
|
8
8
|
along with tools to make it easier to build your own packages that follow these design patterns.
|
9
9
|
|
10
|
-
:rocket: Version 0.
|
10
|
+
:rocket: Version 0.12.2 is now available. Check out our
|
11
11
|
[release notes](https://skbase.readthedocs.io/en/latest/changelog.html).
|
12
12
|
|
13
13
|
| Overview | |
|
@@ -33,7 +33,7 @@ For trouble shooting or more information, see our
|
|
33
33
|
[detailed installation instructions](https://skbase.readthedocs.io/en/latest/user_documentation/installation.html).
|
34
34
|
|
35
35
|
- **Operating system**: macOS X · Linux · Windows 8.1 or higher
|
36
|
-
- **Python version**: Python 3.
|
36
|
+
- **Python version**: Python 3.9, 3.10, 3.11, 3.12, and 3.13
|
37
37
|
- **Package managers**: [pip]
|
38
38
|
|
39
39
|
[pip]: https://pip.pypa.io/en/stable/
|
@@ -53,3 +53,13 @@ or, if you want to install with the maximum set of dependencies, use:
|
|
53
53
|
```bash
|
54
54
|
pip install scikit-base[all_extras]
|
55
55
|
```
|
56
|
+
|
57
|
+
## Contributors ✨
|
58
|
+
|
59
|
+
This project follows the
|
60
|
+
[all-contributors](https://github.com/all-contributors/all-contributors) specification.
|
61
|
+
Contributions of any kind welcome!
|
62
|
+
|
63
|
+
Thanks go to these wonderful people:
|
64
|
+
|
65
|
+
[skbase contributors](https://github.com/sktime/skbase/graphs/contributors)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "scikit-base"
|
3
|
-
version = "0.
|
3
|
+
version = "0.12.2"
|
4
4
|
description = "Base classes for sklearn-like parametric objects"
|
5
5
|
authors = [
|
6
6
|
{name = "sktime developers", email = "sktime.toolbox@gmail.com"},
|
@@ -26,14 +26,13 @@ classifiers = [
|
|
26
26
|
"Operating System :: POSIX",
|
27
27
|
"Operating System :: Unix",
|
28
28
|
"Operating System :: MacOS",
|
29
|
-
"Programming Language :: Python :: 3.8",
|
30
29
|
"Programming Language :: Python :: 3.9",
|
31
30
|
"Programming Language :: Python :: 3.10",
|
32
31
|
"Programming Language :: Python :: 3.11",
|
33
32
|
"Programming Language :: Python :: 3.12",
|
34
33
|
"Programming Language :: Python :: 3.13",
|
35
34
|
]
|
36
|
-
requires-python = ">=3.
|
35
|
+
requires-python = ">=3.9,<3.14"
|
37
36
|
dependencies = []
|
38
37
|
|
39
38
|
[project.optional-dependencies]
|
@@ -71,8 +70,8 @@ docs = [
|
|
71
70
|
"nbsphinx>=0.8.6",
|
72
71
|
"numpydoc",
|
73
72
|
"pydata-sphinx-theme",
|
74
|
-
"sphinx-issues<
|
75
|
-
"sphinx-gallery<0.
|
73
|
+
"sphinx-issues<6.0.0",
|
74
|
+
"sphinx-gallery<0.20.0",
|
76
75
|
"sphinx-panels",
|
77
76
|
"sphinx-design<0.7.0",
|
78
77
|
"Sphinx!=7.2.0,<9.0.0",
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: scikit-base
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.2
|
4
4
|
Summary: Base classes for sklearn-like parametric objects
|
5
5
|
Author-email: sktime developers <sktime.toolbox@gmail.com>
|
6
6
|
Maintainer: Franz Király
|
@@ -50,13 +50,12 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
50
50
|
Classifier: Operating System :: POSIX
|
51
51
|
Classifier: Operating System :: Unix
|
52
52
|
Classifier: Operating System :: MacOS
|
53
|
-
Classifier: Programming Language :: Python :: 3.8
|
54
53
|
Classifier: Programming Language :: Python :: 3.9
|
55
54
|
Classifier: Programming Language :: Python :: 3.10
|
56
55
|
Classifier: Programming Language :: Python :: 3.11
|
57
56
|
Classifier: Programming Language :: Python :: 3.12
|
58
57
|
Classifier: Programming Language :: Python :: 3.13
|
59
|
-
Requires-Python: <3.14,>=3.
|
58
|
+
Requires-Python: <3.14,>=3.9
|
60
59
|
Description-Content-Type: text/markdown
|
61
60
|
License-File: LICENSE
|
62
61
|
Provides-Extra: all-extras
|
@@ -90,8 +89,8 @@ Requires-Dist: myst-parser; extra == "docs"
|
|
90
89
|
Requires-Dist: nbsphinx>=0.8.6; extra == "docs"
|
91
90
|
Requires-Dist: numpydoc; extra == "docs"
|
92
91
|
Requires-Dist: pydata-sphinx-theme; extra == "docs"
|
93
|
-
Requires-Dist: sphinx-issues<
|
94
|
-
Requires-Dist: sphinx-gallery<0.
|
92
|
+
Requires-Dist: sphinx-issues<6.0.0; extra == "docs"
|
93
|
+
Requires-Dist: sphinx-gallery<0.20.0; extra == "docs"
|
95
94
|
Requires-Dist: sphinx-panels; extra == "docs"
|
96
95
|
Requires-Dist: sphinx-design<0.7.0; extra == "docs"
|
97
96
|
Requires-Dist: Sphinx!=7.2.0,<9.0.0; extra == "docs"
|
@@ -105,6 +104,7 @@ Requires-Dist: numpy; extra == "test"
|
|
105
104
|
Requires-Dist: scipy; extra == "test"
|
106
105
|
Requires-Dist: pandas; extra == "test"
|
107
106
|
Requires-Dist: scikit-learn>=0.24.0; extra == "test"
|
107
|
+
Dynamic: license-file
|
108
108
|
|
109
109
|
<a href="https://skbase.readthedocs.io/en/latest/"><img src="https://github.com/sktime/skbase/blob/main/docs/source/images/skbase-logo-with-name.png" width="175" align="right" /></a>
|
110
110
|
|
@@ -115,7 +115,7 @@ Requires-Dist: scikit-learn>=0.24.0; extra == "test"
|
|
115
115
|
`skbase` provides base classes for creating scikit-learn-like parametric objects,
|
116
116
|
along with tools to make it easier to build your own packages that follow these design patterns.
|
117
117
|
|
118
|
-
:rocket: Version 0.
|
118
|
+
:rocket: Version 0.12.2 is now available. Check out our
|
119
119
|
[release notes](https://skbase.readthedocs.io/en/latest/changelog.html).
|
120
120
|
|
121
121
|
| Overview | |
|
@@ -141,7 +141,7 @@ For trouble shooting or more information, see our
|
|
141
141
|
[detailed installation instructions](https://skbase.readthedocs.io/en/latest/user_documentation/installation.html).
|
142
142
|
|
143
143
|
- **Operating system**: macOS X · Linux · Windows 8.1 or higher
|
144
|
-
- **Python version**: Python 3.
|
144
|
+
- **Python version**: Python 3.9, 3.10, 3.11, 3.12, and 3.13
|
145
145
|
- **Package managers**: [pip]
|
146
146
|
|
147
147
|
[pip]: https://pip.pypa.io/en/stable/
|
@@ -161,3 +161,13 @@ or, if you want to install with the maximum set of dependencies, use:
|
|
161
161
|
```bash
|
162
162
|
pip install scikit-base[all_extras]
|
163
163
|
```
|
164
|
+
|
165
|
+
## Contributors ✨
|
166
|
+
|
167
|
+
This project follows the
|
168
|
+
[all-contributors](https://github.com/all-contributors/all-contributors) specification.
|
169
|
+
Contributions of any kind welcome!
|
170
|
+
|
171
|
+
Thanks go to these wonderful people:
|
172
|
+
|
173
|
+
[skbase contributors](https://github.com/sktime/skbase/graphs/contributors)
|
@@ -14,6 +14,8 @@ skbase/_exceptions.py
|
|
14
14
|
skbase/_nopytest_tests.py
|
15
15
|
skbase/base/__init__.py
|
16
16
|
skbase/base/_base.py
|
17
|
+
skbase/base/_clone_base.py
|
18
|
+
skbase/base/_clone_plugins.py
|
17
19
|
skbase/base/_meta.py
|
18
20
|
skbase/base/_tagmanager.py
|
19
21
|
skbase/base/_pretty_printing/__init__.py
|
@@ -51,6 +53,7 @@ skbase/utils/deep_equals/_common.py
|
|
51
53
|
skbase/utils/deep_equals/_deep_equals.py
|
52
54
|
skbase/utils/dependencies/__init__.py
|
53
55
|
skbase/utils/dependencies/_dependencies.py
|
56
|
+
skbase/utils/dependencies/_import.py
|
54
57
|
skbase/utils/dependencies/tests/__init__.py
|
55
58
|
skbase/utils/dependencies/tests/test_check_dependencies.py
|
56
59
|
skbase/utils/tests/__init__.py
|
@@ -7,7 +7,7 @@ from skbase.lookup import all_objects
|
|
7
7
|
|
8
8
|
MODULES_TO_IGNORE = ("tests", "testing", "dependencies", "all")
|
9
9
|
|
10
|
-
#
|
10
|
+
# all_objects crawls all modules excepting pytest test files
|
11
11
|
# if it encounters an unisolated import, it will throw an exception
|
12
12
|
results = all_objects(modules_to_ignore=MODULES_TO_IGNORE)
|
13
13
|
|
@@ -60,6 +60,7 @@ from copy import deepcopy
|
|
60
60
|
from typing import List
|
61
61
|
|
62
62
|
from skbase._exceptions import NotFittedError
|
63
|
+
from skbase.base._clone_base import _check_clone, _clone
|
63
64
|
from skbase.base._pretty_printing._object_html_repr import _object_html_repr
|
64
65
|
from skbase.base._tagmanager import _FlagManager
|
65
66
|
|
@@ -175,11 +176,41 @@ class BaseObject(_FlagManager):
|
|
175
176
|
------
|
176
177
|
RuntimeError if the clone is non-conforming, due to faulty ``__init__``.
|
177
178
|
"""
|
178
|
-
|
179
|
+
# get plugins for cloning, if present (empty by default)
|
180
|
+
clone_plugins = self._get_clone_plugins()
|
181
|
+
|
182
|
+
# clone the object
|
183
|
+
self_clone = _clone(self, base_cls=BaseObject, clone_plugins=clone_plugins)
|
184
|
+
|
185
|
+
# check the clone, if check_clone is set (False by default)
|
179
186
|
if self.get_config()["check_clone"]:
|
180
187
|
_check_clone(original=self, clone=self_clone)
|
188
|
+
|
189
|
+
# return the clone
|
181
190
|
return self_clone
|
182
191
|
|
192
|
+
@classmethod
|
193
|
+
def _get_clone_plugins(cls):
|
194
|
+
"""Get clone plugins for BaseObject.
|
195
|
+
|
196
|
+
Can be overridden in subclasses to add custom clone plugins.
|
197
|
+
|
198
|
+
If implemented, must return a list of clone plugins for descendants.
|
199
|
+
|
200
|
+
Plugins are loaded ahead of the default plugins, and are used in the order
|
201
|
+
they are returned.
|
202
|
+
This allows extenders to override the default behaviours, if desired.
|
203
|
+
|
204
|
+
Returns
|
205
|
+
-------
|
206
|
+
list of str
|
207
|
+
List of clone plugins for descendants.
|
208
|
+
Each plugin must inherit from ``BaseCloner``
|
209
|
+
in ``skbase.base._clone_plugins``, and implement
|
210
|
+
the methods ``_check`` and ``_clone``.
|
211
|
+
"""
|
212
|
+
return None
|
213
|
+
|
183
214
|
@classmethod
|
184
215
|
def _get_init_signature(cls):
|
185
216
|
"""Get class init signature.
|
@@ -1138,13 +1169,19 @@ class BaseObject(_FlagManager):
|
|
1138
1169
|
class TagAliaserMixin:
|
1139
1170
|
"""Mixin class for tag aliasing and deprecation of old tags.
|
1140
1171
|
|
1141
|
-
To deprecate tags, add the TagAliaserMixin to BaseObject
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1172
|
+
To deprecate tags, add the ``TagAliaserMixin`` to ``BaseObject``
|
1173
|
+
or ``BaseEstimator``.
|
1174
|
+
|
1175
|
+
``alias_dict`` contains the deprecated tags, and supports removal and renaming.
|
1176
|
+
|
1177
|
+
* For removal, add an entry ``"old_tag_name": ""``
|
1178
|
+
* For renaming, add an entry ``"old_tag_name": "new_tag_name"``
|
1179
|
+
|
1180
|
+
``deprecate_dict`` contains the version number of renaming or removal.
|
1181
|
+
|
1182
|
+
* The keys in ``deprecate_dict`` should be the same as in alias_dict.
|
1183
|
+
* Values in ``deprecate_dict`` should be strings, the version of
|
1184
|
+
removal/renaming, in PEP 440 format, e.g., ``"1.0.0"``.
|
1148
1185
|
|
1149
1186
|
The class will ensure that new tags alias old tags and vice versa, during
|
1150
1187
|
the deprecation period. Informative warnings will be raised whenever the
|
@@ -1653,107 +1690,3 @@ class BaseEstimator(BaseObject):
|
|
1653
1690
|
fitted parameters, keyed by names of fitted parameter
|
1654
1691
|
"""
|
1655
1692
|
return self._get_fitted_params_default()
|
1656
|
-
|
1657
|
-
|
1658
|
-
# Adapted from sklearn's `_clone_parametrized()`
|
1659
|
-
def _clone(estimator, *, safe=True):
|
1660
|
-
"""Construct a new unfitted estimator with the same parameters.
|
1661
|
-
|
1662
|
-
Clone does a deep copy of the model in an estimator
|
1663
|
-
without actually copying attached data. It returns a new estimator
|
1664
|
-
with the same parameters that has not been fitted on any data.
|
1665
|
-
|
1666
|
-
Parameters
|
1667
|
-
----------
|
1668
|
-
estimator : {list, tuple, set} of estimator instance or a single \
|
1669
|
-
estimator instance
|
1670
|
-
The estimator or group of estimators to be cloned.
|
1671
|
-
safe : bool, default=True
|
1672
|
-
If safe is False, clone will fall back to a deep copy on objects
|
1673
|
-
that are not estimators.
|
1674
|
-
|
1675
|
-
Returns
|
1676
|
-
-------
|
1677
|
-
estimator : object
|
1678
|
-
The deep copy of the input, an estimator if input is an estimator.
|
1679
|
-
|
1680
|
-
Notes
|
1681
|
-
-----
|
1682
|
-
If the estimator's `random_state` parameter is an integer (or if the
|
1683
|
-
estimator doesn't have a `random_state` parameter), an *exact clone* is
|
1684
|
-
returned: the clone and the original estimator will give the exact same
|
1685
|
-
results. Otherwise, *statistical clone* is returned: the clone might
|
1686
|
-
return different results from the original estimator. More details can be
|
1687
|
-
found in :ref:`randomness`.
|
1688
|
-
"""
|
1689
|
-
estimator_type = type(estimator)
|
1690
|
-
if estimator_type is dict:
|
1691
|
-
return {k: _clone(v, safe=safe) for k, v in estimator.items()}
|
1692
|
-
if estimator_type in (list, tuple, set, frozenset):
|
1693
|
-
return estimator_type([_clone(e, safe=safe) for e in estimator])
|
1694
|
-
elif not hasattr(estimator, "get_params") or isinstance(estimator, type):
|
1695
|
-
if not safe:
|
1696
|
-
return deepcopy(estimator)
|
1697
|
-
else:
|
1698
|
-
if isinstance(estimator, type):
|
1699
|
-
raise TypeError(
|
1700
|
-
"Cannot clone object. "
|
1701
|
-
+ "You should provide an instance of "
|
1702
|
-
+ "scikit-learn estimator instead of a class."
|
1703
|
-
)
|
1704
|
-
else:
|
1705
|
-
raise TypeError(
|
1706
|
-
"Cannot clone object '%s' (type %s): "
|
1707
|
-
"it does not seem to be a scikit-learn "
|
1708
|
-
"estimator as it does not implement a "
|
1709
|
-
"'get_params' method." % (repr(estimator), type(estimator))
|
1710
|
-
)
|
1711
|
-
|
1712
|
-
klass = estimator.__class__
|
1713
|
-
new_object_params = estimator.get_params(deep=False)
|
1714
|
-
for name, param in new_object_params.items():
|
1715
|
-
new_object_params[name] = _clone(param, safe=False)
|
1716
|
-
new_object = klass(**new_object_params)
|
1717
|
-
params_set = new_object.get_params(deep=False)
|
1718
|
-
|
1719
|
-
# quick sanity check of the parameters of the clone
|
1720
|
-
for name in new_object_params:
|
1721
|
-
param1 = new_object_params[name]
|
1722
|
-
param2 = params_set[name]
|
1723
|
-
if param1 is not param2:
|
1724
|
-
raise RuntimeError(
|
1725
|
-
"Cannot clone object %s, as the constructor "
|
1726
|
-
"either does not set or modifies parameter %s" % (estimator, name)
|
1727
|
-
)
|
1728
|
-
|
1729
|
-
# This is an extension to the original sklearn implementation
|
1730
|
-
if isinstance(estimator, BaseObject) and estimator.get_config()["clone_config"]:
|
1731
|
-
new_object.set_config(**estimator.get_config())
|
1732
|
-
|
1733
|
-
return new_object
|
1734
|
-
|
1735
|
-
|
1736
|
-
def _check_clone(original, clone):
|
1737
|
-
from skbase.utils.deep_equals import deep_equals
|
1738
|
-
|
1739
|
-
self_params = original.get_params(deep=False)
|
1740
|
-
|
1741
|
-
# check that all attributes are written to the clone
|
1742
|
-
for attrname in self_params.keys():
|
1743
|
-
if not hasattr(clone, attrname):
|
1744
|
-
raise RuntimeError(
|
1745
|
-
f"error in {original}.clone, __init__ must write all arguments "
|
1746
|
-
f"to self and not mutate them, but {attrname} was not found. "
|
1747
|
-
f"Please check __init__ of {original}."
|
1748
|
-
)
|
1749
|
-
|
1750
|
-
clone_attrs = {attr: getattr(clone, attr) for attr in self_params.keys()}
|
1751
|
-
|
1752
|
-
# check equality of parameters post-clone and pre-clone
|
1753
|
-
clone_attrs_valid, msg = deep_equals(self_params, clone_attrs, return_msg=True)
|
1754
|
-
if not clone_attrs_valid:
|
1755
|
-
raise RuntimeError(
|
1756
|
-
f"error in {original}.clone, __init__ must write all arguments "
|
1757
|
-
f"to self and not mutate them, but this is not the case. "
|
1758
|
-
f"Error on equality check of arguments (x) vs parameters (y): {msg}"
|
1759
|
-
)
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# copyright: skbase developers, BSD-3-Clause License (see LICENSE file)
|
3
|
+
# Elements of BaseObject reuse code developed in scikit-learn. These elements
|
4
|
+
# are copyrighted by the scikit-learn developers, BSD-3-Clause License. For
|
5
|
+
# conditions see https://github.com/scikit-learn/scikit-learn/blob/main/COPYING
|
6
|
+
"""Logic and plugins for cloning objects.
|
7
|
+
|
8
|
+
This module contains logic for cloning objects:
|
9
|
+
|
10
|
+
_clone(estimator, *, safe=True, plugins=None) - central entry point for cloning
|
11
|
+
_check_clone(original, clone) - validation utility to check clones
|
12
|
+
|
13
|
+
Default plugins for _clone are stored in _clone_plugins:
|
14
|
+
|
15
|
+
DEFAULT_CLONE_PLUGINS - list with default plugins for cloning
|
16
|
+
|
17
|
+
Each element of DEFAULT_CLONE_PLUGINS inherits from BaseCloner, with methods:
|
18
|
+
|
19
|
+
* check(obj) -> boolean - fast checker whether plugin applies
|
20
|
+
* clone(obj) -> type(obj) - method to clone obj
|
21
|
+
"""
|
22
|
+
__all__ = ["_clone", "_check_clone"]
|
23
|
+
|
24
|
+
from skbase.base._clone_plugins import DEFAULT_CLONE_PLUGINS
|
25
|
+
|
26
|
+
|
27
|
+
# Adapted from sklearn's `_clone_parametrized()`
|
28
|
+
def _clone(estimator, *, safe=True, clone_plugins=None, base_cls=None):
|
29
|
+
"""Construct a new unfitted estimator with the same parameters.
|
30
|
+
|
31
|
+
Clone does a deep copy of the model in an estimator
|
32
|
+
without actually copying attached data. It returns a new estimator
|
33
|
+
with the same parameters that has not been fitted on any data.
|
34
|
+
|
35
|
+
Parameters
|
36
|
+
----------
|
37
|
+
estimator : {list, tuple, set} of estimator instance or a single estimator instance
|
38
|
+
The estimator or group of estimators to be cloned.
|
39
|
+
safe : bool, default=True
|
40
|
+
If ``safe`` is False, clone will fall back to a deep copy on objects
|
41
|
+
that are not estimators.
|
42
|
+
clone_plugins : list of BaseCloner clone plugins, concrete descendant classes.
|
43
|
+
Must implement ``_check`` and ``_clone`` method, see ``BaseCloner`` interface.
|
44
|
+
If passed, will work through clone plugins in ``clone_plugins``
|
45
|
+
before working through ``DEFAULT_CLONE_PLUGINS``. To override
|
46
|
+
a cloner in ``DEAULT_CLONE_PLUGINS``, simply ensure a cloner with
|
47
|
+
the same ``_check`` logis is present in ``clone_plugins``.
|
48
|
+
base_cls : reference to BaseObject
|
49
|
+
Reference to the BaseObject class from skbase.base._base.
|
50
|
+
Present for easy reference, fast imports, and potential extensions.
|
51
|
+
|
52
|
+
Returns
|
53
|
+
-------
|
54
|
+
estimator : object
|
55
|
+
The deep copy of the input, an estimator if input is an estimator.
|
56
|
+
|
57
|
+
Notes
|
58
|
+
-----
|
59
|
+
If the estimator's `random_state` parameter is an integer (or if the
|
60
|
+
estimator doesn't have a `random_state` parameter), an *exact clone* is
|
61
|
+
returned: the clone and the original estimator will give the exact same
|
62
|
+
results. Otherwise, *statistical clone* is returned: the clone might
|
63
|
+
return different results from the original estimator. More details can be
|
64
|
+
found in :ref:`randomness`.
|
65
|
+
"""
|
66
|
+
# handle cloning plugins:
|
67
|
+
# if no plugins provided by user, work through the DEFAULT_CLONE_PLUGINS
|
68
|
+
# if provided by user, work through user provided plugins first, then defaults
|
69
|
+
if clone_plugins is not None:
|
70
|
+
all_plugins = clone_plugins.copy()
|
71
|
+
all_plugins.append(DEFAULT_CLONE_PLUGINS.copy())
|
72
|
+
else:
|
73
|
+
all_plugins = DEFAULT_CLONE_PLUGINS
|
74
|
+
|
75
|
+
for cloner_plugin in all_plugins:
|
76
|
+
cloner = cloner_plugin(safe=safe, clone_plugins=all_plugins, base_cls=base_cls)
|
77
|
+
# we clone with the first plugin in the list that:
|
78
|
+
# 1. claims it is applicable, via check
|
79
|
+
# 2. does not produce an Exception when cloning
|
80
|
+
if cloner.check(obj=estimator):
|
81
|
+
return cloner.clone(obj=estimator)
|
82
|
+
|
83
|
+
raise RuntimeError(
|
84
|
+
"Error in skbase _clone, catch-all plugin did not catch all "
|
85
|
+
"remaining cases. This is likely due to custom modification of the module."
|
86
|
+
)
|
87
|
+
|
88
|
+
|
89
|
+
def _check_clone(original, clone):
|
90
|
+
"""Check that clone is a valid clone of original.
|
91
|
+
|
92
|
+
Called from BaseObject.clone to validate the clone, if
|
93
|
+
the config flag check_clone is set to True.
|
94
|
+
|
95
|
+
Parameters
|
96
|
+
----------
|
97
|
+
original : object
|
98
|
+
The original object.
|
99
|
+
clone : object
|
100
|
+
The cloned object.
|
101
|
+
|
102
|
+
Raises
|
103
|
+
------
|
104
|
+
RuntimeError
|
105
|
+
If the clone is not a valid clone of the original.
|
106
|
+
"""
|
107
|
+
from skbase.utils.deep_equals import deep_equals
|
108
|
+
|
109
|
+
self_params = original.get_params(deep=False)
|
110
|
+
|
111
|
+
# check that all attributes are written to the clone
|
112
|
+
for attrname in self_params.keys():
|
113
|
+
if not hasattr(clone, attrname):
|
114
|
+
raise RuntimeError(
|
115
|
+
f"error in {original}.clone, __init__ must write all arguments "
|
116
|
+
f"to self and not mutate them, but {attrname} was not found. "
|
117
|
+
f"Please check __init__ of {original}."
|
118
|
+
)
|
119
|
+
|
120
|
+
clone_attrs = {attr: getattr(clone, attr) for attr in self_params.keys()}
|
121
|
+
|
122
|
+
# check equality of parameters post-clone and pre-clone
|
123
|
+
clone_attrs_valid, msg = deep_equals(self_params, clone_attrs, return_msg=True)
|
124
|
+
if not clone_attrs_valid:
|
125
|
+
raise RuntimeError(
|
126
|
+
f"error in {original}.clone, __init__ must write all arguments "
|
127
|
+
f"to self and not mutate them, but this is not the case. "
|
128
|
+
f"Error on equality check of arguments (x) vs parameters (y): {msg}"
|
129
|
+
)
|