Auxiliary data struct to hold all boosters of CV.
| 274 | |
| 275 | |
| 276 | class _CVBooster(object): |
| 277 | """Auxiliary data struct to hold all boosters of CV.""" |
| 278 | |
| 279 | def __init__(self): |
| 280 | self.boosters = [] |
| 281 | self.best_iteration = -1 |
| 282 | |
| 283 | def append(self, booster): |
| 284 | """Add a booster to _CVBooster.""" |
| 285 | self.boosters.append(booster) |
| 286 | |
| 287 | def __getattr__(self, name): |
| 288 | """Redirect methods call of _CVBooster.""" |
| 289 | def handler_function(*args, **kwargs): |
| 290 | """Call methods with each booster, and concatenate their results.""" |
| 291 | ret = [] |
| 292 | for booster in self.boosters: |
| 293 | ret.append(getattr(booster, name)(*args, **kwargs)) |
| 294 | return ret |
| 295 | return handler_function |
| 296 | |
| 297 | |
| 298 | def _make_n_folds(full_data, folds, nfold, params, seed, fpreproc=None, stratified=True, |