|
9 | 9 |
|
10 | 10 | import numpy as np |
11 | 11 | import numpy.ma as npma |
12 | | -from sklearn.grid_search import _CVScoreTuple |
13 | 12 |
|
14 | 13 | import autosklearn.pipeline.util as putil |
15 | 14 | from autosklearn.classification import AutoSklearnClassifier |
@@ -114,7 +113,9 @@ def test_fit_pSMAC(self): |
114 | 113 | with open(true_targets_ensemble_path, 'rb') as fh: |
115 | 114 | true_targets_ensemble = np.load(fh) |
116 | 115 | true_targets_ensemble[-1] = 1 if true_targets_ensemble[-1] != 1 else 0 |
| 116 | + true_targets_ensemble = true_targets_ensemble.astype(int) |
117 | 117 | probas = np.zeros((len(true_targets_ensemble), 3), dtype=float) |
| 118 | + |
118 | 119 | for i, value in enumerate(true_targets_ensemble): |
119 | 120 | probas[i, value] = 1.0 |
120 | 121 | dummy_predictions_path = os.path.join(output, '.auto-sklearn', |
@@ -164,42 +165,6 @@ def test_fit_pSMAC(self): |
164 | 165 | del automl |
165 | 166 | self._tearDown(output) |
166 | 167 |
|
167 | | - def test_grid_scores(self): |
168 | | - output = os.path.join(self.test_dir, '..', '.tmp_grid_scores') |
169 | | - self._setUp(output) |
170 | | - |
171 | | - cls = AutoSklearnClassifier(time_left_for_this_task=30, |
172 | | - per_run_time_limit=5, |
173 | | - output_folder=output, |
174 | | - tmp_folder=output, |
175 | | - shared_mode=False, |
176 | | - seed=1, |
177 | | - initial_configurations_via_metalearning=0, |
178 | | - ensemble_size=0) |
179 | | - cls_ = cls.build_automl() |
180 | | - automl = cls_._automl |
181 | | - automl.runhistory_ = unittest.mock.MagicMock() |
182 | | - |
183 | | - RunKey = collections.namedtuple( |
184 | | - 'RunKey', ['config_id', 'instance_id', 'seed']) |
185 | | - |
186 | | - RunValue = collections.namedtuple( |
187 | | - 'RunValue', ['cost', 'time', 'status', 'additional_info']) |
188 | | - |
189 | | - runhistory = dict() |
190 | | - runhistory[RunKey(1, 1, 1)] = RunValue(1, 1, 1, '') |
191 | | - automl.runhistory_.data = runhistory |
192 | | - grid_scores_ = automl.grid_scores_ |
193 | | - |
194 | | - self.assertIsInstance(grid_scores_[0], _CVScoreTuple) |
195 | | - # In the runhistory we store losses, thus the score is zero |
196 | | - self.assertEqual(grid_scores_[0].mean_validation_score, 0) |
197 | | - self.assertEqual(grid_scores_[0].cv_validation_scores, [0]) |
198 | | - self.assertIsInstance(grid_scores_[0].parameters, unittest.mock.MagicMock) |
199 | | - |
200 | | - del automl |
201 | | - self._tearDown(output) |
202 | | - |
203 | 168 | def test_cv_results(self): |
204 | 169 | # TODO restructure and actually use real SMAC output from a long run |
205 | 170 | # to do this unittest! |
|
0 commit comments