skbase

0.13.1 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates defining a custom object inheriting from `skbase.base.BaseObject`, illustrating how to initialize parameters, retrieve them with `get_params`, modify them with `set_params`, and create a deep copy using `clone()`.

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}")

view raw JSON →