Tune Command - Search for the best hyperparameters of an algorithm.
Functions
tuiml tune [OPTIONS]
Search for the hyperparameters that score best.
Scores candidate configurations by cross-validation and reports the best parameters, the best score, and a model refitted with those settings. Grid search tries every combination, random search samples a fixed number of candidates, and Bayesian search uses a Gaussian process to decide where to look next.
Exhaustive grid search over two hyperparameters:
bash
$ tuiml tune --algorithm RandomForestClassifier --data iris --target class --method grid --param-grid '{"n_estimators": [50, 100, 200], "max_depth": [3, 5, 10]}'
Random search with a bounded integer range and a fixed budget:
bash
$ tuiml tune --algorithm RandomForestClassifier --data data.csv --target label --method random --param-grid '{"n_estimators": [10, 500, "int"]}' --n-iter 25 --random-seed 42
Bayesian search optimising R-squared with 5-fold CV:
bash
$ tuiml tune --algorithm SVR --data housing.csv --target price --method bayesian --param-grid '{"C": [0.1, 100.0]}' --scoring r2 --cv 5
Options
--algorithm
str required
Exact algorithm class name to tune, e.g. 'RandomForestClassifier'.
--data
str required
Path to a data file or a built-in dataset name.
--target
str required
Name of the target column in the data.
--method
str required
Search strategy: 'grid' (exhaustive), 'random' (sampled), or 'bayesian' (Gaussian-process guided).
--param-grid
str required
Search space as a JSON object. For grid: {"param": [val1, val2]}. For random/bayesian a range may be given as {"param": [low, high, "int"]}.
--cv
int
Number of cross-validation folds used to score each candidate.
--scoring
str
Metric to maximise, e.g. 'accuracy', 'r2', or 'neg_mse'. Defaults to a metric chosen for the task.
--n-iter
int
Number of candidates to sample. Random search only.
--n-iterations
int
Number of optimisation rounds. Bayesian search only.
--random-seed
int
Random seed, so the sampled candidates and CV splits are reproducible.
--json-output
flag
Print the raw JSON result.