Skip to content

Documentation for LabelEncoder

Suitable version of the scikit-learn LabelEncoder for PHOTONAI. Since the pipeline process streams the underlying samples to every transformer, this class is required.

__init__(self) special

Initialize the object.

Source code in photonai/modelwrapper/label_encoder.py
def __init__(self):
    """Initialize the object."""
    super(LabelEncoder, self).__init__()
    self.needs_y = True

fit(self, X, y=None, **kwargs)

Call of the underlying sklearn.fit(y) method.

Parameters:

Name Type Description Default
X ndarray

The input samples of shape [n_samples, n_features].

required
y ndarray

The input targets of shape [n_samples, 1].

None
**kwargs

Ignored input.

{}
Source code in photonai/modelwrapper/label_encoder.py
def fit(self, X: np.ndarray, y: np.ndarray = None, **kwargs):
    """
    Call of the underlying sklearn.fit(y) method.

    Parameters:
        X:
            The input samples of shape [n_samples, n_features].

        y:
            The input targets of shape [n_samples, 1].

        **kwargs:
            Ignored input.

    """
    super(LabelEncoder, self).fit(y)
    return self

fit_transform(self, X, y=None, **kwargs)

Call of the underlying sklearn.fit_transform(y) method.

Parameters:

Name Type Description Default
X ndarray

The input samples of shape [n_samples, n_features].

required
y ndarray

The input targets of shape [n_samples, 1].

None
**kwargs

Ignored input.

{}

Returns:

Type Description
(<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)

Original X and encoded y.

Source code in photonai/modelwrapper/label_encoder.py
def fit_transform(self, X: np.ndarray, y: np.ndarray = None, **kwargs) -> (np.ndarray, np.ndarray):
    """
    Call of the underlying sklearn.fit_transform(y) method.

    Parameters:
        X:
            The input samples of shape [n_samples, n_features].

        y:
            The input targets of shape [n_samples, 1].

        **kwargs:
            Ignored input.

    Returns:
        Original X and encoded y.

    """
    return super(LabelEncoder, self).fit_transform(y)

transform(self, X, y=None, **kwargs)

Call of the underlying sklearn.transform(y) method.

Parameters:

Name Type Description Default
X ndarray

The input samples of shape [n_samples, n_features].

required
y ndarray

The input targets of shape [n_samples, 1].

None
**kwargs

Ignored input.

{}

Returns:

Type Description
(<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)

Original X and encoded y.

Source code in photonai/modelwrapper/label_encoder.py
def transform(self, X: np.ndarray, y: np.ndarray = None, **kwargs) -> (np.ndarray, np.ndarray):
    """
    Call of the underlying sklearn.transform(y) method.

    Parameters:
        X:
            The input samples of shape [n_samples, n_features].

        y:
            The input targets of shape [n_samples, 1].

        **kwargs:
            Ignored input.

    Returns:
        Original X and encoded y.

    """
    yt = super(LabelEncoder, self).transform(y)
    return X, yt