space_sample.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Mon Oct 5 09:50:24 2020
  5. @author: tanya
  6. """
  7. from sklearn.ensemble import RandomForestClassifier
  8. from sklearn.feature_selection import SelectPercentile
  9. from sklearn.linear_model import LogisticRegression
  10. from sklearn.decomposition import PCA
  11. from sklearn.pipeline import Pipeline
  12. from sklearn.preprocessing import StandardScaler
  13. space = [
  14. {"name": "std_scaler_kbest_rf",
  15. "pipeline": Pipeline([
  16. ("std_scaler", StandardScaler()),
  17. ("kbest", SelectPercentile()),
  18. ("rf", RandomForestClassifier())]),
  19. "params": {"kbest__percentile": [2, 3],
  20. "rf__n_estimators": [10, 20]}},
  21. {"name": "std_scaler_pca_lr",
  22. "pipeline": Pipeline([
  23. ("std_scaler", StandardScaler()),
  24. ("pca", PCA()),
  25. ("lr", LogisticRegression())]),
  26. "params": {"lr__C": [0.5, 1],
  27. "pca__n_components": [2, 3]}}
  28. ]