Sometimes I design machine learning pipelines that look something like this:
Normally I have to hack these "split" pipelines together using my own "Combine Features" function. However, it'd be great if I could fit this into a sklearn Pipeline object. How would I go about doing that? (Pseudo-code is fine.)
As long as "Entire Data Set" means the same features, this is exactly what FeatureUnion
does:
make_pipeline(make_union(PolynomialFeatures(), PCA()), RFE(RandomForestClassifier()))
If you have two different sets of features that you want to combine, you first need to put them into a single dataset, and then have each branch of the FeatureUnion
first select the features it should operate on. [there is currently no ready-made function for this but it's easily achiveable with a FunctionTransformer() for example]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With