简体   繁体   English

Optuna 多目标优化的最佳参数

[英]Best parameters of an Optuna multi-objective optimization

When performing a single-objective optimization with Optuna , the best parameters of the study are accessible using:使用Optuna执行单目标优化时,可以使用以下方法访问研究的最佳参数:

import optuna
def objective(trial):
    x = trial.suggest_uniform('x', -10, 10)
    return (x - 2) ** 2

study = optuna.create_study(direction='minimize')
study.optimize(objective, n_trials=100)

study.best_params  # E.g. {'x': 2.002108042}

If I want to perform a multi-objective optimization, this would be become for example:如果我想执行多目标优化,这将成为例如:

import optuna
def multi_objective(trial):
    x = trial.suggest_uniform('x', -10, 10)
    f1 = (x - 2) ** 2
    f2 = -f1
    return f1, f2

study = optuna.create_study(directions=['minimize', 'maximize'])
study.optimize(multi_objective, n_trials=100)

This works, but the command study.best_params fails with RuntimeError: The best trial of a 'study' is only supported for single-objective optimization.这可行,但命令study.best_params失败并出现RuntimeError: The best trial of a 'study' is only supported for single-objective optimization.

How can I get the best parameters for a multi-objective optimization?如何获得多目标优化的最佳参数?

In multi-objective optimization, you often end up with more than one best trial, but rather a set of trials.在多目标优化中,您通常会得到不止一个最佳试验,而是一组试验。 This set if often referred to as the Pareto front.这个集合如果经常被称为帕累托前沿。 You can get this Pareto front, or the list of trials, via study.best_trials , then look at the parameters from each individual trial ie study.best_trials[some_index].params .您可以通过study.best_trials获取此 Pareto 前沿或试验列表,然后查看每个单独试验的参数,即study.best_trials[some_index].params

For instance, given your directions of minimizing f1 and maximizing f2 , you might end up with a trial that has a small value for f1 (good) but at the same time small value for f2 (bad) while another trial might have a large value for both f1 (bad) and f2 (good).例如,给定最小化f1和最大化f2的方向,您最终可能会得到一个f1值较小(好)但同时f2值较小(坏)的试验,而另一个试验可能具有较大的值对于f1 (坏)和f2 (好)。 Both of these trials could be returned from study.best_trials .这两个试验都可以从study.best_trials中返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pyomo:多目标优化 - Pyomo: Multi-objective optimization pyomo 中的多目标优化 - Multi-objective optimization in pyomo 使用 Platypus (Python) 进行整数、多目标优化 - Integer, multi-objective optimization with Platypus (Python) 如何使用神经网络进行多目标优化? - How to do multi-objective optimization using neural networks? 使用 DEAP 的遗传算法多目标优化 - Multi-objective optimization with Genetic Algorithm using DEAP 使用DEAP的具有多个变量的多目标优化 - python - Multi-Objective optimization with multiple variables using DEAP 在 Python 中使用 Gekko,对于多目标优化问题,是否所有目标函数都必须具有相同的单位? - Using Gekko in Python, for a multi-objective optimization problem, do all objective functions have to be of the same unit? 使用带有 NSGA2 的 python DEAP 库解决多目标优化问题 - Solving a multi-objective optimization problem using python DEAP library with NSGA2 使用逐次二次规划 (SQP) 进行多目标优化的 Python 包 - Python packages for multi-objective optimization using Successive Quadratic Programming (SQP) 从非线性寻根到多目标优化 - Going from non-linear root-finding to multi-objective optimization
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM