是否有一个虚拟的 Scaler 不做任何事情来插入管道?

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

是否有一个虚拟的 Scaler 可以插入一个什么都不做的管道?即

# 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]
           }]

DummyDoNothingScaler吗?

实际上使用 None 与 "do nothing" 一样完美,即

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

我认为 Skywalker 提供了一个非常干净的解决方案,但如果您想创建一些对象进行测试,您可以尝试以下操作:

from sklearn.preprocessing import FunctionTransformer

DummyScaler = FunctionTransformer(lambda x: x)

希望对您有所帮助!