Skip to content

glassbox.models._base

Abstract BaseModel defining the fit / predict interface.


BaseModel

Bases: ABC

fit abstractmethod

fit(X, y)

Fits the model to the training data.

Parameters:

Name Type Description Default
X ndarray

Training data of shape (n_samples, n_features).

required
y ndarray

Target values of shape (n_samples,).

required

Returns:

Type Description
Self

The fitted model.

Source code in glassbox/models/_base.py
@abstractmethod
def fit(self, X: np.ndarray, y: np.ndarray) -> Self:
    """
    Fits the model to the training data.

    Parameters
    ----------
    X : np.ndarray
        Training data of shape (n_samples, n_features).
    y : np.ndarray
        Target values of shape (n_samples,).

    Returns
    -------
    Self
        The fitted model.
    """
    raise NotImplementedError

predict abstractmethod

predict(X, **kwargs)

Predicts target values for the given data.

Parameters:

Name Type Description Default
X ndarray

Data to predict on, of shape (n_samples, n_features).

required
**kwargs Any

Additional keyword arguments.

{}

Returns:

Type Description
ndarray

Predicted target values.

Source code in glassbox/models/_base.py
@abstractmethod
def predict(self, X: np.ndarray, **kwargs: Any) -> np.ndarray:
    """
    Predicts target values for the given data.

    Parameters
    ----------
    X : np.ndarray
        Data to predict on, of shape (n_samples, n_features).
    **kwargs : Any
        Additional keyword arguments.

    Returns
    -------
    np.ndarray
        Predicted target values.
    """
    raise NotImplementedError