SkyWalker
SkyWalker

Reputation: 14309

Is there a dummy Scaler that does nothing to plug into a Pipeline?

Is there a dummy Scaler to plug into a Pipeline that does nothing? i.e.

# define the SVM model using the RBF kernel
model = Pipeline(steps=[('preprocess', MinMaxScaler()),
                        ('model', SVC(kernel='rbf',
                                      gamma='scale',
                                      probability=True,
                                      class_weight='balanced',
                                      cache_size=1000,
                                      tol=1e-10,
                                      shrinking=True,
                                      decision_function_shape='ovr',
                                      break_ties=False,
                                      C=3.0))])
params =  [{'preprocess': [DummyDoNothingScaler(), MaxAbsScaler(), MinMaxScaler(), StandardScaler()],
            'model__gamma': ['scale', 'auto'],
            'model__C': [1.0, 1.01, 1.015,3.0]
           }]

Is there a DummyDoNothingScaler?

Upvotes: 2

Views: 1156

Answers (2)

siu
siu

Reputation: 81

I think Skywalker provided a realy clean solution, but if you wanna create some objects to test, you could try below:

from sklearn.preprocessing import FunctionTransformer

DummyScaler = FunctionTransformer(lambda x: x)

Hope it helps!

Upvotes: 8

SkyWalker
SkyWalker

Reputation: 14309

Actually using None works perfectly as "do nothing" i.e.

params =  [{'preprocess': [None, MaxAbsScaler(), MinMaxScaler(), StandardScaler()],
            'model__gamma': ['scale', 'auto'],
            'model__C': [1.0, 1.01, 1.015,3.0]
          }]

Upvotes: 2

Related Questions