models.grid_search()
Scores every candidate by cross_validate on the same splits and
Usage
models.grid_search(
candidates,
make,
design,
y,
splits,
score,
n_jobs=None,
)picks the lowest mean score.
Parameters
candidates: list-
Hyperparameter values, in any form
makeaccepts. make: callable-
make(candidate) -> model. design: Designy: list of floatsplits: list of (list of int, list of int)score: callable-
As cross_validate.
n_jobs: int = None
Returns
SearchResult
Examples
>>> from prospicio.models import Design, ElasticNet, deviance_score, grid_search, k_fold
>>> x = [i / 10 for i in range(40)]
>>> d = Design([[1.0] * 40, x], ["(Intercept)", "x"])
>>> y = [1.0 + 2.0 * v for v in x]
>>> found = grid_search([0.0, 1.0, 10.0], lambda lam: ElasticNet("gaussian", lam=lam),
... d, y, k_fold(40, 4, 1), deviance_score("gaussian"))
>>> found.best_candidate0.0