Source code for mlinsights.sklapi.sklearn_base_transform

# -*- coding: utf-8 -*-
"""
Implements a *transform* which follows the smae API
as every :epkg:`scikit-learn` transform.


:githublink:`%|py|7`
"""
from .sklearn_base import SkBase


[docs]class SkBaseTransform(SkBase): """ Pattern of a *learner* which follows the same API que :epkg:`scikit-learn`. :githublink:`%|py|13` """
[docs] def __init__(self, **kwargs): """ Stores the parameters. :githublink:`%|py|18` """ SkBase.__init__(self, **kwargs)
################### # API scikit-learn ###################
[docs] def fit(self, X, y=None, **kwargs): """ Trains a model. :param X: features :param y: targets :return: self :githublink:`%|py|32` """ raise NotImplementedError()
[docs] def transform(self, X): """ Transforms the data. :param X: features :return: predictions :githublink:`%|py|41` """ raise NotImplementedError()
[docs] def fit_transform(self, X, y=None, **kwargs): """ Trains and transforms the data. :param X: features :param y: targets :return: self :githublink:`%|py|51` """ self.fit(X, y=y, **kwargs) return self.transform(X)