scikit-base 0.5.0__py3-none-any.whl → 0.5.1__py3-none-any.whl
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.5.0.dist-info → scikit_base-0.5.1.dist-info}/METADATA +17 -15
- {scikit_base-0.5.0.dist-info → scikit_base-0.5.1.dist-info}/RECORD +11 -11
- {scikit_base-0.5.0.dist-info → scikit_base-0.5.1.dist-info}/WHEEL +1 -1
- skbase/__init__.py +1 -1
- skbase/base/_meta.py +21 -9
- skbase/testing/test_all_objects.py +7 -11
- skbase/tests/test_meta.py +48 -9
- skbase/utils/deep_equals.py +1 -1
- {scikit_base-0.5.0.dist-info → scikit_base-0.5.1.dist-info}/LICENSE +0 -0
- {scikit_base-0.5.0.dist-info → scikit_base-0.5.1.dist-info}/top_level.txt +0 -0
- {scikit_base-0.5.0.dist-info → scikit_base-0.5.1.dist-info}/zip-safe +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: scikit-base
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.1
|
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
|
@@ -63,21 +63,21 @@ Requires-Dist: pandas ; extra == 'all_extras'
|
|
63
63
|
Provides-Extra: binder
|
64
64
|
Requires-Dist: jupyter ; extra == 'binder'
|
65
65
|
Provides-Extra: dev
|
66
|
-
Requires-Dist: scikit-learn
|
66
|
+
Requires-Dist: scikit-learn >=0.24.0 ; extra == 'dev'
|
67
67
|
Requires-Dist: pre-commit ; extra == 'dev'
|
68
68
|
Requires-Dist: pytest ; extra == 'dev'
|
69
69
|
Requires-Dist: pytest-cov ; extra == 'dev'
|
70
70
|
Provides-Extra: docs
|
71
71
|
Requires-Dist: jupyter ; extra == 'docs'
|
72
72
|
Requires-Dist: myst-parser ; extra == 'docs'
|
73
|
-
Requires-Dist: nbsphinx
|
73
|
+
Requires-Dist: nbsphinx >=0.8.6 ; extra == 'docs'
|
74
74
|
Requires-Dist: numpydoc ; extra == 'docs'
|
75
75
|
Requires-Dist: pydata-sphinx-theme ; extra == 'docs'
|
76
|
-
Requires-Dist: sphinx-issues
|
77
|
-
Requires-Dist: sphinx-gallery
|
76
|
+
Requires-Dist: sphinx-issues ==1.2.0 ; extra == 'docs'
|
77
|
+
Requires-Dist: sphinx-gallery ==0.6.0 ; extra == 'docs'
|
78
78
|
Requires-Dist: sphinx-panels ; extra == 'docs'
|
79
|
-
Requires-Dist: sphinx-design
|
80
|
-
Requires-Dist: sphinx
|
79
|
+
Requires-Dist: sphinx-design ==0.3.0 ; extra == 'docs'
|
80
|
+
Requires-Dist: sphinx ==4.1.1 ; extra == 'docs'
|
81
81
|
Requires-Dist: tabulate ; extra == 'docs'
|
82
82
|
Provides-Extra: linters
|
83
83
|
Requires-Dist: mypy ; extra == 'linters'
|
@@ -102,34 +102,36 @@ Requires-Dist: safety ; extra == 'test'
|
|
102
102
|
Requires-Dist: numpy ; extra == 'test'
|
103
103
|
Requires-Dist: scipy ; extra == 'test'
|
104
104
|
Requires-Dist: pandas ; extra == 'test'
|
105
|
-
Requires-Dist: scikit-learn
|
105
|
+
Requires-Dist: scikit-learn >=0.24.0 ; extra == 'test'
|
106
106
|
|
107
107
|
<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>
|
108
108
|
|
109
109
|
# Welcome to skbase
|
110
110
|
|
111
|
-
> A
|
111
|
+
> A framework factory for scikit-learn-like and sktime-like parametric objects
|
112
112
|
|
113
113
|
`skbase` provides base classes for creating scikit-learn-like parametric objects,
|
114
|
-
along with tools to make it easier to build your own packages that follow these
|
115
|
-
design patterns.
|
114
|
+
along with tools to make it easier to build your own packages that follow these design patterns.
|
116
115
|
|
117
|
-
:rocket: Version 0.5.
|
116
|
+
:rocket: Version 0.5.1 is now available. Checkout our
|
118
117
|
[release notes](https://skbase.readthedocs.io/en/latest/changelog.html).
|
119
118
|
|
120
119
|
| Overview | |
|
121
120
|
|---|---|
|
122
121
|
| **CI/CD** | [](https://github.com/sktime/skbase/actions/workflows/test.yml) [](https://codecov.io/gh/sktime/skbase) [](https://skbase.readthedocs.io/en/latest/?badge=latest) [](https://results.pre-commit.ci/latest/github/sktime/skbase/main) |
|
123
|
-
| **Code** | [](https://pypi.org/project/
|
122
|
+
| **Code** | [](https://pypi.org/project/scikit-base/) [](https://www.python.org/) [](https://github.com/psf/black) [](https://github.com/PyCQA/bandit) |
|
124
123
|
| **Downloads**| [)](https://pepy.tech/project/scikit-base) [)](https://pepy.tech/project/scikit-base) [)](https://pepy.tech/project/scikit-base) |
|
125
124
|
|
126
125
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
127
126
|
[](#contributors)
|
128
127
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
129
128
|
|
130
|
-
## Documentation
|
129
|
+
## Documentation and Tutorials
|
131
130
|
|
132
|
-
To learn more about the package
|
131
|
+
To learn more about the package check out:
|
132
|
+
|
133
|
+
* our [documentation](https://skbase.readthedocs.io/en/latest/)
|
134
|
+
* our [introductory tutorial](https://github.com/sktime/sktime-tutorial-pydata-seattle-2023) (jupyter notebooks and video presentation)
|
133
135
|
|
134
136
|
## :hourglass_flowing_sand: Install skbase
|
135
137
|
For trouble shooting or more information, see our
|
@@ -1,10 +1,10 @@
|
|
1
1
|
docs/source/conf.py,sha256=Ob6dAIWxgemP0kwSzuO7wWknKcnybs3HyfPcuwhyNIc,9845
|
2
|
-
skbase/__init__.py,sha256=
|
2
|
+
skbase/__init__.py,sha256=WZe3oBlNkMLhyqABTvFoT7nJhb8toJSIHTX_tYJLj1A,454
|
3
3
|
skbase/_exceptions.py,sha256=xoucRFDeUnPhMBEWRCMyP-r2hUF8ZippKxJyi_8oAKI,1113
|
4
4
|
skbase/_nopytest_tests.py,sha256=npL5pibSgCpulEGw0NqLKcG0majh6xcdW5A4Zibf78s,1077
|
5
5
|
skbase/base/__init__.py,sha256=QZLPb8_XOOhV1Y6KQuIjBvnNE9Rc09TkSfqkN5SiqLc,629
|
6
6
|
skbase/base/_base.py,sha256=czFUqCbl69MwRZvJI2ytJE34p_odgV8rKmveafBp_Sk,46750
|
7
|
-
skbase/base/_meta.py,sha256=
|
7
|
+
skbase/base/_meta.py,sha256=SQ3geft8wzciN4XQLiUWT7E9RF_r06mCFsp9It7Ev6w,36329
|
8
8
|
skbase/base/_tagmanager.py,sha256=mcKrME8kl300ev2WxgtWkbMj_ikfF7FFTLMSa0O1OU0,7290
|
9
9
|
skbase/base/_pretty_printing/__init__.py,sha256=bVuKnwafn8c2q2AGJ9BOu9cmu-xBjiOxHf1hxjm8K2A,492
|
10
10
|
skbase/base/_pretty_printing/_object_html_repr.py,sha256=wU2pMg3XmpNWoJaPXUzLpoMG5vLfAF83OeI6KftYXlg,11539
|
@@ -14,7 +14,7 @@ skbase/lookup/_lookup.py,sha256=ITzLugUeUO6IyTth5l31UZI_Hkv1_3mQrEQW7nyi7Rw,3914
|
|
14
14
|
skbase/lookup/tests/__init__.py,sha256=MVqGlWsUV-gQ4qzW_TqE3UmKO9IQ9mwdDlsIHaGt3bc,68
|
15
15
|
skbase/lookup/tests/test_lookup.py,sha256=BZdRuUUl6gZC943wiTTV5hnjXbU2rEe-Gbmu8-hXajQ,36924
|
16
16
|
skbase/testing/__init__.py,sha256=OdwR-aEU2KzGrU-O0gtNSMNGmF2mtgBmjAnMzcgwe6w,351
|
17
|
-
skbase/testing/test_all_objects.py,sha256=
|
17
|
+
skbase/testing/test_all_objects.py,sha256=jJHSMGWDIruKq2rTdUl9QoLMlOxH8E6oZd82NuPDYt4,36178
|
18
18
|
skbase/testing/utils/__init__.py,sha256=kaLuqQwJsCunRWsUb1JwTVG-iqXbzdUobuYHNHsBlQQ,113
|
19
19
|
skbase/testing/utils/_conditional_fixtures.py,sha256=QwI7K28Lsy6RAkDP94goo8uWWvMzKKNOmXRFtc9RNtI,9890
|
20
20
|
skbase/testing/utils/_dependencies.py,sha256=WgoHKRT6bxvJqG7lK_r9dKG3TCAHFxhjyjwE1cPEjdk,469
|
@@ -28,7 +28,7 @@ skbase/tests/conftest.py,sha256=g4pfthiTxU8iSWcHHVhxAd4JCBx2Lf6V9lk6A0zikKA,8398
|
|
28
28
|
skbase/tests/test_base.py,sha256=LxSgtI8zJ3sulgGTPA_fgvHmACqqrW1vBXeP-YEl4v0,42582
|
29
29
|
skbase/tests/test_baseestimator.py,sha256=6Jna9Sdecg9kwhXmTumBTBPNT_Hb9-o345RHVEMWWOI,4730
|
30
30
|
skbase/tests/test_exceptions.py,sha256=wOdk7Gp8pvbhucna3_9FxTk9xFLjC9XNsGsVabQLYEE,629
|
31
|
-
skbase/tests/test_meta.py,sha256=
|
31
|
+
skbase/tests/test_meta.py,sha256=mjfa7QrSxzc1DEJ51OGgnmr9iawKsYtUjBmNrZTnUrc,5661
|
32
32
|
skbase/tests/mock_package/__init__.py,sha256=9HanT3M2_OCF1uhdLbYNyDDo5m3djsjOkbsxxbx-TPo,135
|
33
33
|
skbase/tests/mock_package/test_mock_package.py,sha256=qX777HIJ0-BU_K4l5q5oYbEXk-b0cpg6gkzeET8WZbQ,2021
|
34
34
|
skbase/utils/__init__.py,sha256=z0jI3ncO4xurEUHE0eJqYxxY6TD4SDFVCiVH71gtqyU,633
|
@@ -36,7 +36,7 @@ skbase/utils/_check.py,sha256=mLfqYMCT-4ro5PFJXyx4QNfjbAecHuZQGl_CVM3GoqE,1395
|
|
36
36
|
skbase/utils/_iter.py,sha256=Um1rq79tl7PtWAq1VMHVf-pt9vQj5C0zuvyF49ob9G0,8037
|
37
37
|
skbase/utils/_nested_iter.py,sha256=omDI2Y75ajWTSV9d59iJTj1RcCk5YFbc7cZNQjz8AC8,4566
|
38
38
|
skbase/utils/_utils.py,sha256=A6sTIUEscEy9TjBmCvXEuhk9q8ROBPyfJGhrjlSA4LY,3134
|
39
|
-
skbase/utils/deep_equals.py,sha256=
|
39
|
+
skbase/utils/deep_equals.py,sha256=aeTZVkYq_gJ3gB64F1rJDHe-YrxqHetHX4yNXD7mqI4,11303
|
40
40
|
skbase/utils/dependencies/__init__.py,sha256=89TNnES--f1PeoPm-_h6a2mCtoGXt6mAd-n89FdusMM,352
|
41
41
|
skbase/utils/dependencies/_dependencies.py,sha256=zmlWZ10HtiHE2PK2T7AzsFNKIA95O8hmIySlz2t4Mrs,10359
|
42
42
|
skbase/utils/tests/__init__.py,sha256=YfvP5lpCrTC_6SIakU7jBBdqYyuqE07nZ56ZYKTs3f0,165
|
@@ -50,9 +50,9 @@ skbase/validate/_types.py,sha256=TIoqmfhwW_kMHEhfiBtUpmN56t1trWBVtC03sAkrUjk,121
|
|
50
50
|
skbase/validate/tests/__init__.py,sha256=wunQBy6rajyrDymKvuFVajsBjj90VP5IFey5b6ZIRCk,70
|
51
51
|
skbase/validate/tests/test_iterable_named_objects.py,sha256=Pb3Y7lPo7zcuulKqJ6z9M5DkCqW-S3KZ4rR-jC5lM8w,7438
|
52
52
|
skbase/validate/tests/test_type_validations.py,sha256=G-qwFjXk-8WvXoeOvo2omfFKKjbpWhP-sPf6hsw8q30,14131
|
53
|
-
scikit_base-0.5.
|
54
|
-
scikit_base-0.5.
|
55
|
-
scikit_base-0.5.
|
56
|
-
scikit_base-0.5.
|
57
|
-
scikit_base-0.5.
|
58
|
-
scikit_base-0.5.
|
53
|
+
scikit_base-0.5.1.dist-info/LICENSE,sha256=W2h8EYZ_G_mvCmCmXTTYqv66QF5NgSMbzLYJdk8qHVg,1525
|
54
|
+
scikit_base-0.5.1.dist-info/METADATA,sha256=53135HaAwhlh0oRkBBODC-i2-lI1r6-EA6gk7yf5S7U,8641
|
55
|
+
scikit_base-0.5.1.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
|
56
|
+
scikit_base-0.5.1.dist-info/top_level.txt,sha256=FbRMsZcP-O6pMLGZpxA5pQ-ClfRzoB6Yr-hTViYqwT0,57
|
57
|
+
scikit_base-0.5.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
58
|
+
scikit_base-0.5.1.dist-info/RECORD,,
|
skbase/__init__.py
CHANGED
skbase/base/_meta.py
CHANGED
@@ -188,14 +188,16 @@ class _MetaObjectMixin:
|
|
188
188
|
"""
|
189
189
|
# Set variables that let us use same code for retrieving params or fitted params
|
190
190
|
if fitted:
|
191
|
-
|
191
|
+
method_shallow = "_get_fitted_params"
|
192
|
+
method_public = "get_fitted_params"
|
192
193
|
deepkw = {}
|
193
194
|
else:
|
194
|
-
|
195
|
+
method_shallow = "get_params"
|
196
|
+
method_public = "get_params"
|
195
197
|
deepkw = {"deep": deep}
|
196
198
|
|
197
199
|
# Get the direct params/fitted params
|
198
|
-
out = getattr(super(),
|
200
|
+
out = getattr(super(), method_shallow)(**deepkw)
|
199
201
|
|
200
202
|
if deep and hasattr(self, attr):
|
201
203
|
named_objects = getattr(self, attr)
|
@@ -207,8 +209,15 @@ class _MetaObjectMixin:
|
|
207
209
|
]
|
208
210
|
out.update(named_objects_)
|
209
211
|
for name, obj in named_objects_:
|
210
|
-
|
211
|
-
|
212
|
+
# checks estimator has the method we want to call
|
213
|
+
cond1 = hasattr(obj, method_public)
|
214
|
+
# checks estimator is fitted if calling get_fitted_params
|
215
|
+
is_fitted = hasattr(obj, "is_fitted") and obj.is_fitted
|
216
|
+
# if we call get_params and not get_fitted_params, this is True
|
217
|
+
cond2 = not fitted or is_fitted
|
218
|
+
# check both conditions together
|
219
|
+
if cond1 and cond2:
|
220
|
+
for key, value in getattr(obj, method_public)(**deepkw).items():
|
212
221
|
out["%s__%s" % (name, key)] = value
|
213
222
|
return out
|
214
223
|
|
@@ -234,8 +243,8 @@ class _MetaObjectMixin:
|
|
234
243
|
# 2. Step replacement
|
235
244
|
items = getattr(self, attr)
|
236
245
|
names = []
|
237
|
-
if items:
|
238
|
-
names
|
246
|
+
if items and isinstance(items, (list, tuple)):
|
247
|
+
names = list(zip(*items))[0]
|
239
248
|
for name in list(params.keys()):
|
240
249
|
if "__" not in name and name in names:
|
241
250
|
self._replace_object(attr, name, params.pop(name))
|
@@ -247,9 +256,12 @@ class _MetaObjectMixin:
|
|
247
256
|
"""Replace an object in attribute that contains named objects."""
|
248
257
|
# assumes `name` is a valid object name
|
249
258
|
new_objects = list(getattr(self, attr))
|
250
|
-
for i,
|
259
|
+
for i, obj_tpl in enumerate(new_objects):
|
260
|
+
object_name = obj_tpl[0]
|
251
261
|
if object_name == name:
|
252
|
-
|
262
|
+
new_tpl = list(obj_tpl)
|
263
|
+
new_tpl[1] = new_val
|
264
|
+
new_objects[i] = tuple(new_tpl)
|
253
265
|
break
|
254
266
|
setattr(self, attr, new_objects)
|
255
267
|
|
@@ -659,21 +659,17 @@ class TestAllObjects(BaseFixtureGenerator, QuickTester):
|
|
659
659
|
assert not hasattr(object_instance, "test__attr")
|
660
660
|
object_instance.test__attr = 42
|
661
661
|
|
662
|
-
@pytest.mark.skipif(
|
663
|
-
not _check_soft_dependencies("sklearn", severity="none"),
|
664
|
-
reason="skip test if sklearn is not available",
|
665
|
-
) # sklearn is part of the dev dependency set, test should be executed with that
|
666
662
|
def test_get_params(self, object_instance):
|
667
663
|
"""Check that get_params works correctly, against sklearn interface."""
|
668
|
-
from sklearn.utils.estimator_checks import (
|
669
|
-
check_get_params_invariance as _check_get_params_invariance,
|
670
|
-
)
|
671
|
-
|
672
664
|
params = object_instance.get_params()
|
673
665
|
assert isinstance(params, dict)
|
674
|
-
|
675
|
-
|
676
|
-
|
666
|
+
|
667
|
+
e = object_instance.clone()
|
668
|
+
|
669
|
+
shallow_params = e.get_params(deep=False)
|
670
|
+
deep_params = e.get_params(deep=True)
|
671
|
+
|
672
|
+
assert all(item in deep_params.items() for item in shallow_params.items())
|
677
673
|
|
678
674
|
def test_set_params(self, object_instance):
|
679
675
|
"""Check that set_params works correctly."""
|
skbase/tests/test_meta.py
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# copyright: skbase developers, BSD-3-Clause License (see LICENSE file)
|
3
|
-
"""Tests for BaseMetaObject and BaseMetaEstimator mixins.
|
3
|
+
"""Tests for BaseMetaObject and BaseMetaEstimator mixins."""
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
"""
|
9
|
-
|
10
|
-
__author__ = ["RNKuhns"]
|
5
|
+
__author__ = ["RNKuhns", "fkiraly"]
|
11
6
|
import inspect
|
12
7
|
|
13
8
|
import pytest
|
@@ -23,37 +18,51 @@ from skbase.base._meta import (
|
|
23
18
|
|
24
19
|
|
25
20
|
class MetaObjectTester(BaseMetaObject):
|
26
|
-
"""Class to test meta
|
21
|
+
"""Class to test meta-object functionality."""
|
27
22
|
|
28
23
|
def __init__(self, a=7, b="something", c=None, steps=None):
|
29
24
|
self.a = a
|
30
25
|
self.b = b
|
31
26
|
self.c = c
|
32
27
|
self.steps = steps
|
28
|
+
super().__init__()
|
33
29
|
|
34
30
|
|
35
31
|
class MetaEstimatorTester(BaseMetaEstimator):
|
36
|
-
"""Class to test meta
|
32
|
+
"""Class to test meta-estimator functionality."""
|
37
33
|
|
38
34
|
def __init__(self, a=7, b="something", c=None, steps=None):
|
39
35
|
self.a = a
|
40
36
|
self.b = b
|
41
37
|
self.c = c
|
42
38
|
self.steps = steps
|
39
|
+
super().__init__()
|
40
|
+
|
41
|
+
|
42
|
+
class ComponentDummy(BaseObject):
|
43
|
+
"""Class to use as components in meta-estimator."""
|
44
|
+
|
45
|
+
def __init__(self, a=7, b="something"):
|
46
|
+
self.a = a
|
47
|
+
self.b = b
|
48
|
+
super().__init__()
|
43
49
|
|
44
50
|
|
45
51
|
@pytest.fixture
|
46
52
|
def fixture_metaestimator_instance():
|
53
|
+
"""BaseMetaEstimator instance fixture."""
|
47
54
|
return BaseMetaEstimator()
|
48
55
|
|
49
56
|
|
50
57
|
@pytest.fixture
|
51
58
|
def fixture_meta_object():
|
59
|
+
"""MetaObjectTester instance fixture."""
|
52
60
|
return MetaObjectTester()
|
53
61
|
|
54
62
|
|
55
63
|
@pytest.fixture
|
56
64
|
def fixture_meta_estimator():
|
65
|
+
"""MetaEstimatorTester instance fixture."""
|
57
66
|
return MetaEstimatorTester()
|
58
67
|
|
59
68
|
|
@@ -129,3 +138,33 @@ def test_basemetaestimator_check_is_fitted_raises_error_when_unfitted(
|
|
129
138
|
|
130
139
|
fixture_metaestimator_instance._is_fitted = True
|
131
140
|
assert fixture_metaestimator_instance.check_is_fitted() is None
|
141
|
+
|
142
|
+
|
143
|
+
@pytest.mark.parametrize("long_steps", (True, False))
|
144
|
+
def test_metaestimator_composite(long_steps):
|
145
|
+
"""Test composite meta-estimator functionality."""
|
146
|
+
if long_steps:
|
147
|
+
steps = [("foo", ComponentDummy(42)), ("bar", ComponentDummy(24))]
|
148
|
+
else:
|
149
|
+
steps = [("foo", ComponentDummy(42), 123), ("bar", ComponentDummy(24), 321)]
|
150
|
+
|
151
|
+
meta_est = MetaEstimatorTester(steps=steps)
|
152
|
+
|
153
|
+
meta_est_params = meta_est.get_params()
|
154
|
+
assert isinstance(meta_est_params, dict)
|
155
|
+
expected_keys = [
|
156
|
+
"a",
|
157
|
+
"b",
|
158
|
+
"c",
|
159
|
+
"steps",
|
160
|
+
"foo",
|
161
|
+
"bar",
|
162
|
+
"foo__a",
|
163
|
+
"foo__b",
|
164
|
+
"bar__a",
|
165
|
+
"bar__b",
|
166
|
+
]
|
167
|
+
assert set(meta_est_params.keys()) == set(expected_keys)
|
168
|
+
|
169
|
+
meta_est.set_params(bar__b="something else")
|
170
|
+
assert meta_est.get_params()["bar__b"] == "something else"
|
skbase/utils/deep_equals.py
CHANGED
File without changes
|
File without changes
|
File without changes
|