slickbet.tune¶
Hyperparameter tuning for the betting model.
Uses cached API data to run backtests across different weight configurations and find the best parameters. No API calls during tuning.
Examples
>>> # 1. Populate cache:
>>> # slickbet backtest-all --weeks 12 --cache-dir data/12_weeks_cache
>>> # 2. Run tuning:
>>> # slickbet tune --cache-dir data/12_weeks_cache --trials 20
>>> from slickbet.tune import tune
>>> best = tune(cache_dir="data/12_weeks_cache", weeks=12, trials=20)
Attributes¶
Classes¶
Result of a single tuning trial. |
Functions¶
|
Format weights for copying into BettingModel. |
Run backtest-all-global with given weights using cached data. |
|
|
Run hyperparameter tuning over weight configurations. |
Module Contents¶
- slickbet.tune.ALL_LEAGUES = [('1', 'Bundesliga', 'Germany'), ('2', 'Premier League', 'England'), ('3', 'La Liga', 'Spain'),...¶
- slickbet.tune.AMERICAS_LEAGUES = [('23', 'Liga Professional', 'Argentina'), ('24', 'Serie A Brazil', 'Brazil'), ('45', 'Liga MX',...¶
- slickbet.tune.ASIA_LEAGUES = [('313', 'Saudi Pro League', 'Saudi Arabia'), ('67', 'Hyundai A-League', 'Australia'), ('28',...¶
- slickbet.tune.MAJOR_LEAGUES = [('1', 'Bundesliga', 'Germany'), ('2', 'Premier League', 'England'), ('3', 'La Liga', 'Spain'),...¶
- slickbet.tune.MINOR_LEAGUES = [('68', 'Belgian Pro League', 'Belgium'), ('8', 'Primeira Liga', 'Portugal'), ('6', 'Super Lig',...¶
- slickbet.tune.format_best_weights(weights: dict[str, float]) str[source]¶
Format weights for copying into BettingModel.
- Parameters:
weights (dict[str, float]) – Factor name → weight mapping.
- Returns:
str – Indented
"name": value,lines sorted by name.
- slickbet.tune.run_backtest_with_weights(cache_dir: str | pathlib.Path, weeks: int, weights: dict[str, float], min_probability: float = 0.0) slickbet.backtest.BacktestResults | None[source]¶
Run backtest-all-global with given weights using cached data.
- Parameters:
cache_dir (str or Path) – Directory with cached API data.
weeks (int) – Weeks of history (must match what was cached).
weights (dict[str, float]) – Factor name → weight mapping for BettingModel.
min_probability (float, optional) – Minimum prediction probability to include.
- Returns:
BacktestResults or None – Aggregated results, or None if no matches.
- slickbet.tune.tune(cache_dir: str | pathlib.Path, weeks: int = 12, trials: int = 20, strategy: str = 'random', min_probability: float = 0.0, metric: str = 'accuracy_excl_draws', verbose: bool = True) TuneResult | None[source]¶
Run hyperparameter tuning over weight configurations.
- Parameters:
cache_dir (str or Path) – Directory with cached API data (from prior backtest with –cache-dir).
weeks (int) – Weeks of data (must match what was cached).
trials (int) – Number of weight configurations to try.
strategy (str) – “random” = random weights, “near_default” = perturb defaults.
min_probability (float) – Minimum prediction probability to include.
metric (str) – “accuracy”, “accuracy_excl_draws”, or “best_dc”.
verbose (bool) – Print progress.
- Returns:
TuneResult or None – Best result, or None if no valid trials.