plot
Plot Bayesian optimization results
Description
Examples
Plot After Optimization
This example shows how to plot the error model and the best objective trace after the optimization has finished. The objective function for this example throws an error for points with norm larger than 2.
function f = makeanerror(x)
f = x.x1 - x.x2 - sqrt(4-x.x1^2-x.x2^2);
fun = @makeanerror;
Create the variables for optimization.
var1 = optimizableVariable('x1',[-5,5]); var2 = optimizableVariable('x2',[-5,5]); vars = [var1,var2];
Run the optimization without any plots. For reproducibility, set the random seed and use the 'expected-improvement-plus' acquisition function. Optimize for 60 iterations so the error model becomes well-trained.
rng default results = bayesopt(fun,vars,'MaxObjectiveEvaluations',60,... 'AcquisitionFunctionName','expected-improvement-plus',... 'PlotFcn',[],'Verbose',0);
Plot the error model and the best objective trace.
plot(results,@plotConstraintModels,@plotMinObjective)
Input Arguments
results
— Bayesian optimization results
BayesianOptimization
object
Bayesian optimization results, specified as a BayesianOptimization
object.
plotFcn
— Plot function
function handle
Plot function, specified as a function handle.
There are several built-in plot functions:
Model Plots — Apply When D ≤ 2 | Description |
---|---|
@plotAcquisitionFunction | Plot the acquisition function surface. |
@plotConstraintModels | Plot each constraint model surface. Negative values indicate feasible points. Also plot a P(feasible) surface. Also plot the error model, if
it exists, which ranges from Plotted error = 2*Probability(error) – 1. |
@plotObjectiveEvaluationTimeModel | Plot the objective function evaluation time model surface. |
@plotObjectiveModel | Plot the |
Trace Plots — Apply to All D | Description |
---|---|
@plotObjective | Plot each observed function value versus the number of function evaluations. |
@plotObjectiveEvaluationTime | Plot each observed function evaluation run time versus the number of function evaluations. |
@plotMinObjective | Plot the minimum observed and estimated function values versus the number of function evaluations. |
@plotElapsedTime | Plot three curves: the total elapsed time of the optimization, the total function evaluation time, and the total modeling and point selection time, all versus the number of function evaluations. |
You can include a handle to your own plot functions. For details, see Bayesian Optimization Plot Functions.
Example: @plotObjective
Data Types: function_handle
Alternative Functionality
You can specify plot functions in the bayesopt
PlotFcn
name-value pair. This allows you to monitor the progress of
the optimization.
Version History
Introduced in R2016b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)