Skip to content

glassbox.cleaner._base

Abstract BaseTransformer defining the fit / transform interface.


BaseTransformer

Bases: ABC

fit abstractmethod

fit(X)

Calculates parameters needed for transformation.

Parameters:

Name Type Description Default
X ndarray

Input array for learning

required

Returns:

Type Description
Self

Updated state of the transformer

Source code in glassbox/cleaner/_base.py
@abstractmethod
def fit(self, X: np.ndarray) -> Self:
    """
    Calculates parameters needed for transformation.

    Parameters
    ----------
    X : np.ndarray
        Input array for learning

    Returns
    -------
    Self
        Updated state of the transformer
    """
    raise NotImplementedError

transform abstractmethod

transform(X)

Applies the transformation to the dataset.

Parameters:

Name Type Description Default
X ndarray

Input array to be transformed

required

Returns:

Type Description
ndarray

transformed array

Source code in glassbox/cleaner/_base.py
@abstractmethod
def transform(self, X: np.ndarray) -> np.ndarray:
    """
    Applies the transformation to the dataset.

    Parameters
    ----------
    X : np.ndarray
        Input array to be transformed

    Returns
    -------
    np.ndarray
        transformed array
    """
    raise NotImplementedError

fit_transform

fit_transform(X)

Fits to the data, then transforms it.

Parameters:

Name Type Description Default
X ndarray

Input array to be transformed

required

Returns:

Type Description
ndarray

transformed array

Source code in glassbox/cleaner/_base.py
def fit_transform(self, X: np.ndarray) -> np.ndarray:
    """
    Fits to the data, then transforms it.

    Parameters
    ----------
    X : np.ndarray
        Input array to be transformed

    Returns
    -------
    np.ndarray
        transformed array
    """
    return self.fit(X).transform(X)