1
$\begingroup$

Is there a correct order I should put data transformations into a pipeline using Sklearn?

Currently I have these items in my pipeline;

Feature selection, skew removal, scaling, outlier removal, oversampling and the estimator.

Is there a right or wrong way to do it? Or is there no free lunch?

$\endgroup$
4
$\begingroup$

The most common approach is a combination of these two strategies:

  1. Domain expertise - Given knowledge about the dataset and the goal of the model, choose the order that best manipulates the data to accomplish the goal of the project.

  2. Empirical evidence - Permutation the order and benchmark results. Pick the permutation that has the highest performance on the benchmarks.

$\endgroup$
2
$\begingroup$

I'll agree with @BrianSpiering on general approaches, and with you that this is a no-free-lunch situation. But...

Oversampling seems reasonably to fit in just about anywhere. It may depend on what kind of oversampling you're doing. I could see the new points messing up the distributions and thus affecting everything else, but it could potentially also make the other steps more robust.
(Then again, I'm still looking for examples where resampling techniques help substantially beyond threshold selection. See https://stats.stackexchange.com/questions/247871/what-is-the-root-cause-of-the-class-imbalance-problem and its linked questions.)

Outlier removal should happen early, as outliers will affect skew/scaling corrections. Skew/scaling feel like the same process to me, and if they're separate steps I suspect they can occur in either order.

I would keep feature selection for near the end, lest an important feature be overlooked because it is skew/unscaled/outlier-prone. (Feature selection methods are notoriously error-prone though, so I wouldn't be surprised if moving it around performed better for certain datasets.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.