main content

best point in a bayesian optimization according to a criterion -凯发k8网页登录

best point in a bayesian optimization according to a criterion

description

example

x = bestpoint(results) returns the best feasible point in the bayesian model results according to the default criterion 'min-visited-upper-confidence-interval'.

example

x = bestpoint(results,name,value) modifies the best point using name-value pairs.

example

[x,criterionvalue] = bestpoint(___), for any previous syntax, also returns the value of the criterion at x.

example

[x,criterionvalue,iteration] = bestpoint(___) also returns the iteration number at which the best point was returned. applies when the criterion name-value pair is 'min-observed', 'min-visited-mean', or the default 'min-visited-upper-confidence-interval'.

examples

this example shows how to obtain the best point of an optimized classifier.

optimize a knn classifier for the ionosphere data, meaning find parameters that minimize the cross-validation loss. minimize over nearest-neighborhood sizes from 1 to 30, and over the distance functions 'chebychev', 'euclidean', and 'minkowski'.

for reproducibility, set the random seed, and set the acquisitionfunctionname option to 'expected-improvement-plus'.

load ionosphere
rng(11)
num = optimizablevariable('n',[1,30],'type','integer');
dst = optimizablevariable('dst',{'chebychev','euclidean','minkowski'},'type','categorical');
c = cvpartition(351,'kfold',5);
fun = @(x)kfoldloss(fitcknn(x,y,'cvpartition',c,'numneighbors',x.n,...
    'distance',char(x.dst),'nsmethod','exhaustive'));
results = bayesopt(fun,[num,dst],'verbose',0,...
    'acquisitionfunctionname','expected-improvement-plus');

figure contains an axes object. the axes object with title objective function model, xlabel n, ylabel dst contains 5 objects of type line, surface, contour. one or more of the lines displays its values using only markers these objects represent observed points, model mean, next point, model minimum feasible.

figure contains an axes object. the axes object with title min objective vs. number of function evaluations, xlabel function evaluations, ylabel min objective contains 2 objects of type line. these objects represent min observed objective, estimated min objective.

obtain the best point according to the default 'min-visited-upper-confidence-interval' criterion.

x = bestpoint(results)
x=1×2 table
    n       dst   
    _    _________
    1    chebychev

the lowest estimated cross-validation loss occurs for one nearest neighbor and 'chebychev' distance.

careful examination of the objective function model plot shows a point with two nearest neighbors and 'chebychev' distance that has a lower objective function value. find this point using a different criterion.

x = bestpoint(results,'criterion','min-observed')
x=1×2 table
    n       dst   
    _    _________
    2    chebychev

also find the minimum observed objective function value, and the iteration number at which it was observed.

[x,criterionvalue,iteration] = bestpoint(results,'criterion','min-observed')
x=1×2 table
    n       dst   
    _    _________
    2    chebychev
criterionvalue = 0.1054
iteration = 21

input arguments

bayesian optimization results, specified as a bayesianoptimization object.

name-value arguments

specify optional pairs of arguments as name1=value1,...,namen=valuen, where name is the argument name and value is the corresponding value. name-value arguments must appear after other arguments, but the order of the pairs does not matter.

before r2021a, use commas to separate each name and value, and enclose name in quotes.

example: x = bestpoint(results,'criterion','min-observed')

best point criterion, specified as the comma-separated pair consisting of 'criterion' and a criterion name. the names are case-insensitive, do not require - characters, and require only enough characters to make the name uniquely distinguishable.

criterion namemeaning
'min-observed'x is the feasible point with minimum observed objective.
'min-mean'x is the feasible point where the objective model mean is minimized.
'min-upper-confidence-interval'x is the feasible point minimizing an upper confidence interval of the objective model. see alpha.
'min-visited-mean'x is the feasible point where the objective model mean is minimized among the visited points.
'min-visited-upper-confidence-interval'x is the feasible point minimizing an upper confidence interval of the objective model among the visited points. see alpha.

example: 'criterion','min-visited-mean'

probability that the modeled objective mean exceeds criterionvalue, specified as the comma-separated pair consisting of 'alpha' and a scalar between 0 and 1. alpha relates to the 'min-upper-confidence-interval' and 'min-visited-upper-confidence-interval' criterion values. the definition for the upper confidence interval is the value y where

p(meanq(fun(x)) > y) = alpha,

where fun is the objective function, and the mean is calculated with respect to the posterior distribution q.

example: 'alpha',0.05

data types: double

output arguments

best point, returned as a 1-by-d table, where d is the number of variables. the meaning of “best” is with respect to criterion.

value of criterion, returned as a real scalar. the value depends on the setting of the criterion name-value pair, which has a default value of 'min-visited-upper-confidence-interval'.

criterion namemeaning
'min-observed'minimum observed objective.
'min-mean'minimum of model mean.
'min-upper-confidence-interval'value y satisfying the equation p(meanq(fun(x)) > y) = alpha.
'min-visited-mean'minimum of observed model mean.
'min-visited-upper-confidence-interval'value y satisfying the equation p(meanq(fun(x)) > y) = alpha among observed points.

iteration number at which best point was observed, returned as a positive integer. the best point is defined by criterionvalue.

version history

introduced in r2016b

网站地图