MCPcopy
hub / github.com/optuna/optuna / create_study

Function create_study

optuna/study/study.py:1204–1341  ·  view source on GitHub ↗

Create a new :class:`~optuna.study.Study`. Example: .. testcode:: import optuna def objective(trial): x = trial.suggest_float("x", 0, 10) return x**2 study = optuna.create_study() study.optimize(object

(
    *,
    storage: str | storages.BaseStorage | None = None,
    sampler: "samplers.BaseSampler" | None = None,
    pruner: pruners.BasePruner | None = None,
    study_name: str | None = None,
    direction: str | StudyDirection | None = None,
    load_if_exists: bool = False,
    directions: Sequence[str | StudyDirection] | None = None,
)

Source from the content-addressed store, hash-verified

1202 removed_version="5.0.0",
1203)
1204def create_study(
1205 *,
1206 storage: str | storages.BaseStorage | None = None,
1207 sampler: "samplers.BaseSampler" | None = None,
1208 pruner: pruners.BasePruner | None = None,
1209 study_name: str | None = None,
1210 direction: str | StudyDirection | None = None,
1211 load_if_exists: bool = False,
1212 directions: Sequence[str | StudyDirection] | None = None,
1213) -> Study:
1214 """Create a new :class:`~optuna.study.Study`.
1215
1216 Example:
1217
1218 .. testcode::
1219
1220 import optuna
1221
1222
1223 def objective(trial):
1224 x = trial.suggest_float("x", 0, 10)
1225 return x**2
1226
1227
1228 study = optuna.create_study()
1229 study.optimize(objective, n_trials=3)
1230
1231 Args:
1232 storage:
1233 Database URL. If this argument is set to None,
1234 :class:`~optuna.storages.InMemoryStorage` is used, and the
1235 :class:`~optuna.study.Study` will not be persistent.
1236
1237 .. note::
1238 When a database URL is passed, Optuna internally uses `SQLAlchemy`_ to handle
1239 the database. Please refer to `SQLAlchemy's document`_ for further details.
1240 If you want to specify non-default options to `SQLAlchemy Engine`_, you can
1241 instantiate :class:`~optuna.storages.RDBStorage` with your desired options and
1242 pass it to the ``storage`` argument instead of a URL.
1243
1244 .. _SQLAlchemy: https://www.sqlalchemy.org/
1245 .. _SQLAlchemy's document:
1246 https://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls
1247 .. _SQLAlchemy Engine: https://docs.sqlalchemy.org/en/latest/core/engines.html
1248
1249 sampler:
1250 A sampler object that implements background algorithm for value suggestion.
1251 If :obj:`None` is specified, :class:`~optuna.samplers.TPESampler` is used during
1252 single-objective optimization and :class:`~optuna.samplers.NSGAIISampler` during
1253 multi-objective optimization. See also :class:`~optuna.samplers`.
1254 pruner:
1255 A pruner object that decides early stopping of unpromising trials. If :obj:`None`
1256 is specified, :class:`~optuna.pruners.MedianPruner` is used as the default. See
1257 also :class:`~optuna.pruners`.
1258 study_name:
1259 Study's name. If this argument is set to None, a unique name is generated
1260 automatically.
1261 direction:

Calls 4

StudyClass · 0.85
create_new_studyMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…