Building custom transformation functions

As you will have noticed, in our example, we used a couple of custom transformation functions, an identity, and an inverse, in order to have the original features along the transformed one and to make features inverse. Custom transformations can help you deal with the specific munging you have in mind for your problem, and you will also find them useful because they can act as a filter by filtering unwanted or erroneous values.

You can create a custom transformation just by applying the FunctionTransformer function from sklearn.preprocessing, which turns any function into a Scikit-learn class with the fit and transform method. Creating a transformation from scratch may help to make things clear for ...

Get Python Data Science Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.