sdkagent

optuna API reference

188 public APIs from optuna (optuna/optuna) — 66 classes, 31 functions, 91 methods. Signatures extracted by static analysis of the actual source.

Repository: optuna/optuna

KindCount
Classes66
Functions31
Methods91

API list

classoptuna._callbacks.MaxTrialsCallback
Set a maximum number of trials before ending the study.
funcoptuna._deprecated.deprecated_class(deprecated_version:str, removed_version:str, name:str | None=None, text:str | None=None) -> 'Callable[[CT], CT]'
Decorate class as deprecated.
funcoptuna._deprecated.deprecated_func(deprecated_version:str, removed_version:str, name:str | None=None, text:str | None=None) -> 'Callable[[Callable[FP, FT]], Callable[FP, FT]]'
Decorate function as deprecated.
funcoptuna._deprecated.wrapper(*args:Any, **kwargs:Any) -> 'FT'
Decorates a function as deprecated.
funcoptuna._experimental.experimental_class(version:str, name:str | None=None) -> Callable[[CT], CT]
Decorate class as experimental.
funcoptuna._experimental.experimental_func(version:str, name:str | None=None) -> Callable[[Callable[FP, FT]], Callable[FP, FT]]
Decorate function as experimental.
funcoptuna._hypervolume.wfg.compute_hypervolume(loss_vals:np.ndarray, reference_point:np.ndarray, assume_pareto:bool=False) -> float
Hypervolume calculator for any dimension.
classoptuna.artifacts._backoff.Backoff
An artifact store's middleware for exponential backoff.
classoptuna.artifacts._boto3.Boto3ArtifactStore
An artifact backend for Boto3.
funcoptuna.artifacts._download.download_artifact(*artifact_store:ArtifactStore, *file_path:str, *artifact_id:str) -> None
Download an artifact from the artifact store.
classoptuna.artifacts._filesystem.FileSystemArtifactStore
An artifact store for file systems.
classoptuna.artifacts._gcs.GCSArtifactStore
An artifact backend for Google Cloud Storage (GCS).
classoptuna.artifacts._protocol.ArtifactStore
A protocol defining the interface for an artifact backend.
methodoptuna.artifacts._protocol.ArtifactStore.open_reader(artifact_id:str) -> BinaryIO
Open the artifact identified by the artifact_id.
methodoptuna.artifacts._protocol.ArtifactStore.remove(artifact_id:str) -> None
Remove the artifact identified by the artifact_id.
methodoptuna.artifacts._protocol.ArtifactStore.write(artifact_id:str, content_body:BinaryIO) -> None
Save the content to the backend.
classoptuna.artifacts._upload.ArtifactMeta
Meta information for an artifact.
classoptuna.artifacts.exceptions.ArtifactNotFound
Exception raised when an artifact is not found.
classoptuna.distributions.BaseDistribution
Base class for distributions.
classoptuna.distributions.CategoricalDistribution
A categorical distribution.
classoptuna.distributions.DiscreteUniformDistribution
A discretized uniform distribution in the linear domain.
methodoptuna.distributions.DiscreteUniformDistribution.q() -> float
Discretization step.
classoptuna.distributions.FloatDistribution
A distribution on floats.
classoptuna.distributions.IntDistribution
A distribution on integers.
classoptuna.distributions.IntLogUniformDistribution
A uniform distribution on integers in the log domain.
classoptuna.distributions.IntUniformDistribution
A uniform distribution on integers.
classoptuna.distributions.LogUniformDistribution
A uniform distribution in the log domain.
classoptuna.distributions.UniformDistribution
A uniform distribution in the linear domain.
funcoptuna.distributions.check_distribution_compatibility(dist_old:BaseDistribution, dist_new:BaseDistribution) -> None
A function to check compatibility of two distributions.
funcoptuna.distributions.distribution_to_json(dist:BaseDistribution) -> str
Serialize a distribution to JSON format.
funcoptuna.distributions.json_to_distribution(json_str:str) -> BaseDistribution
Deserialize a distribution in JSON format.
classoptuna.exceptions.CLIUsageError
Exception for CLI.
classoptuna.exceptions.DuplicatedStudyError
Exception for a duplicated study name.
classoptuna.exceptions.ExperimentalWarning
Experimental Warning class.
classoptuna.exceptions.OptunaError
Base class for Optuna specific errors.
classoptuna.exceptions.StorageInternalError
Exception for storage operation.
classoptuna.exceptions.TrialPruned
Exception for pruned trials.
classoptuna.exceptions.UpdateFinishedTrialError
Exception for updating a finished trial.
classoptuna.importance._base.BaseImportanceEvaluator
Abstract parameter importance evaluator.
classoptuna.importance._fanova._evaluator.FanovaImportanceEvaluator
fANOVA importance evaluator.
classoptuna.importance._ped_anova.evaluator.PedAnovaImportanceEvaluator
PED-ANOVA importance evaluator.
funcoptuna.logging.create_default_formatter() -> logging.Formatter
Create a default formatter of log messages.
funcoptuna.logging.disable_default_handler() -> None
Disable the default handler of the Optuna's root logger.
funcoptuna.logging.disable_propagation() -> None
Disable propagation of the library log outputs.
funcoptuna.logging.enable_default_handler() -> None
Enable the default handler of the Optuna's root logger.
funcoptuna.logging.enable_propagation() -> None
Enable propagation of the library log outputs.
funcoptuna.logging.get_logger(name:str) -> logging.Logger
Return a logger with the specified name.
funcoptuna.logging.get_verbosity() -> int
Return the current level for the Optuna's root logger.
funcoptuna.logging.set_verbosity(verbosity:int) -> None
Set the level for the Optuna's root logger.
classoptuna.pruners._base.BasePruner
Base class for pruners.
classoptuna.pruners._hyperband.HyperbandPruner
Pruner using Hyperband.
classoptuna.pruners._median.MedianPruner
Pruner using the median stopping rule.
classoptuna.pruners._nop.NopPruner
Pruner which never prunes trials.
classoptuna.pruners._patient.PatientPruner
Pruner which wraps another pruner with tolerance.
classoptuna.pruners._percentile.PercentilePruner
Pruner to keep the specified percentile of the trials.
classoptuna.pruners._successive_halving.SuccessiveHalvingPruner
Pruner using Asynchronous Successive Halving Algorithm.
classoptuna.pruners._threshold.ThresholdPruner
Pruner to detect outlying metrics of the trials.
classoptuna.samplers._base.BaseSampler
Base class for samplers.
methodoptuna.samplers._base.BaseSampler.after_trial(study:Study, trial:FrozenTrial, state:TrialState, values:Sequence[float] | None) -> None
Trial post-processing.
methodoptuna.samplers._base.BaseSampler.before_trial(study:Study, trial:FrozenTrial) -> None
Trial pre-processing.
methodoptuna.samplers._base.BaseSampler.reseed_rng() -> None
Reseed sampler's random number generator.
methodoptuna.samplers._base.BaseSampler.sample_independent(study:Study, trial:FrozenTrial, param_name:str, param_distribution:BaseDistribution) -> Any
Sample a parameter for a given distribution.
methodoptuna.samplers._base.BaseSampler.sample_relative(study:Study, trial:FrozenTrial, search_space:dict[str, BaseDistribution]) -> dict[str, Any]
Sample parameters in a given search space.
classoptuna.samplers._ga._base.BaseGASampler
Base class for Genetic Algorithm (GA) samplers.
methodoptuna.samplers._ga._base.BaseGASampler.get_parent_population(study:Study, generation:int) -> list[FrozenTrial]
Get the parent population of the given generation.
methodoptuna.samplers._ga._base.BaseGASampler.get_population(study:Study, generation:int) -> list[FrozenTrial]
Get the population of the given generation.
methodoptuna.samplers._ga._base.BaseGASampler.get_trial_generation(study:Study, trial:FrozenTrial) -> int
Get the generation number of the given trial.
classoptuna.samplers._gp.sampler.GPSampler
Sampler using Gaussian process-based Bayesian optimization.
classoptuna.samplers._lazy_random_state.LazyRandomState
Lazy Random State class.
classoptuna.samplers._nsgaiii._sampler.NSGAIIISampler
Multi-objective sampler using the NSGA-III algorithm.
classoptuna.samplers._partial_fixed.PartialFixedSampler
Sampler with partially fixed parameters.
classoptuna.samplers._random.RandomSampler
Sampler using random sampling.
classoptuna.samplers.nsgaii._crossovers._base.BaseCrossover
Base class for crossovers.
classoptuna.samplers.nsgaii._mutations._base.BaseMutation
Base class for mutations.
methodoptuna.samplers.nsgaii._mutations._base.BaseMutation.mutation(param:float, rng:np.random.RandomState, study:Study, search_space_bounds:np.ndarray) -> float
Mutate the given parameter.
classoptuna.samplers.nsgaii._sampler.NSGAIISampler
Multi-objective sampler using the NSGA-II algorithm.
classoptuna.storages._base.BaseStorage
Base class for storages.
methodoptuna.storages._base.BaseStorage.check_trial_is_updatable(trial_id:int, trial_state:TrialState) -> None
Check whether a trial state is updatable.
methodoptuna.storages._base.BaseStorage.create_new_study(directions:Sequence[StudyDirection], study_name:str | None=None) -> int
Create a new study from a name.
methodoptuna.storages._base.BaseStorage.create_new_trial(study_id:int, template_trial:FrozenTrial | None=None) -> int
Create and add a new trial to a study.
methodoptuna.storages._base.BaseStorage.delete_study(study_id:int) -> None
Delete a study.
methodoptuna.storages._base.BaseStorage.get_all_trials(study_id:int, deepcopy:bool=True, states:Container[TrialState] | None=None) -> list[FrozenTrial]
Read all trials in a study.
methodoptuna.storages._base.BaseStorage.get_best_trial(study_id:int) -> FrozenTrial
Return the trial with the best value in a study.
methodoptuna.storages._base.BaseStorage.get_n_trials(study_id:int, state:tuple[TrialState, ...] | TrialState | None=None) -> int
Count the number of trials in a study.
methodoptuna.storages._base.BaseStorage.get_study_directions(study_id:int) -> list[StudyDirection]
Read whether a study maximizes or minimizes an objective.
methodoptuna.storages._base.BaseStorage.get_study_id_from_name(study_name:str) -> int
Read the ID of a study.
methodoptuna.storages._base.BaseStorage.get_study_name_from_id(study_id:int) -> str
Read the study name of a study.
methodoptuna.storages._base.BaseStorage.get_study_system_attrs(study_id:int) -> dict[str, Any]
Read the optuna-internal attributes of a study.
methodoptuna.storages._base.BaseStorage.get_study_user_attrs(study_id:int) -> dict[str, Any]
Read the user-defined attributes of a study.
methodoptuna.storages._base.BaseStorage.get_trial(trial_id:int) -> FrozenTrial
Read a trial.
methodoptuna.storages._base.BaseStorage.get_trial_id_from_study_id_trial_number(study_id:int, trial_number:int) -> int
Read the trial ID of a trial.
methodoptuna.storages._base.BaseStorage.get_trial_number_from_id(trial_id:int) -> int
Read the trial number of a trial.
methodoptuna.storages._base.BaseStorage.get_trial_param(trial_id:int, param_name:str) -> float
Read the parameter of a trial.
methodoptuna.storages._base.BaseStorage.get_trial_params(trial_id:int) -> dict[str, Any]
Read the parameter dictionary of a trial.
methodoptuna.storages._base.BaseStorage.get_trial_system_attrs(trial_id:int) -> dict[str, Any]
Read the optuna-internal attributes of a trial.
methodoptuna.storages._base.BaseStorage.get_trial_user_attrs(trial_id:int) -> dict[str, Any]
Read the user-defined attributes of a trial.
methodoptuna.storages._base.BaseStorage.remove_session() -> None
Clean up all connections to a database.
methodoptuna.storages._base.BaseStorage.set_study_system_attr(study_id:int, key:str, value:JSONSerializable) -> None
Register an optuna-internal attribute to a study.
methodoptuna.storages._base.BaseStorage.set_study_user_attr(study_id:int, key:str, value:Any) -> None
Register a user-defined attribute to a study.
methodoptuna.storages._base.BaseStorage.set_trial_intermediate_value(trial_id:int, step:int, intermediate_value:float) -> None
Report an intermediate value of an objective function.
methodoptuna.storages._base.BaseStorage.set_trial_param(trial_id:int, param_name:str, param_value_internal:float, distribution:BaseDistribution) -> None
Set a parameter to a trial.
methodoptuna.storages._base.BaseStorage.set_trial_state_values(trial_id:int, state:TrialState, values:Sequence[float] | None=None) -> bool
Update the state and values of a trial.
methodoptuna.storages._base.BaseStorage.set_trial_system_attr(trial_id:int, key:str, value:JSONSerializable) -> None
Set an optuna-internal attribute to a trial.
methodoptuna.storages._base.BaseStorage.set_trial_user_attr(trial_id:int, key:str, value:Any) -> None
Set a user-defined attribute to a trial.
classoptuna.storages._heartbeat.BaseHeartbeat
Base class for heartbeat.
methodoptuna.storages._heartbeat.BaseHeartbeat.get_heartbeat_interval() -> int | None
Get the heartbeat interval if it is set.
methodoptuna.storages._heartbeat.BaseHeartbeat.record_heartbeat(trial_id:int) -> None
Record the heartbeat of the trial.
funcoptuna.storages._heartbeat.fail_stale_trials(study:'optuna.Study') -> None
Fail stale trials and run their failure callbacks.
funcoptuna.storages._heartbeat.is_heartbeat_enabled(storage:BaseStorage) -> bool
Check whether the storage enables the heartbeat.
funcoptuna.storages._rdb.alembic.env.run_migrations_offline()
Run migrations in 'offline' mode.
funcoptuna.storages._rdb.alembic.env.run_migrations_online()
Run migrations in 'online' mode.
classoptuna.storages._rdb.storage.RDBStorage
Storage class for RDB backend.
methodoptuna.storages._rdb.storage.RDBStorage.get_all_versions() -> list[str]
Return the schema version list.
methodoptuna.storages._rdb.storage.RDBStorage.get_head_version() -> str
Return the latest schema version.
methodoptuna.storages._rdb.storage.RDBStorage.remove_session() -> None
Removes the current session.
methodoptuna.storages._rdb.storage.RDBStorage.upgrade() -> None
Upgrade the storage schema.
funcoptuna.storages.get_storage(storage:None | str | BaseStorage) -> BaseStorage
Only for internal usage.
classoptuna.storages.journal._base.BaseJournalBackend
Base class for Journal storages.
methodoptuna.storages.journal._base.BaseJournalBackend.append_logs(logs:list[dict[str, Any]]) -> None
Append logs to the backend.
classoptuna.storages.journal._base.BaseJournalLogStorage
Base class for Journal storages.
classoptuna.storages.journal._base.BaseJournalSnapshot
Optional base class for Journal storages.
methodoptuna.storages.journal._base.BaseJournalSnapshot.load_snapshot() -> bytes | None
Load snapshot from the backend.
methodoptuna.storages.journal._base.BaseJournalSnapshot.save_snapshot(snapshot:bytes) -> None
Save snapshot to the backend.
classoptuna.storages.journal._file.JournalFileBackend
File storage class for Journal log backend.
methodoptuna.storages.journal._file.JournalFileOpenLock.release() -> None
Release a lock by removing the created file.
methodoptuna.storages.journal._file.JournalFileSymlinkLock.release() -> None
Release a lock by removing the symbolic link.
classoptuna.storages.journal._redis.JournalRedisBackend
Redis storage class for Journal log backend.
classoptuna.storages.journal._storage.JournalStorage
Storage class for Journal storage backend.
classoptuna.study._frozen.FrozenStudy
Basic attributes of a :class:`~optuna.study.Study`.
classoptuna.study._study_direction.StudyDirection
Direction of a :class:`~optuna.study.Study`.
methodoptuna.study.study.Study.add_trial(trial:FrozenTrial) -> None
Add trial to study.
methodoptuna.study.study.Study.add_trials(trials:Iterable[FrozenTrial]) -> None
Add trials to study.
methodoptuna.study.study.Study.best_params() -> dict[str, Any]
Return parameters of the best trial in the study.
methodoptuna.study.study.Study.best_trial() -> FrozenTrial
Return the best trial in the study.
methodoptuna.study.study.Study.best_trials() -> list[FrozenTrial]
Return trials located at the Pareto front in the study.
methodoptuna.study.study.Study.best_value() -> float
Return the best objective value in the study.
methodoptuna.study.study.Study.direction() -> StudyDirection
Return the direction of the study.
methodoptuna.study.study.Study.directions() -> list[StudyDirection]
Return the directions of the study.
methodoptuna.study.study.Study.enqueue_trial(params:dict[str, Any], user_attrs:dict[str, Any] | None=None, skip_if_exists:bool=False) -> None
Enqueue a trial with given parameter values.
methodoptuna.study.study.Study.get_trials(deepcopy:bool=True, states:Container[TrialState] | None=None) -> list[FrozenTrial]
Return all trials in the study.
methodoptuna.study.study.Study.metric_names() -> list[str] | None
Return metric names.
methodoptuna.study.study.Study.set_metric_names(metric_names:list[str]) -> None
Set metric names.
methodoptuna.study.study.Study.set_system_attr(key:str, value:Any) -> None
Set a system attribute to the study.
methodoptuna.study.study.Study.set_user_attr(key:str, value:Any) -> None
Set a user attribute to the study.
methodoptuna.study.study.Study.system_attrs() -> dict[str, Any]
Return system attributes.
methodoptuna.study.study.Study.trials() -> list[FrozenTrial]
Return all trials in the study.
methodoptuna.study.study.Study.user_attrs() -> dict[str, Any]
Return user attributes.
funcoptuna.study.study.copy_study(*from_study_name:str, *from_storage:str | storages.BaseStorage, *to_storage:str | storages.BaseStorage, *to_study_name:str | None=None) -> None
Copy study from one storage to another.
funcoptuna.study.study.delete_study(*study_name:str, *storage:str | storages.BaseStorage) -> None
Delete a :class:`~optuna.study.Study` object.
funcoptuna.study.study.get_all_study_names(storage:str | storages.BaseStorage) -> list[str]
Get all study names stored in a specified storage.
classoptuna.terminator.erroreval.BaseErrorEvaluator
Base class for error evaluators.
classoptuna.terminator.erroreval.StaticErrorEvaluator
An error evaluator that always returns a constant value.
funcoptuna.terminator.erroreval.report_cross_validation_scores(trial:Trial, scores:list[float]) -> None
A function to report cross-validation scores of a trial.
classoptuna.terminator.improvement.evaluator.BaseImprovementEvaluator
Base class for improvement evaluators.
classoptuna.terminator.terminator.BaseTerminator
Base class for terminators.
classoptuna.terminator.terminator.Terminator
Automatic stopping mechanism for Optuna studies.
classoptuna.trial._base.BaseTrial
Base class for trials.
classoptuna.trial._fixed.FixedTrial
A trial class which suggests a fixed value for each parameter.
methodoptuna.trial._fixed.FixedTrial.constraints() -> dict[str, float]
Returns constraint values.
methodoptuna.trial._fixed.FixedTrial.set_constraint(key:str, value:float) -> None
Set a constraint value for the trial.
classoptuna.trial._frozen.FrozenTrial
Status and results of a :class:`~optuna.trial.Trial`.
methodoptuna.trial._frozen.FrozenTrial.constraints() -> dict[str, float]
Returns constraint values.
methodoptuna.trial._frozen.FrozenTrial.duration() -> datetime.timedelta | None
Return the elapsed time taken to complete the trial.
methodoptuna.trial._frozen.FrozenTrial.report(value:float, step:int) -> None
Interface of report function.
methodoptuna.trial._frozen.FrozenTrial.set_constraint(key:str, value:float) -> None
Set a constraint value for the trial.
methodoptuna.trial._frozen.FrozenTrial.should_prune() -> bool
Suggest whether the trial should be pruned or not.
classoptuna.trial._state.TrialState
State of a :class:`~optuna.trial.Trial`.
classoptuna.trial._trial.Trial
A trial is a process of evaluating an objective function.
methodoptuna.trial._trial.Trial.constraints() -> dict[str, float]
Returns constraint values.
methodoptuna.trial._trial.Trial.datetime_start() -> datetime.datetime | None
Return start datetime.
methodoptuna.trial._trial.Trial.distributions() -> dict[str, BaseDistribution]
Return distributions of parameters to be optimized.
methodoptuna.trial._trial.Trial.params() -> dict[str, Any]
Return parameters to be optimized.
methodoptuna.trial._trial.Trial.report(value:float, step:int) -> None
Report an objective function value for a given step.
methodoptuna.trial._trial.Trial.set_constraint(key:str, value:float) -> None
Set a constraint value for the trial.
methodoptuna.trial._trial.Trial.set_system_attr(key:str, value:Any) -> None
Set system attributes to the trial.
methodoptuna.trial._trial.Trial.set_user_attr(key:str, value:Any) -> None
Set user attributes to the trial.
methodoptuna.trial._trial.Trial.should_prune() -> bool
Suggest whether the trial should be pruned or not.
methodoptuna.trial._trial.Trial.suggest_discrete_uniform(name:str, low:float, high:float, q:float) -> float
Suggest a value for the discrete parameter.
methodoptuna.trial._trial.Trial.suggest_float(name:str, low:float, high:float, *step:float | None=None, *log:bool=False) -> float
Suggest a value for the floating point parameter.
methodoptuna.trial._trial.Trial.suggest_int(name:str, low:int, high:int, *step:int=1, *log:bool=False) -> int
Suggest a value for the integer parameter.
methodoptuna.trial._trial.Trial.suggest_loguniform(name:str, low:float, high:float) -> float
Suggest a value for the continuous parameter.
methodoptuna.trial._trial.Trial.suggest_uniform(name:str, low:float, high:float) -> float
Suggest a value for the continuous parameter.
methodoptuna.trial._trial.Trial.system_attrs() -> dict[str, Any]
Return system attributes.
methodoptuna.trial._trial.Trial.user_attrs() -> dict[str, Any]
Return user attributes.
funcoptuna.visualization._hypervolume_history.plot_hypervolume_history(study:Study, reference_point:Sequence[float]) -> 'go.Figure'
Plot hypervolume history of all trials in a study.
funcoptuna.visualization._intermediate_values.plot_intermediate_values(study:Study) -> 'go.Figure'
Plot intermediate values of all trials in a study.
funcoptuna.visualization._timeline.plot_timeline(study:Study, n_recent_trials:int | None=None) -> 'go.Figure'
Plot the timeline of a study.
funcoptuna.visualization.matplotlib._timeline.plot_timeline(study:Study, n_recent_trials:int | None=None) -> 'Axes'
Plot the timeline of a study.

About this data

These signatures were extracted from the public source of optuna/optuna using Python's ast module. Argument names, default values, type annotations and return types are taken verbatim from the code. Implementation bodies are never stored. See how it works for details.

Back to all 805 libraries