Exceptions¶
-
class
optuna.exceptions.
TrialPruned
[source]¶ Exception for pruned trials.
This error tells a trainer that the current
Trial
was pruned. It is supposed to be raised afteroptuna.trial.Trial.should_prune()
as shown in the following example.Example
import optuna from sklearn.linear_model import SGDClassifier def objective(trial): alpha = trial.suggest_uniform('alpha', 0.0, 1.0) clf = SGDClassifier(alpha=alpha) n_train_iter = 100 for step in range(n_train_iter): clf.partial_fit(X_train, y_train, classes=classes) intermediate_value = clf.score(X_test, y_test) trial.report(intermediate_value, step) if trial.should_prune(): raise optuna.exceptions.TrialPruned() return clf.score(X_test, y_test) study = optuna.create_study(direction='maximize') study.optimize(objective, n_trials=20)
-
class
optuna.exceptions.
CLIUsageError
[source]¶ Exception for CLI.
CLI raises this exception when it receives invalid configuration.