Main Content

hyperparameters

Variable descriptions for optimizing a fit function

Description

VariableDescriptions = hyperparameters(FitFcnName,predictors,response) returns the default variables for the given fit function. These are the variables that apply when you set the OptimizeHyperparameters name-value argument to "auto".

example

VariableDescriptions = hyperparameters(FitFcnName,predictors,response,LearnerType) returns the variables for an ensemble fit with specified learner type. This syntax applies when FitFcnName is "fitcecoc", "fitcensemble", or "fitrensemble".

example

Examples

collapse all

Obtain the default hyperparameters for the fitcsvm classifier.

Load the ionosphere data.

load ionosphere

Obtain the hyperparameters.

VariableDescriptions = hyperparameters('fitcsvm',X,Y);

Examine all the hyperparameters.

for ii = 1:length(VariableDescriptions)
    disp(ii),disp(VariableDescriptions(ii))
end
     1

  optimizableVariable with properties:

         Name: 'BoxConstraint'
        Range: [1.0000e-03 1000]
         Type: 'real'
    Transform: 'log'
     Optimize: 1

     2

  optimizableVariable with properties:

         Name: 'KernelScale'
        Range: [1.0000e-03 1000]
         Type: 'real'
    Transform: 'log'
     Optimize: 1

     3

  optimizableVariable with properties:

         Name: 'KernelFunction'
        Range: {'gaussian'  'linear'  'polynomial'}
         Type: 'categorical'
    Transform: 'none'
     Optimize: 0

     4

  optimizableVariable with properties:

         Name: 'PolynomialOrder'
        Range: [2 4]
         Type: 'integer'
    Transform: 'none'
     Optimize: 0

     5

  optimizableVariable with properties:

         Name: 'Standardize'
        Range: {'true'  'false'}
         Type: 'categorical'
    Transform: 'none'
     Optimize: 1

Change the PolynomialOrder hyperparameter to have a wider range and to be used in an optimization.

VariableDescriptions(4).Range = [2,5];
VariableDescriptions(4).Optimize = true;
disp(VariableDescriptions(4))
  optimizableVariable with properties:

         Name: 'PolynomialOrder'
        Range: [2 5]
         Type: 'integer'
    Transform: 'none'
     Optimize: 1

Obtain the default hyperparameters for the fitrensemble ensemble regression function.

Load the carsmall data.

load carsmall

Use Horsepower and Weight as predictor variables, and MPG as the response variable.

X = [Horsepower Weight];
Y = MPG;

Obtain the default hyperparameters for a Tree learner.

VariableDescriptions = hyperparameters('fitrensemble',X,Y,'Tree');

Examine all the hyperparameters.

for ii = 1:length(VariableDescriptions)
    disp(ii),disp(VariableDescriptions(ii))
end
     1

  optimizableVariable with properties:

         Name: 'Method'
        Range: {'Bag'  'LSBoost'}
         Type: 'categorical'
    Transform: 'none'
     Optimize: 1

     2

  optimizableVariable with properties:

         Name: 'NumLearningCycles'
        Range: [10 500]
         Type: 'integer'
    Transform: 'log'
     Optimize: 1

     3

  optimizableVariable with properties:

         Name: 'LearnRate'
        Range: [1.0000e-03 1]
         Type: 'real'
    Transform: 'log'
     Optimize: 1

     4

  optimizableVariable with properties:

         Name: 'MinLeafSize'
        Range: [1 50]
         Type: 'integer'
    Transform: 'log'
     Optimize: 1

     5

  optimizableVariable with properties:

         Name: 'MaxNumSplits'
        Range: [1 99]
         Type: 'integer'
    Transform: 'log'
     Optimize: 0

     6

  optimizableVariable with properties:

         Name: 'NumVariablesToSample'
        Range: [1 2]
         Type: 'integer'
    Transform: 'none'
     Optimize: 0

Change the MaxNumSplits hyperparameter to have a wider range and to be used in an optimization.

VariableDescriptions(5).Range = [1,200];
VariableDescriptions(5).Optimize = true;
disp(VariableDescriptions(5))
  optimizableVariable with properties:

         Name: 'MaxNumSplits'
        Range: [1 200]
         Type: 'integer'
    Transform: 'log'
     Optimize: 1

Input Arguments

collapse all

Name of the fitting function, specified as one of the listed classification or regression fit function names.

If FitFcnName is "fitcecoc", "fitcensemble", or "fitrensemble", then you also need to specify the learner type in the LearnerType argument.

Example: "fitctree"

Predictor data, specified as a matrix with D predictor columns or a table with D predictor columns, where D is the number of predictors.

Example: X

Data Types: double | logical | char | string | table | cell | categorical | datetime

Class labels or numeric response, specified as a grouping variable (see Grouping Variables) or a scalar.

Example: Y

Data Types: single | double | logical | char | string | cell

Learner type for an ensemble fit, specified as "discriminant", "ensemble", "kernel", "knn", "linear", "svm", "tree", or a template of one of these learners. Use this argument when FitFcnName is "fitcecoc", "fitcensemble", or "fitrensemble".

For "fitcensemble", you can specify only "discriminant", "knn", "tree", or an associated template.

For "fitrensemble", you can specify only "tree" or its associated template.

Example: "tree"

Output Arguments

collapse all

Variable descriptions, returned as a vector of optimizableVariable objects. The variables have their default parameters set, such as range and variable type. All eligible variables exist in the descriptions, but the variables unused in the "auto" setting have their Optimize property set to false. You can update the variables by using dot notation, as shown in Examples.

Version History

Introduced in R2016b

expand all