|
1 | 1 | import sys |
2 | 2 |
|
| 3 | +from sklearn.dummy import DummyClassifier |
| 4 | +from sklearn.preprocessing import StandardScaler |
3 | 5 | from sklearn.linear_model import LogisticRegression, SGDClassifier, LinearRegression |
4 | 6 | from sklearn.ensemble import RandomForestClassifier, BaggingClassifier |
5 | 7 | from sklearn.svm import SVC |
6 | 8 | from sklearn.model_selection import RandomizedSearchCV, GridSearchCV, StratifiedKFold |
| 9 | +from sklearn.pipeline import Pipeline |
7 | 10 | import openml |
8 | 11 | import openml.exceptions |
9 | 12 | from openml.testing import TestBase |
@@ -86,6 +89,19 @@ def test_run_optimize_bagging_iris(self): |
86 | 89 | run = self._perform_run(task_id, num_instances, grid_search) |
87 | 90 | self.assertEqual(len(run.trace_content), num_iterations * num_folds) |
88 | 91 |
|
| 92 | + def test_run_pipeline(self): |
| 93 | + task_id = 10107 |
| 94 | + num_instances = 150 |
| 95 | + num_folds = 10 |
| 96 | + num_iterations = 9 # (num values for C times gamma) |
| 97 | + |
| 98 | + scaler = StandardScaler(with_mean=False) |
| 99 | + dummy = DummyClassifier(strategy='prior') |
| 100 | + model = Pipeline(steps=(('scaler', scaler), ('dummy', dummy))) |
| 101 | + |
| 102 | + run = self._perform_run(task_id, num_instances, model) |
| 103 | + self.assertEqual(len(run.trace_content), num_iterations * num_folds) |
| 104 | + |
89 | 105 | def test__run_task_get_arffcontent(self): |
90 | 106 | task = openml.tasks.get_task(1939) |
91 | 107 | class_labels = task.class_labels |
|
0 commit comments