| Conditions | 1 |
| Total Lines | 32 |
| Code Lines | 13 |
| Lines | 32 |
| Ratio | 100 % |
| Changes | 0 | ||
| 1 | """Experiment adapter for sklearn cross-validation experiments.""" |
||
| 28 | def _score(self, **params): |
||
| 29 | """Score the parameters. |
||
| 30 | |||
| 31 | Parameters |
||
| 32 | ---------- |
||
| 33 | params : dict with string keys |
||
| 34 | Parameters to score. |
||
| 35 | |||
| 36 | Returns |
||
| 37 | ------- |
||
| 38 | float |
||
| 39 | The score of the parameters. |
||
| 40 | dict |
||
| 41 | Additional metadata about the search. |
||
| 42 | """ |
||
| 43 | estimator = clone(self.estimator) |
||
| 44 | estimator.set_params(**params) |
||
| 45 | |||
| 46 | cv_results = cross_validate( |
||
| 47 | self.estimator, |
||
| 48 | self.X, |
||
| 49 | self.y, |
||
| 50 | cv=self.cv, |
||
| 51 | ) |
||
| 52 | |||
| 53 | add_info_d = { |
||
| 54 | "score_time": cv_results["score_time"], |
||
| 55 | "fit_time": cv_results["fit_time"], |
||
| 56 | "n_test_samples": _num_samples(self.X), |
||
| 57 | } |
||
| 58 | |||
| 59 | return cv_results["test_score"].mean(), add_info_d |
||
| 60 |