skbase
skbase provides base classes for creating scikit-learn-like parametric objects, along with tools to make it easier to build custom packages that follow these design patterns. It is a foundational library, notably used by `sktime`. The current version is 0.13.1, and it has a frequent release cadence with minor and patch updates occurring roughly monthly or bi-monthly.
Warnings
- breaking The meaning of `filter_tags` arguments (type `str` or `iterable of str`) in `skbase.lookup.all_objects` changed. Previously, it selected objects possessing the tag(s) of any value. From version 0.9.0, it selects objects where the tag's value is explicitly `True` (boolean).
- gotcha As of version 0.4.2, `skbase` explicitly removed all core external PyPI dependencies, intending to be a truly base module without implicit requirements beyond Python itself. Developers building on `skbase` should be aware of this and explicitly manage any dependencies their custom objects require.
- gotcha Users often confuse `skbase` with `scikit-learn`. `skbase` provides base classes for *creating* scikit-learn-like parametric objects and design patterns, but it is not `scikit-learn` itself and does not contain machine learning algorithms for direct use. Importing `sklearn.base.BaseEstimator` is for `scikit-learn`, not `skbase.base.BaseObject`.
Install
-
pip install scikit-base -
pip install scikit-base[all_extras]
Imports
- BaseObject
from skbase.base import BaseObject
- all_objects
from skbase.lookup import all_objects
Quickstart
from skbase.base import BaseObject
class MyCustomObject(BaseObject):
"""A simple custom object demonstrating skbase.base.BaseObject."""
def __init__(self, value_a=1, value_b="default_string", random_state=None):
self.value_a = value_a
self.value_b = value_b
self.random_state = random_state
super().__init__()
# Create an instance of our custom object
my_obj = MyCustomObject(value_a=10)
print(f"Initial parameters: {my_obj.get_params()}")
# Modify parameters using set_params
my_obj.set_params(value_b="new_string_value")
print(f"Parameters after set_params: {my_obj.get_params()}")
# Demonstrate cloning (a common scikit-learn-like pattern)
cloned_obj = my_obj.clone()
print(f"Cloned object parameters: {cloned_obj.get_params()}")
print(f"Is cloned_obj the same instance as my_obj? {cloned_obj is my_obj}")