skforecast/skforecast-ai/hyperparameter-optimization
- community
Checking that the SKILL.md file is still in the repository.
Optimizes forecaster hyperparameters using grid search, random search, or Bayesian search (Optuna). Covers single-series and multi-series search, cross-validation configuration, and search space definition. Use when the user wants to find the best model configuration.
Install
npx vskill@latest install skforecast/skforecast-ai/hyperparameter-optimizationSKILL.md
The same SKILL.md was published earlier as skforecast/skforecast/hyperparameter-optimization.
Hyperparameter Optimization
When to Use
Use hyperparameter search after establishing a baseline forecaster to improve prediction accuracy. Skforecast supports three strategies:
| Strategy | When to Use | Speed | |
|---|---|---|---|
| Bayesian Search | Recommended default. Smart exploration via Optuna | Fastest to converge | |
| Random Search | Large parameter space, limited compute budget | Medium | |
| Grid Search | Small parameter space, exhaustive exploration | Slowest |
Related skills
- Prerequisite:
autocorrelation-and-lag-selection(narrow thelagssearch space to a statistically informed candidate set) - Related:
baseline-forecasting(tuneForecasterEquivalentDatebaselines withgrid_search_equivalent_date) - Related:
foundation-forecasting(tune zero-shotForecasterFoundationinference parameters withbayesian_search_foundation) - Related:
feature-selection(optional trim of the feature set afterwards; re-tune if the reduction is large) - Next:
prediction-intervals(add uncertainty quantification once the configuration is fixed)
Stop Conditions
Scan before writing code. Each row lists a rule, the symptom when it is broken, and the recovery. Full pitfall catalog: the troubleshooting-common-errors skill.
| Rule | Symptom | Recovery | |
|---|---|---|---|
The search refits the forecaster in place with the best params when return_best=True (the default) | With return_best=False, the forecaster keeps its pre-search params | Rely on the default, or refit with the best params from the results table | |
Use the *_multiseries / *_stats search variant matching the forecaster type | Search function raises on the wrong forecaster type | Call e.g. bayesian_search_forecaster_multiseries / grid_search_stats / grid_search_equivalent_date | |
ForecasterFoundation is tuned only with bayesian_search_foundation and TimeSeriesFold | TypeError from the generic search functions, or from passing OneStepAheadFold | Call bayesian_search_foundation with a TimeSeriesFold | |
Include lags in the Bayesian search_space() | Suboptimal search; the highest-impact parameter stays fixed | Add trial.suggest_categorical('lags', [...]) to the search space |
Bayesian Search (Recommended)
Always prefer Bayesian search as the default strategy. It uses Optuna to intelligently explore the search space.
Grid Search
Random Search
Multi-Series Search
Statistical Models Search
Foundation Model Search
ForecasterFoundation is zero-shot: no weights are trained, so only the inference-time configuration is tuned. The highest-impact parameter is context_length (how many past observations are fed to the model). Use bayesian_search_foundation, which evaluates each trial with backtesting_foundation.
Differences from bayesian_search_forecaster: no lags in search_space, no n_jobs, TimeSeriesFold only, and every search_space key must be a valid adapter parameter. Search context_length and the adapter's quality-relevant parameters; device/dtype and other runtime settings are accepted but cannot improve accuracy, and several parameters force an expensive model reload per trial. Per-adapter tunables and reload matrix: the foundation-forecasting skill (references/adapter-parameters.md).
Fast Tuning with OneStepAheadFold
Common Mistakes
- Not setting `return_best=True`: The forecaster is not updated with the best parameters unless this is True.
- Too few trials in Bayesian search: Start with at least 20-50 trials for meaningful exploration. A small search may not beat the default configuration on the test set, because the configuration is chosen on the validation period, which can differ from the test period.
- Using TimeSeriesFold for initial tuning: Use
OneStepAheadFoldfirst for fast screening, then validate the top candidates withTimeSeriesFold. - Forgetting to include lags in search space: For Bayesian search, lags can be included in
search_space(); this is often the most impactful parameter. - Putting `lags` in a foundation `search_space`:
bayesian_search_foundationhas no lag concept; any key that is not an adapter parameter raisesValueError. - Passing the test set to the search: give the search only the training and validation data (e.g.
y=data.loc[:end_validation]). Withreturn_best=Truethe forecaster is refitted on everything the search receives, so keep the test set out and evaluate the refitted forecaster withbacktesting_forecasteron it.
References
See references/search-parameters.md for the complete parameter comparison across all 9 search functions, function routing by forecaster type, and lags_grid / search_space / param_grid usage details.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskforecast_ai/skills/hyperparameter-optimization/SKILL.md
Popularity
- Repository stars
- 50
- Repository forks
- 6
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/skforecast/skforecast-ai/hyperparameter-optimization)