optimizableVariable - Variable description for bayesopt or other

        optimizers - MATLAB ([original](https://in.mathworks.com/help/stats/optimizablevariable.html)) ([raw](?raw))

Variable description for bayesopt or other optimizers

Description

Create variables for optimizers.

Creation

Syntax

Description

variable = optimizableVariable(`Name`,`Range`) creates a variable with the specified name and range of values.

example

variable = optimizableVariable(`Name`,`Range`,Name,Value) sets properties using name-value arguments. For example, optimizableVariable('xvar',[1 1000],'Type','integer') creates an integer variable from 1 to 1000. You can specify multiple name-value arguments. Enclose each property name in quotes.

example

Properties

expand all

Variable name, specified as a character vector or string scalar. The name must be unique, meaning different from those of other variables in the optimization.

Note

Example: 'X1'

Data Types: char | string

Variable range, specified as a 2-element finite increasing real vector, or as a string array or cell array of category names:

Example: [-10,1]

Example: {'red','blue','black'}

Data Types: double | string | cell

Variable type, specified as 'real' (real variable),'integer' (integer variable), or'categorical' (categorical variable).

Note

The MATLAB data type of both 'real' and'integer' variables is the standard double-precision floating point number. The data type of'categorical' variables is categorical. So, for example, to read a value of a categorical variable named'colorv' in a table of variables namedx, use the commandchar(x.colorv). For an example, see the objective function in Custom Output Functions.

Example: 'Type','categorical'

Transform applied to the variable, specified as 'none' (no transform) or 'log' (logarithmic transform).

For 'log', the variable must be a positive real variable ('Type','real') or a nonnegative integer variable ('Type','integer'). The software searches and models the variable on a log scale.

Example: 'Transform','log'

Indication to use variable in optimization, specified astrue (use the variable) or false (do not use the variable).

Example: 'Optimize',false

Data Types: logical

Note

You can use dot notation to change the following properties after creation.

You can use this flexibility, for example, to tweak an optimization that you want to continue. Update the range or transform using dot notation and then callresume.

Object Functions

bayesopt Select optimal machine learning hyperparameters using Bayesian optimization

Examples

collapse all

Real variable from 0 to 1:

var1 = optimizableVariable('xvar',[0 1])

var1 = optimizableVariable with properties:

     Name: 'xvar'
    Range: [0 1]
     Type: 'real'
Transform: 'none'
 Optimize: 1

Integer variable from 0 to 1000 on a log scale:

var2 = optimizableVariable('ivar',[0 1000],'Type','integer','Transform','log')

var2 = optimizableVariable with properties:

     Name: 'ivar'
    Range: [0 1000]
     Type: 'integer'
Transform: 'log'
 Optimize: 1

Categorical variable of rainbow colors:

var3 = optimizableVariable('rvar',{'r' 'o' 'y' 'g' 'b' 'i' 'v'},'Type','categorical')

var3 = optimizableVariable with properties:

     Name: 'rvar'
    Range: {'r'  'o'  'y'  'g'  'b'  'i'  'v'}
     Type: 'categorical'
Transform: 'none'
 Optimize: 1

Version History

Introduced in R2016b