← Back to all products

Hyperparameter Tuning Kit

$29

Optuna/Ray Tune configs, search space definitions, pruning strategies, and distributed tuning setups.

📁 18 files🏷 v1.0.0
JSONMarkdownPython

📄 Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample

📁 File Structure 18 files

hyperparameter-tuning-kit/ ├── LICENSE ├── README.md ├── examples/ │ ├── optuna_sklearn.py │ ├── random_search_baseline.py │ └── ray_tune_torch.py ├── guides/ │ ├── hpo-guide.md │ └── search-space-design.md ├── src/ │ └── hpo/ │ ├── __init__.py │ ├── analysis.py │ ├── objective.py │ ├── optuna_search.py │ ├── pruning.py │ ├── ray_tune_search.py │ └── search_spaces.py └── tests/ ├── test_objective.py ├── test_pruning.py └── test_search_spaces.py

📖 Documentation Preview README excerpt

Hyperparameter Tuning Kit

A practical hyperparameter optimization toolkit built around a single idea: define

your search space once and run it on both Optuna and Ray Tune without

rewriting anything. Ships with cross-validated objectives, median/percentile

pruning, ASHA/PBT scheduling, multi-objective support, and backend-agnostic result

analysis.

The core (search spaces, pruning, objectives, analysis) depends only on the Python

standard library — it imports and its full test suite runs with no third-party

packages at all. Optuna and Ray Tune are imported lazily, so you install only the

backend you actually use.

Features

  • One declarative search space, two backends. SearchSpace compiles to the

Optuna suggest API and to a Ray Tune param_space dict — no drift between them.

  • Typed parametersFloatParameter, IntParameter, CategoricalParameter

with log scaling, step grids, and validation that rejects impossible ranges.

  • Cross-validated objectivesObjective wraps stdlib K-fold CV with a

per-fold pruning hook and first-class multi-objective support.

  • Pruning in plain PythonMedianPruner, PercentilePruner,

ThresholdPruner, and EarlyStopping, with startup/warmup/interval gates you can

unit-test and reason about (and convert to real Optuna pruners on demand).

  • Optuna runner — samplers (TPE, CMA-ES, QMC, random, grid), pruning, SQLite

persistence, resume, and multi-objective studies via a declarative StudyConfig.

  • Ray Tune runner — ASHA, Population Based Training, and median stopping via a

declarative TuneConfig, plus per-trial resources.

  • Result analysis — best/top-k trials, a fast parameter-importance proxy,

Pareto fronts, convergence history, and CSV/JSON export over a single

TrialRecord type that works regardless of backend.

  • A zero-dependency example that runs the moment you unzip the kit.

What's included


hyperparameter-tuning-kit/
├── src/hpo/
│   ├── search_spaces.py     # SearchSpace + typed params + RandomTrial (stdlib)
│   ├── pruning.py           # median/percentile/threshold pruners + early stopping
│   ├── objective.py         # scorers, K-fold CV, Objective (multi-objective)
│   ├── analysis.py          # best/top-k, importance, Pareto, export (stdlib)
│   ├── optuna_search.py     # StudyConfig + run_study (lazy `optuna`)
│   └── ray_tune_search.py   # TuneConfig + run_tune, ASHA/PBT (lazy `ray`)
├── examples/
│   ├── random_search_baseline.py  # runs on stdlib alone — start here
│   ├── optuna_sklearn.py          # tunes a GradientBoostingClassifier with Optuna
│   └── ray_tune_torch.py          # tunes a PyTorch MLP with Ray Tune + ASHA
├── guides/
│   ├── hpo-guide.md               # samplers, pruning, schedulers, budgets, pitfalls
│   └── search-space-design.md     # log scales, ranges, conditionals, worked spaces
├── tests/
│   ├── test_search_spaces.py
│   ├── test_pruning.py
│   └── test_objective.py
├── README.md
└── LICENSE

Quick start

... continues with setup instructions, usage examples, and more.

📄 Code Sample .py preview

src/hpo/search_spaces.py"""Declarative hyperparameter search spaces. A :class:`SearchSpace` is an ordered collection of typed parameters that compiles to **both** Optuna (via the ``suggest`` API) and Ray Tune (via ``to_ray``) from a single source of truth. Defining the space once and targeting two backends avoids the classic drift where the Optuna study and the Ray Tune ``param_space`` slowly diverge and produce incomparable results. The module depends only on the Python standard library. Optuna is never imported here at all (parameters are *suggested* by calling methods on whatever trial object you pass in, so a real ``optuna.Trial`` and the bundled :class:`RandomTrial` are interchangeable). Ray Tune is imported lazily inside :meth:`Parameter.to_ray`, so simply *building* a space never requires either library to be installed. Example ------- >>> space = SearchSpace([ ... FloatParameter("learning_rate", 1e-4, 1e-1, log=True), ... IntParameter("num_layers", 1, 8), ... CategoricalParameter("activation", ["relu", "gelu", "tanh"]), ... ]) >>> params = space.suggest(RandomTrial(seed=0)) >>> sorted(params) ['activation', 'learning_rate', 'num_layers'] """ from __future__ import annotations import math import random from dataclasses import dataclass from typing import Any, Iterable, Iterator, Mapping, Sequence __all__ = [ "Parameter", "FloatParameter", "IntParameter", "CategoricalParameter", "SearchSpace", "RandomTrial",
Buy Now — $29 Back to Products