Custom preprocessing steps in the Features Handling section in model design

Options
cronos003
cronos003 Registered Posts: 7 ✭✭✭✭

I'm trying to create a custom transformation but haven't been successful. The sample code provided works fine but when I define my own function with the same transformation it fails. See below for the exact snippets.



Works:


from sklearn import preprocessing
import numpy as np

# Applies log transformation to the feature
processor = preprocessing.FunctionTransformer(np.log1p)





Does not work:


from sklearn import preprocessing
import numpy as np

def CustomT(X):
return np.log1p(X)

# Applies log transformation to the feature
processor = preprocessing.FunctionTransformer(CustomT)

Error (more detailed logs available if required):


Failed to train : <type 'exceptions.TypeError'> : expected string or Unicode object, NoneType found

I used a pared down dataset to generate this log: https://we.tl/t-YWJABcMO5s

Best Answer

Answers

Setup Info
    Tags
      Help me…