best point in a bayesian optimization according to a criterion -凯发k8网页登录
best point in a bayesian optimization according to a criterion
syntax
description
modifies the best point using name-value pairs.x
= bestpoint(results
,name,value
)
[
,
for any previous syntax, also returns the value of the criterion at
x
,criterionvalue
]
= bestpoint(___)x
.
[
also returns the iteration number at which the best point was returned. applies when
the x
,criterionvalue
,iteration
]
= bestpoint(___)criterion
name-value pair is
'min-observed'
, 'min-visited-mean'
, or the
default 'min-visited-upper-confidence-interval'
.
examples
best point of an optimized knn classifier
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');
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
results
— bayesian optimization results
bayesianoptimization
object
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')
criterion
— best point criterion
'min-visited-upper-confidence-interval'
(default) | 'min-observed'
| 'min-mean'
| 'min-upper-confidence-interval'
| 'min-visited-mean'
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 name | meaning |
---|---|
'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'
alpha
— probability that modeled objective mean exceeds criterionvalue
0.01
(default) | scalar between 0
and 1
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
x
— best point
1
-by-d
table
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
.
criterionvalue
— value of criterion
real scalar
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 name | meaning |
---|---|
'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
— iteration number at which best point was observed
positive integer
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
see also
打开示例
您曾对此示例进行过修改。是否要打开带有您的编辑的示例?
matlab 命令
您点击的链接对应于以下 matlab 命令:
请在 matlab 命令行窗口中直接输入以执行命令。web 浏览器不支持 matlab 命令。
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
- (español)
- (english)
- (english)
europe
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
asia pacific
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)