Custom Transformer

You can add your own method, be it preprocessing, feature selection or dimensionality reduction, by simply adhering to the scikit-learn interface as shown below. Then register your class with the Register module and you're good to go. You can then combine it with any optimizer and metric and design your custom pipeline layout.

from sklearn.base import BaseEstimator

class CustomTransformer(BaseEstimator):

    def __init__(self, param1=0, param2=None):
        # it is important that you name your params the same in the constructor
        #  stub as well as in your class variables!
        self.param1 = param1
        self.param2 = param2

    def fit(self, data, targets=None, **kwargs):
        Adjust the underlying model or method to the data.

        IMPORTANT: must return self!
        return self

    def transform(self, data, targets=None, **kwargs):
        Apply the method's logic to the data.
        transformed_data = []
        return transformed_data