Skip to content

Instantly share code, notes, and snippets.

@elisim
Last active September 2, 2021 09:16
Show Gist options
  • Save elisim/ca2d43393714e9482d0c4be304062a8a to your computer and use it in GitHub Desktop.
Save elisim/ca2d43393714e9482d0c4be304062a8a to your computer and use it in GitHub Desktop.
Hydra-Sklearn Blog - Code example 2
from sklearn.decomposition import PCA
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
pipeline_lr = Pipeline(
[
("imputer", SimpleImputer(strategy="constant", fill_value="-1")),
("VarianceThreshold", VarianceThreshold(threshold=0.1)),
("scalar1", StandardScaler()),
("pca1", PCA(n_components=2)),
("lr_classifier", LogisticRegression(random_state=0)),
]
)
pipeline_dt = Pipeline(
[
("scalar2", StandardScaler()),
("VarianceThreshold", VarianceThreshold(threshold=0.1)),
("imputer", SimpleImputer(strategy="constant", fill_value="-1")),
("pca2", PCA(n_components=2)),
("dt_classifier", DecisionTreeClassifier()),
]
)
pipeline_randomforest = Pipeline(
[
("scalar3", StandardScaler()),
("pca3", PCA(n_components=2)),
("rf_classifier", RandomForestClassifier()),
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment