Main Content

fitrauto

Automatically select regression model with optimized hyperparameters

Description

Given predictor and response data, fitrauto automatically tries a selection of regression model types with different hyperparameter values. The function uses Bayesian optimization to select models and their hyperparameter values, and computes the following for each model: log(1 + valLoss), where valLoss is the cross-validation mean squared error (MSE). After the optimization is complete, fitrauto returns the model, trained on the entire data set, that is expected to best predict the responses for new data. You can use the predict and loss object functions of the returned model to predict on new data and compute the test set MSE, respectively.

Use fitrauto when you are uncertain which model types best suit your data. For information on alternative methods for tuning hyperparameters of regression models, see Alternative Functionality.

example

Mdl = fitrauto(Tbl,ResponseVarName) returns a regression model Mdl with tuned hyperparameters. The table Tbl contains the predictor variables and the response variable, where ResponseVarName is the name of the response variable.

Mdl = fitrauto(Tbl,formula) uses formula to specify the response variable and the predictor variables to consider among the variables in Tbl.

Mdl = fitrauto(Tbl,Y) uses the predictor variables in table Tbl and the response values in vector Y.

example

Mdl = fitrauto(X,Y) uses the predictor variables in matrix X and the response values in vector Y.

example

Mdl = fitrauto(___,Name,Value) specifies options using one or more name-value pair arguments in addition to any of the input argument combinations in previous syntaxes. For example, use the HyperparameterOptimizationOptions name-value pair argument to specify how the Bayesian optimization is performed.

[Mdl,OptimizationResults] = fitrauto(___) additionally returns OptimizationResults, a BayesianOptimization object containing the results of the model selection and hyperparameter tuning process.

Examples

collapse all

Use fitrauto to automatically select a regression model with optimized hyperparameters, given predictor and response data stored in a table.

Load Data

Load the carbig data set, which contains measurements of cars made in the 1970s and early 1980s.

load carbig

Create a table containing the predictor variables Acceleration, Displacement, and so on, as well as the response variable MPG.

cars = table(Acceleration,Displacement,Horsepower, ...
    Model_Year,Origin,Weight,MPG);

Partition Data

Partition the data into training and test sets. Use approximately 80% of the observations for the model selection and hyperparameter tuning process, and 20% of the observations to test the performance of the final model returned by fitrauto. Use cvpartition to partition the data.

rng('default') % For reproducibility of the data partition
c = cvpartition(length(MPG),'Holdout',0.2);
trainingIdx = training(c); % Training set indices
carsTrain = cars(trainingIdx,:);
testIdx = test(c); % Test set indices
carsTest = cars(testIdx,:);

Run fitrauto

Pass the training data to fitrauto. By default, fitrauto determines appropriate model types to try, uses Bayesian optimization to find good hyperparameter values, and returns a trained model Mdl with the best expected performance. Additionally, fitrauto provides a plot of the optimization and an iterative display of the optimization results. For more information on how to interpret these results, see Verbose Display.

Expect this process to take some time. To speed up the optimization process, consider running the optimization in parallel, if you have a Parallel Computing Toolbox™ license. To do so, pass 'HyperparameterOptimizationOptions',struct('UseParallel',true) to fitrauto as a name-value pair argument.

Mdl = fitrauto(carsTrain,'MPG');
Learner types to explore: ensemble, svm, tree
Total iterations (MaxObjectiveEvaluations): 90
Total time (MaxTime): Inf

|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|    1 | Best   |           2.5161 |            1.4197 |           2.5161 |           2.5161 |         tree | MinLeafSize:              6 |
|    2 | Accept |           4.1439 |           0.68799 |           2.5161 |           2.5161 |          svm | BoxConstraint:       336.91 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0018275 |
|      |        |                  |                   |                  |                  |              | Epsilon:             0.1074 |
|    3 | Accept |            4.144 |            5.5942 |           2.5161 |           2.5161 |     ensemble | Method:                 Bag |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      257 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:            156 |
|    4 | Accept |           3.1976 |            20.387 |           2.5161 |           2.5161 |          svm | BoxConstraint:     0.033502 |
|      |        |                  |                   |                  |                  |              | KernelScale:         153.38 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.093672 |
|    5 | Best   |           2.5041 |           0.13106 |           2.5041 |           2.5101 |         tree | MinLeafSize:              5 |
|    6 | Best   |           2.2096 |            7.0177 |           2.2096 |           2.5101 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      287 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:              1 |
|    7 | Accept |           2.7182 |          0.085053 |           2.2096 |           2.5057 |         tree | MinLeafSize:              1 |
|    8 | Accept |           17.207 |            23.312 |           2.2096 |           2.5057 |          svm | BoxConstraint:       196.73 |
|      |        |                  |                   |                  |                  |              | KernelScale:         34.789 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.03716 |
|    9 | Accept |           4.1439 |          0.057226 |           2.2096 |           2.5057 |          svm | BoxConstraint:       346.92 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.032493 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.23974 |
|   10 | Best   |           2.1916 |            6.4368 |           2.1916 |           2.5057 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      278 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:             13 |
|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|   11 | Accept |           2.8889 |            0.1325 |           2.1916 |           2.5057 |          svm | BoxConstraint:     0.033068 |
|      |        |                  |                   |                  |                  |              | KernelScale:         585.38 |
|      |        |                  |                   |                  |                  |              | Epsilon:             4.6993 |
|   12 | Accept |           4.1439 |           0.06362 |           2.1916 |           2.5057 |          svm | BoxConstraint:       48.997 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0045904 |
|      |        |                  |                   |                  |                  |              | Epsilon:             18.085 |
|   13 | Accept |           4.1439 |          0.048941 |           2.1916 |           2.5057 |          svm | BoxConstraint:       985.69 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0010988 |
|      |        |                  |                   |                  |                  |              | Epsilon:             449.48 |
|   14 | Accept |           2.2844 |            6.7538 |           2.1916 |           2.4806 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      287 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:             63 |
|   15 | Accept |           4.1439 |          0.054943 |           2.1916 |           2.4806 |          svm | BoxConstraint:     0.010812 |
|      |        |                  |                   |                  |                  |              | KernelScale:         1.2015 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.034209 |
|   16 | Accept |           4.1439 |          0.055455 |           2.1916 |           2.4806 |          svm | BoxConstraint:    0.0021787 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.018209 |
|      |        |                  |                   |                  |                  |              | Epsilon:             443.71 |
|   17 | Accept |           2.2075 |            6.7931 |           2.1916 |           2.1942 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      283 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:             17 |
|   18 | Accept |           2.6056 |           0.08425 |           2.1916 |           2.1942 |         tree | MinLeafSize:              2 |
|   19 | Accept |           2.6056 |          0.087135 |           2.1916 |           2.1942 |         tree | MinLeafSize:              2 |
|   20 | Accept |           2.7182 |          0.062848 |           2.1916 |           2.1942 |         tree | MinLeafSize:              1 |
|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|   21 | Accept |           2.2402 |            6.8909 |           2.1916 |           2.2011 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      282 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|   22 | Accept |           2.6056 |          0.059067 |           2.1916 |           2.2011 |         tree | MinLeafSize:              2 |
|   23 | Accept |           2.3016 |            4.8177 |           2.1916 |           2.1911 |     ensemble | Method:                 Bag |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      202 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:              9 |
|   24 | Accept |           4.1439 |           0.05258 |           2.1916 |           2.1911 |          svm | BoxConstraint:       37.028 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.033731 |
|      |        |                  |                   |                  |                  |              | Epsilon:             0.2457 |
|   25 | Accept |            3.352 |          0.043391 |           2.1916 |           2.1911 |         tree | MinLeafSize:            122 |
|   26 | Accept |           4.1439 |          0.062799 |           2.1916 |           2.1911 |          svm | BoxConstraint:      0.01045 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0024261 |
|      |        |                  |                   |                  |                  |              | Epsilon:             12.355 |
|   27 | Accept |           2.3188 |            5.1633 |           2.1916 |           2.1884 |     ensemble | Method:                 Bag |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      212 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|   28 | Accept |           2.4271 |            5.8444 |           2.1916 |           2.1908 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      247 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:             83 |
|   29 | Accept |           2.6056 |           0.05574 |           2.1916 |           2.1908 |         tree | MinLeafSize:              2 |
|   30 | Accept |           4.1439 |          0.054692 |           2.1916 |           2.1908 |          svm | BoxConstraint:       2.1296 |
|      |        |                  |                   |                  |                  |              | KernelScale:         3.2623 |
|      |        |                  |                   |                  |                  |              | Epsilon:             599.62 |
|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|   31 | Accept |           2.5241 |          0.051793 |           2.1916 |           2.1908 |         tree | MinLeafSize:              8 |
|   32 | Accept |           2.6443 |            5.2572 |           2.1916 |           2.1969 |     ensemble | Method:                 Bag |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      229 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:             52 |
|   33 | Accept |           2.2537 |             5.641 |           2.1916 |           2.1931 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      235 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:             26 |
|   34 | Accept |           2.5448 |          0.053688 |           2.1916 |           2.1931 |         tree | MinLeafSize:             19 |
|   35 | Accept |           2.4438 |          0.045817 |           2.1916 |           2.1931 |         tree | MinLeafSize:             13 |
|   36 | Accept |           2.7182 |          0.062646 |           2.1916 |           2.1931 |         tree | MinLeafSize:              1 |
|   37 | Accept |           2.4749 |          0.048072 |           2.1916 |           2.1931 |         tree | MinLeafSize:              9 |
|   38 | Accept |           13.083 |            31.488 |           2.1916 |           2.1931 |          svm | BoxConstraint:       5.2568 |
|      |        |                  |                   |                  |                  |              | KernelScale:         10.811 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.073361 |
|   39 | Accept |           2.2446 |            5.2866 |           2.1916 |           2.1952 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      214 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:              4 |
|   40 | Accept |           3.0919 |          0.040315 |           2.1916 |           2.1952 |         tree | MinLeafSize:             62 |
|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|   41 | Accept |           2.6335 |            6.4626 |           2.1916 |           2.1926 |     ensemble | Method:                 Bag |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      280 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:             45 |
|   42 | Accept |           4.1439 |          0.048186 |           2.1916 |           2.1926 |          svm | BoxConstraint:     0.093799 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0053728 |
|      |        |                  |                   |                  |                  |              | Epsilon:             17.332 |
|   43 | Accept |           2.8766 |          0.075435 |           2.1916 |           2.1926 |          svm | BoxConstraint:      0.20553 |
|      |        |                  |                   |                  |                  |              | KernelScale:         880.29 |
|      |        |                  |                   |                  |                  |              | Epsilon:             4.5637 |
|   44 | Accept |           2.2402 |            5.6507 |           2.1916 |           2.1944 |     ensemble | Method:             LSBoost |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      233 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|   45 | Accept |           2.4576 |            5.4632 |           2.1916 |           2.1928 |     ensemble | Method:                 Bag |
|      |        |                  |                   |                  |                  |              | NumLearningCycles:      232 |
|      |        |                  |                   |                  |                  |              | MinLeafSize:             27 |
|   46 | Accept |            3.003 |          0.069043 |           2.1916 |           2.1928 |          svm | BoxConstraint:    0.0010563 |
|      |        |                  |                   |                  |                  |              | KernelScale:         527.21 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.010074 |
|   47 | Accept |           4.1439 |           0.05544 |           2.1916 |           2.1928 |          svm | BoxConstraint:       1.6452 |
|      |        |                  |                   |                  |                  |              | KernelScale:         880.96 |
|      |        |                  |                   |                  |                  |              | Epsilon:             656.96 |
|   48 | Accept |           11.118 |            31.888 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.001029 |
|      |        |                  |                   |                  |                  |              | KernelScale:         25.502 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.22713 |
|   49 | Accept |           3.0019 |          0.064077 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.012054 |
|      |        |                  |                   |                  |                  |              | KernelScale:         976.62 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.013474 |
|   50 | Accept |           4.1439 |          0.069826 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.045381 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.030659 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.021441 |
|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|   51 | Accept |           4.1439 |          0.050005 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.090287 |
|      |        |                  |                   |                  |                  |              | KernelScale:         69.941 |
|      |        |                  |                   |                  |                  |              | Epsilon:             125.56 |
|   52 | Accept |           4.1439 |          0.054745 |           2.1916 |           2.1928 |          svm | BoxConstraint:       285.67 |
|      |        |                  |                   |                  |                  |              | KernelScale:        0.14938 |
|      |        |                  |                   |                  |                  |              | Epsilon:             764.19 |
|   53 | Accept |           2.8779 |           0.11876 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.064002 |
|      |        |                  |                   |                  |                  |              | KernelScale:         969.91 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.46473 |
|   54 | Accept |           12.921 |            18.315 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.019899 |
|      |        |                  |                   |                  |                  |              | KernelScale:         50.528 |
|      |        |                  |                   |                  |                  |              | Epsilon:          0.0091628 |
|   55 | Accept |           2.9117 |          0.076534 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.028436 |
|      |        |                  |                   |                  |                  |              | KernelScale:         919.02 |
|      |        |                  |                   |                  |                  |              | Epsilon:             1.2395 |
|   56 | Accept |           3.0276 |          0.064801 |           2.1916 |           2.1928 |          svm | BoxConstraint:    0.0073097 |
|      |        |                  |                   |                  |                  |              | KernelScale:         898.72 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.088715 |
|   57 | Accept |           7.1555 |             20.87 |           2.1916 |           2.1928 |          svm | BoxConstraint:      0.07913 |
|      |        |                  |                   |                  |                  |              | KernelScale:         100.43 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.78937 |
|   58 | Accept |           2.9075 |          0.077548 |           2.1916 |           2.1928 |          svm | BoxConstraint:      0.03913 |
|      |        |                  |                   |                  |                  |              | KernelScale:         956.28 |
|      |        |                  |                   |                  |                  |              | Epsilon:             1.1315 |
|   59 | Accept |           2.9168 |          0.068648 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.033583 |
|      |        |                  |                   |                  |                  |              | KernelScale:         973.75 |
|      |        |                  |                   |                  |                  |              | Epsilon:             2.1404 |
|   60 | Accept |           4.1439 |          0.053635 |           2.1916 |           2.1928 |          svm | BoxConstraint:       0.1278 |
|      |        |                  |                   |                  |                  |              | KernelScale:         899.12 |
|      |        |                  |                   |                  |                  |              | Epsilon:             36.993 |
|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|   61 | Accept |           2.9456 |          0.073895 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.022705 |
|      |        |                  |                   |                  |                  |              | KernelScale:         995.04 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.21977 |
|   62 | Accept |           4.1439 |           0.04979 |           2.1916 |           2.1928 |          svm | BoxConstraint:    0.0047868 |
|      |        |                  |                   |                  |                  |              | KernelScale:         0.1518 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.042601 |
|   63 | Accept |           2.9095 |          0.065115 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.033402 |
|      |        |                  |                   |                  |                  |              | KernelScale:         989.34 |
|      |        |                  |                   |                  |                  |              | Epsilon:             0.3073 |
|   64 | Accept |           4.1439 |          0.065248 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.056303 |
|      |        |                  |                   |                  |                  |              | KernelScale:        0.29988 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.10313 |
|   65 | Accept |           4.1439 |          0.050181 |           2.1916 |           2.1928 |          svm | BoxConstraint:    0.0040769 |
|      |        |                  |                   |                  |                  |              | KernelScale:         238.59 |
|      |        |                  |                   |                  |                  |              | Epsilon:             32.573 |
|   66 | Accept |           2.6802 |            2.1221 |           2.1916 |           2.1928 |          svm | BoxConstraint:      0.11739 |
|      |        |                  |                   |                  |                  |              | KernelScale:         555.21 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.048956 |
|   67 | Accept |           4.1439 |          0.055315 |           2.1916 |           2.1928 |          svm | BoxConstraint:       772.51 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.016887 |
|      |        |                  |                   |                  |                  |              | Epsilon:             72.705 |
|   68 | Accept |           4.1439 |          0.063152 |           2.1916 |           2.1928 |          svm | BoxConstraint:       63.153 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0080065 |
|      |        |                  |                   |                  |                  |              | Epsilon:             481.39 |
|   69 | Accept |           4.1439 |          0.054083 |           2.1916 |           2.1928 |          svm | BoxConstraint:        4.117 |
|      |        |                  |                   |                  |                  |              | KernelScale:         73.496 |
|      |        |                  |                   |                  |                  |              | Epsilon:             121.74 |
|   70 | Accept |           4.1439 |           0.05377 |           2.1916 |           2.1928 |          svm | BoxConstraint:       30.398 |
|      |        |                  |                   |                  |                  |              | KernelScale:        0.12159 |
|      |        |                  |                   |                  |                  |              | Epsilon:              64.06 |
|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|   71 | Accept |           4.1439 |          0.053553 |           2.1916 |           2.1928 |          svm | BoxConstraint:       3.9304 |
|      |        |                  |                   |                  |                  |              | KernelScale:         871.88 |
|      |        |                  |                   |                  |                  |              | Epsilon:               23.7 |
|   72 | Accept |           4.1439 |          0.050525 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.031734 |
|      |        |                  |                   |                  |                  |              | KernelScale:        0.28247 |
|      |        |                  |                   |                  |                  |              | Epsilon:          0.0097239 |
|   73 | Accept |           4.1439 |          0.068567 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.021528 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.001858 |
|      |        |                  |                   |                  |                  |              | Epsilon:             283.71 |
|   74 | Accept |           4.1439 |          0.055336 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.024702 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.055101 |
|      |        |                  |                   |                  |                  |              | Epsilon:             84.374 |
|   75 | Accept |           2.8707 |          0.095257 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.070484 |
|      |        |                  |                   |                  |                  |              | KernelScale:         928.16 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.11681 |
|   76 | Accept |           4.1439 |          0.059476 |           2.1916 |           2.1928 |          svm | BoxConstraint:       636.13 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0020368 |
|      |        |                  |                   |                  |                  |              | Epsilon:             2.0625 |
|   77 | Accept |           2.8682 |           0.10867 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.059284 |
|      |        |                  |                   |                  |                  |              | KernelScale:         888.99 |
|      |        |                  |                   |                  |                  |              | Epsilon:             0.1389 |
|   78 | Accept |           2.7111 |           0.59286 |           2.1916 |           2.1928 |          svm | BoxConstraint:       2.4776 |
|      |        |                  |                   |                  |                  |              | KernelScale:          998.2 |
|      |        |                  |                   |                  |                  |              | Epsilon:             1.5291 |
|   79 | Accept |           2.7625 |           0.45668 |           2.1916 |           2.1928 |          svm | BoxConstraint:      0.91288 |
|      |        |                  |                   |                  |                  |              | KernelScale:         996.35 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.16968 |
|   80 | Accept |           3.2211 |          0.058812 |           2.1916 |           2.1928 |          svm | BoxConstraint:    0.0011498 |
|      |        |                  |                   |                  |                  |              | KernelScale:         989.38 |
|      |        |                  |                   |                  |                  |              | Epsilon:          0.0091368 |
|=========================================================================================================================================|
| Iter | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|=========================================================================================================================================|
|   81 | Accept |           4.1439 |           0.05754 |           2.1916 |           2.1928 |          svm | BoxConstraint:       26.543 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0016089 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.68659 |
|   82 | Accept |           4.1439 |          0.055356 |           2.1916 |           2.1928 |          svm | BoxConstraint:       129.11 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.044504 |
|      |        |                  |                   |                  |                  |              | Epsilon:             3.7911 |
|   83 | Accept |           2.7643 |           0.51644 |           2.1916 |           2.1928 |          svm | BoxConstraint:      0.82852 |
|      |        |                  |                   |                  |                  |              | KernelScale:         990.02 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.013169 |
|   84 | Accept |           4.1439 |           0.05615 |           2.1916 |           2.1928 |          svm | BoxConstraint:       53.003 |
|      |        |                  |                   |                  |                  |              | KernelScale:         3.9941 |
|      |        |                  |                   |                  |                  |              | Epsilon:             318.78 |
|   85 | Accept |           4.1439 |          0.054645 |           2.1916 |           2.1928 |          svm | BoxConstraint:       10.848 |
|      |        |                  |                   |                  |                  |              | KernelScale:         0.2138 |
|      |        |                  |                   |                  |                  |              | Epsilon:             876.72 |
|   86 | Accept |           2.8797 |          0.077707 |           2.1916 |           2.1928 |          svm | BoxConstraint:     0.063788 |
|      |        |                  |                   |                  |                  |              | KernelScale:         999.56 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.24966 |
|   87 | Accept |           4.1439 |          0.056472 |           2.1916 |           2.1928 |          svm | BoxConstraint:       29.921 |
|      |        |                  |                   |                  |                  |              | KernelScale:         300.51 |
|      |        |                  |                   |                  |                  |              | Epsilon:             872.64 |
|   88 | Accept |           4.1439 |          0.053269 |           2.1916 |           2.1928 |          svm | BoxConstraint:       0.5701 |
|      |        |                  |                   |                  |                  |              | KernelScale:       0.020421 |
|      |        |                  |                   |                  |                  |              | Epsilon:             282.76 |
|   89 | Accept |           4.1439 |          0.054778 |           2.1916 |           2.1928 |          svm | BoxConstraint:      0.60472 |
|      |        |                  |                   |                  |                  |              | KernelScale:      0.0052641 |
|      |        |                  |                   |                  |                  |              | Epsilon:            0.11831 |
|   90 | Accept |           2.8676 |          0.097394 |           2.1916 |           2.1928 |          svm | BoxConstraint:      0.11411 |
|      |        |                  |                   |                  |                  |              | KernelScale:         977.02 |
|      |        |                  |                   |                  |                  |              | Epsilon:           0.090725 |

__________________________________________________________
Optimization completed.
Total iterations: 90
Total elapsed time: 589.6892 seconds
Total time for training and validation: 245.2123 seconds

Best observed learner is an ensemble model with:
	Method:             LSBoost
	NumLearningCycles:      278
	MinLeafSize:             13
Observed log(1 + valLoss): 2.1916
Time for training and validation: 6.4368 seconds

Best estimated learner (returned model) is an ensemble model with:
	Method:             LSBoost
	NumLearningCycles:      278
	MinLeafSize:             13
Estimated log(1 + valLoss): 2.1928
Estimated time for training and validation: 5.8977 seconds

Documentation for fitrauto display

The final model returned by fitrauto corresponds to the best estimated learner. Before returning the model, the function retrains it using the entire training data (carsTrain), the listed Learner (or model) type, and the displayed hyperparameter values.

Evaluate Test Set Performance

Evaluate the performance of the model on the test set. testError is based on the test set mean squared error (MSE). Smaller MSE values indicate better performance.

testMSE = loss(Mdl,carsTest,'MPG');
testError = log(1 + testMSE)
testError = 2.3194

Use fitrauto to automatically select a regression model with optimized hyperparameters, given predictor and response data stored in separate variables.

Load Data

Load the carbig data set, which contains measurements of cars made in the 1970s and early 1980s.

load carbig

Create a matrix X containing the predictor variables Acceleration, Cylinders, and so on. Store the response variable MPG in the variable Y.

X = [Acceleration Cylinders Displacement Weight];
Y = MPG;

Create a variable indicating which predictors are categorical. Cylinders is the only categorical variable in X.

categoricalVars = [false true false false];

Partition Data

Partition the data into training and test sets. Use approximately 80% of the observations for the model selection and hyperparameter tuning process, and 20% of the observations to test the performance of the final model returned by fitrauto. Use cvpartition to partition the data.

rng('default') % For reproducibility of the partition
c = cvpartition(length(Y),'Holdout',0.20);
trainingIdx = training(c); % Indices for the training set
XTrain = X(trainingIdx,:);
YTrain = Y(trainingIdx);
testIdx = test(c); % Indices for the test set
XTest = X(testIdx,:);
YTest = Y(testIdx);

Run fitrauto

Pass the training data to fitrauto. By default, fitrauto determines appropriate model (or learner) types to try, uses Bayesian optimization to find good hyperparameter values for those models, and returns a trained model Mdl with the best expected performance. Specify the categorical predictors, and run the optimization in parallel (requires Parallel Computing Toolbox™). Return a second output OptimizationResults that contains the details of the Bayesian optimization.

Expect this process to take some time. By default, fitrauto provides a plot of the optimization and an iterative display of the optimization results. For more information on how to interpret these results, see Verbose Display.

options = struct('UseParallel',true);
[Mdl,OptimizationResults] = fitrauto(XTrain,YTrain, ...
    'CategoricalPredictors',categoricalVars, ...
    'HyperparameterOptimizationOptions',options);
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 6).
Copying objective function to workers...
Done copying objective function to workers.
Learner types to explore: ensemble, svm, tree
Total iterations (MaxObjectiveEvaluations): 90
Total time (MaxTime): Inf
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|    1 |       5 | Best   |           3.0205 |            1.6237 |           3.0205 |           3.0329 |         tree | MinLeafSize:              6 |
|    2 |       5 | Accept |           3.0453 |             1.572 |           3.0205 |           3.0329 |         tree | MinLeafSize:              5 |
|    3 |       5 | Accept |            4.143 |            2.4922 |           3.0205 |           3.0329 |          svm | BoxConstraint:       336.91 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:      0.0018275 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             0.1074 |
|    4 |       5 | Accept |            4.143 |           0.68486 |           3.0205 |           3.0329 |          svm | BoxConstraint:       346.92 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.032493 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.23974 |
|    5 |       4 | Accept |           4.1434 |            7.9255 |           2.9188 |           3.0329 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      257 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:            156 |
|    6 |       4 | Best   |           2.9188 |            9.0443 |           2.9188 |           3.0329 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      287 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              1 |
|    7 |       4 | Accept |           2.9275 |           0.30936 |           2.9188 |           2.9276 |          svm | BoxConstraint:     0.033068 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         585.38 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             4.6993 |
|    8 |       4 | Accept |            4.143 |           0.12692 |           2.9188 |           2.9276 |          svm | BoxConstraint:       985.69 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:      0.0010988 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             449.48 |
|    9 |       4 | Best   |           2.8721 |            7.5254 |           2.8721 |           2.9276 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      278 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             13 |
|   10 |       4 | Accept |            4.143 |           0.12977 |           2.8721 |           2.9276 |          svm | BoxConstraint:     0.010812 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         1.2015 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.034209 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   11 |       3 | Accept |           2.9167 |            7.4347 |           2.8721 |           2.9276 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      287 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             63 |
|   12 |       3 | Accept |            4.143 |           0.18882 |           2.8721 |           2.9276 |          svm | BoxConstraint:    0.0021787 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.018209 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             443.71 |
|   13 |       6 | Accept |           3.6673 |            23.678 |           2.8721 |           2.9277 |          svm | BoxConstraint:     0.033502 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         153.38 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.093672 |
|   14 |       3 | Accept |           3.1971 |           0.31534 |           2.8721 |           2.9277 |         tree | MinLeafSize:              2 |
|   15 |       3 | Accept |            4.143 |            1.3488 |           2.8721 |           2.9277 |          svm | BoxConstraint:    0.0023916 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:      0.0049969 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             3.0552 |
|   16 |       3 | Accept |           3.0139 |           0.45304 |           2.8721 |           2.9277 |         tree | MinLeafSize:             34 |
|   17 |       3 | Accept |           3.3225 |           0.23199 |           2.8721 |           2.9277 |         tree | MinLeafSize:            122 |
|   18 |       4 | Best   |           2.8696 |            5.7263 |           2.8696 |           2.9278 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      283 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             17 |
|   19 |       4 | Accept |           3.2501 |            0.0799 |           2.8696 |           2.9278 |         tree | MinLeafSize:              1 |
|   20 |       4 | Accept |            4.143 |          0.079241 |           2.8696 |           2.9278 |          svm | BoxConstraint:       37.028 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.033731 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             0.2457 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   21 |       3 | Accept |           2.9536 |           0.19208 |           2.8696 |           2.9278 |         tree | MinLeafSize:             11 |
|   22 |       3 | Accept |            4.143 |           0.18269 |           2.8696 |           2.9278 |          svm | BoxConstraint:       240.91 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:      0.0063646 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             92.342 |
|   23 |       6 | Best   |           2.8672 |            5.0865 |           2.8672 |           2.8672 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      234 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             31 |
|   24 |       2 | Best   |           2.8399 |            4.7739 |           2.8399 |           2.8672 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      212 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|   25 |       2 | Accept |           3.1971 |           0.15794 |           2.8399 |           2.8672 |         tree | MinLeafSize:              2 |
|   26 |       2 | Accept |            4.143 |           0.10773 |           2.8399 |           2.8672 |          svm | BoxConstraint:       282.29 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.046131 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             12.059 |
|   27 |       2 | Accept |            4.143 |           0.71154 |           2.8399 |           2.8672 |          svm | BoxConstraint:    0.0054508 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.013151 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             51.093 |
|   28 |       2 | Accept |            4.143 |           0.68201 |           2.8399 |           2.8672 |          svm | BoxConstraint:       7.8926 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.10102 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.61148 |
|   29 |       6 | Accept |            4.143 |           0.10752 |           2.8399 |           2.8672 |          svm | BoxConstraint:       2.1296 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         3.2623 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             599.62 |
|   30 |       4 | Accept |           2.9403 |           0.12443 |           2.8399 |           2.8672 |         tree | MinLeafSize:             13 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   31 |       4 | Accept |            4.143 |          0.081103 |           2.8399 |           2.8672 |          svm | BoxConstraint:    0.0085377 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.049456 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.59637 |
|   32 |       4 | Accept |            4.143 |           0.23798 |           2.8399 |           2.8672 |          svm | BoxConstraint:     0.036827 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         504.96 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             157.94 |
|   33 |       4 | Accept |           3.2501 |          0.064846 |           2.8399 |           2.8672 |         tree | MinLeafSize:              1 |
|   34 |       3 | Accept |           2.8783 |            6.0315 |           2.8399 |           2.8221 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      269 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              3 |
|   35 |       3 | Accept |            3.112 |          0.055138 |           2.8399 |           2.8221 |         tree | MinLeafSize:             62 |
|   36 |       3 | Accept |            3.112 |          0.044344 |           2.8399 |           2.8221 |         tree | MinLeafSize:             62 |
|   37 |       6 | Accept |           2.8477 |            6.7753 |           2.8399 |           2.8399 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      293 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|   38 |       4 | Accept |           2.8842 |            4.8511 |           2.8399 |           2.8399 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      214 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              4 |
|   39 |       4 | Accept |           2.9282 |           0.12077 |           2.8399 |           2.8399 |          svm | BoxConstraint:      0.20553 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         880.29 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             4.5637 |
|   40 |       4 | Accept |            4.143 |           0.22687 |           2.8399 |           2.8399 |          svm | BoxConstraint:       26.303 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.40313 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              228.3 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   41 |       3 | Accept |           3.0928 |            5.0527 |           2.8294 |           2.8294 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      250 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             70 |
|   42 |       3 | Best   |           2.8294 |            4.9244 |           2.8294 |           2.8294 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      207 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              8 |
|   43 |       4 | Accept |           2.8717 |            4.8606 |           2.8294 |           2.8294 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      233 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|   44 |       4 | Accept |           2.8489 |            4.4632 |           2.8294 |           2.8294 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      200 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              1 |
|   45 |       4 | Accept |           3.3765 |          0.069033 |           2.8294 |           2.8294 |         tree | MinLeafSize:            117 |
|   46 |       4 | Accept |            4.143 |           0.10501 |           2.8294 |           2.8294 |          svm | BoxConstraint:     0.032384 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         797.08 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             64.843 |
|   47 |       4 | Accept |           2.8401 |            5.5934 |           2.8294 |           2.8295 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      300 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             25 |
|   48 |       4 | Accept |           2.8389 |            5.6037 |           2.8294 |           2.8295 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      297 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             26 |
|   49 |       3 | Accept |           4.8036 |            15.721 |           2.8294 |           2.8295 |          svm | BoxConstraint:     0.006061 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         127.62 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:          0.0090183 |
|   50 |       3 | Accept |           2.8545 |             3.771 |           2.8294 |           2.8295 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      201 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             34 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   51 |       6 | Accept |           2.8713 |             13.26 |           2.8294 |           2.8295 |          svm | BoxConstraint:      0.10041 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         286.12 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             2.3001 |
|   52 |       2 | Best   |           2.8234 |            5.8022 |           2.8234 |           2.7997 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      298 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              6 |
|   53 |       2 | Accept |           2.9029 |           0.40398 |           2.8234 |           2.7997 |          svm | BoxConstraint:     0.088088 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         611.34 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.8047 |
|   54 |       2 | Accept |           2.9804 |          0.091645 |           2.8234 |           2.7997 |         tree | MinLeafSize:              8 |
|   55 |       2 | Accept |           2.9032 |           0.10799 |           2.8234 |           2.7997 |         tree | MinLeafSize:             17 |
|   56 |       2 | Accept |            4.143 |          0.070695 |           2.8234 |           2.7997 |          svm | BoxConstraint:    0.0011341 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:      0.0017464 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.012532 |
|   57 |       6 | Accept |            4.143 |          0.065257 |           2.8234 |           2.7997 |          svm | BoxConstraint:       275.76 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.034549 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             6.2312 |
|   58 |       4 | Accept |            2.829 |            6.4083 |           2.8234 |           2.7997 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      299 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              6 |
|   59 |       4 | Accept |           2.8955 |            2.0815 |           2.8234 |           2.7997 |          svm | BoxConstraint:      0.10295 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         505.98 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              1.431 |
|   60 |       4 | Accept |           2.9081 |            1.9958 |           2.8234 |           2.7997 |          svm | BoxConstraint:    0.0012679 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         229.31 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.075286 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   61 |       3 | Accept |           2.8398 |            4.7822 |           2.8234 |           2.7997 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      219 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             26 |
|   62 |       3 | Accept |            2.895 |              3.43 |           2.8234 |           2.7997 |          svm | BoxConstraint:      0.15672 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         480.16 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.1335 |
|   63 |       6 | Accept |            2.912 |           0.27526 |           2.8234 |           2.7997 |          svm | BoxConstraint:    0.0013925 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         333.99 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.24069 |
|   64 |       4 | Accept |            4.143 |          0.069807 |           2.8234 |           2.7997 |          svm | BoxConstraint:       164.25 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:            422 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             709.16 |
|   65 |       4 | Accept |           2.8365 |            4.0891 |           2.8234 |           2.7997 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      205 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              3 |
|   66 |       4 | Accept |            4.143 |           0.08222 |           2.8234 |           2.7997 |          svm | BoxConstraint:    0.0011924 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         6.2437 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             469.79 |
|   67 |       4 | Accept |           2.8335 |            5.8422 |           2.8234 |           2.8284 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      299 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              6 |
|   68 |       4 | Best   |           2.8221 |            5.8695 |           2.8221 |           2.8267 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      299 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              6 |
|   69 |       4 | Accept |           2.9044 |            3.5533 |           2.8221 |           2.8267 |          svm | BoxConstraint:      0.01371 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:          287.4 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              2.327 |
|   70 |       3 | Accept |            4.143 |            30.826 |           2.8221 |           2.8267 |          svm | BoxConstraint:       1.3468 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         9.6762 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.023868 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   71 |       3 | Accept |           2.9103 |           0.35083 |           2.8221 |           2.8267 |          svm | BoxConstraint:    0.0010155 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         291.09 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.12643 |
|   72 |       6 | Accept |           4.0387 |            14.658 |           2.8221 |           2.8267 |          svm | BoxConstraint:    0.0011011 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         144.34 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.13364 |
|   73 |       6 | Accept |            4.143 |          0.045609 |           2.8221 |           2.8267 |          svm | BoxConstraint:      0.06348 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.013026 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             3.9464 |
|   74 |       6 | Accept |           2.9359 |          0.083339 |           2.8221 |           2.8267 |          svm | BoxConstraint:     0.019713 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         788.49 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.2928 |
|   75 |       4 | Accept |           2.8747 |            13.324 |           2.8221 |           2.8267 |          svm | BoxConstraint:      0.49436 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         384.21 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             2.5974 |
|   76 |       4 | Accept |           2.8736 |            9.1937 |           2.8221 |           2.8267 |          svm | BoxConstraint:    0.0030947 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         213.11 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.21173 |
|   77 |       4 | Accept |           2.9658 |           0.08181 |           2.8221 |           2.8267 |          svm | BoxConstraint:     0.012832 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:          837.4 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.0468 |
|   78 |       4 | Accept |           2.9983 |          0.053408 |           2.8221 |           2.8267 |          svm | BoxConstraint:     0.012618 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         952.91 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.99477 |
|   79 |       3 | Accept |            9.656 |            20.116 |           2.8221 |           2.8077 |          svm | BoxConstraint:       121.18 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         196.01 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.010913 |
|   80 |       3 | Accept |           2.9123 |           0.30498 |           2.8221 |           2.8077 |          svm | BoxConstraint:     0.023221 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         560.55 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              1.199 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   81 |       3 | Accept |           2.8944 |            3.6373 |           2.8221 |           2.7917 |          svm | BoxConstraint:      0.06032 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         409.44 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.7539 |
|   82 |       3 | Accept |            3.242 |           0.06087 |           2.8221 |           2.7917 |          svm | BoxConstraint:    0.0010019 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         979.17 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.13535 |
|   83 |       3 | Accept |           3.0281 |          0.043666 |           2.8221 |           2.7917 |         tree | MinLeafSize:             57 |
|   84 |       3 | Accept |           3.1507 |           0.06327 |           2.8221 |           2.7917 |         tree | MinLeafSize:              3 |
|   85 |       6 | Accept |            4.143 |          0.056953 |           2.8221 |           2.8069 |          svm | BoxConstraint:       220.96 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         28.058 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             66.219 |
|   86 |       3 | Accept |           11.403 |            31.076 |           2.8221 |           2.8069 |          svm | BoxConstraint:       1.8523 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         17.462 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             7.7025 |
|   87 |       3 | Accept |           2.8513 |            5.3882 |           2.8221 |           2.8069 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      275 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              1 |
|   88 |       3 | Accept |            4.143 |           0.10474 |           2.8221 |           2.8069 |          svm | BoxConstraint:        8.342 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         70.835 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             38.428 |
|   89 |       3 | Accept |            2.856 |            3.9903 |           2.8221 |           2.8069 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | NumLearningCycles:      210 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              9 |
|   90 |       4 | Accept |            4.143 |          0.052586 |           2.8221 |           2.8271 |          svm | BoxConstraint:       119.13 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.037027 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.010414 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   91 |       4 | Accept |           3.1971 |          0.090004 |           2.8221 |           2.8271 |         tree | MinLeafSize:              2 |
|   92 |       4 | Accept |            2.919 |           0.14565 |           2.8221 |           2.8271 |          svm | BoxConstraint:    0.0028006 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         454.44 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.10156 |

__________________________________________________________
Optimization completed.
Total iterations: 92
Total elapsed time: 171.8421 seconds
Total time for training and validation: 343.7768 seconds

Best observed learner is an ensemble model with:
	Method:                 Bag
	NumLearningCycles:      299
	MinLeafSize:              6
Observed log(1 + valLoss): 2.8221
Time for training and validation: 5.8695 seconds

Best estimated learner (returned model) is an ensemble model with:
	Method:                 Bag
	NumLearningCycles:      298
	MinLeafSize:              6
Estimated log(1 + valLoss): 2.8271
Estimated time for training and validation: 5.9689 seconds

Documentation for fitrauto display

The final model returned by fitrauto corresponds to the best estimated learner. Before returning the model, the function retrains it using the entire training data (XTrain and YTrain), the listed Learner (or model) type, and the displayed hyperparameter values.

Evaluate Test Set Performance

Evaluate the performance of the model on the test set. testError is based on the test set mean squared error (MSE). Smaller MSE values indicate better performance.

testMSE = loss(Mdl,XTest,YTest);
testError = log(1 + testMSE)
testError = 2.8904

Use fitrauto to automatically select a regression model with optimized hyperparameters, given predictor and response data stored in a table. Compare the performance of the resulting regression model to the performance of a simple linear regression model created with fitlm.

Load and Partition Data

Load the carbig data set, which contains measurements of cars made in the 1970s and early 1980s. Convert the Cylinders variable to a categorical variable. Create a table containing the predictor variables Acceleration, Cylinders, Displacement, and so on, as well as the response variable MPG.

load carbig
Cylinders = categorical(Cylinders);
cars = table(Acceleration,Cylinders,Displacement, ...
    Horsepower,Model_Year,Origin,Weight,MPG);

Partition the data into training and test sets. Use approximately 80% of the observations for training, and 20% of the observations for testing. Use cvpartition to partition the data.

rng('default') % For reproducibility of the data partition
c = cvpartition(length(MPG),'Holdout',0.2);
trainingIdx = training(c); % Training set indices
carsTrain = cars(trainingIdx,:);
testIdx = test(c); % Test set indices
carsTest = cars(testIdx,:);

Run fitrauto

Pass the training data to fitrauto. By default, fitrauto determines appropriate model types to try, uses Bayesian optimization to find good hyperparameter values, and returns a trained model autoMdl with the best expected performance. Specify to optimize over all optimizable hyperparameters and run the optimization in parallel (requires Parallel Computing Toolbox™).

Expect this process to take some time. By default, fitrauto provides a plot of the optimization and an iterative display of the optimization results. For more information on how to interpret these results, see Verbose Display.

options = struct('UseParallel',true);
autoMdl = fitrauto(carsTrain,'MPG','OptimizeHyperparameters','all', ...
    'HyperparameterOptimizationOptions',options);
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 6).
Copying objective function to workers...
Done copying objective function to workers.
Learner types to explore: ensemble, svm, tree
Total iterations (MaxObjectiveEvaluations): 90
Total time (MaxTime): Inf
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|    1 |       4 | Accept |           3.1825 |            1.6878 |           2.6471 |           2.6473 |         tree | MinLeafSize:             38 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:             2 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     1 |
|    2 |       4 | Best   |           2.6471 |             1.696 |           2.6471 |           2.6473 |         tree | MinLeafSize:              1 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            44 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     4 |
|    3 |       4 | Accept |           2.6683 |            1.6819 |           2.6471 |           2.6473 |         tree | MinLeafSize:             29 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            52 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     6 |
|    4 |       4 | Accept |           4.1439 |            3.1431 |           2.6471 |           2.6473 |          svm | BoxConstraint:     0.010718 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         1.7547 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              182.6 |
|    5 |       3 | Best   |           2.3998 |            6.3705 |           2.3998 |           2.6473 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:          0.64294 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             39 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|    6 |       3 | Accept |           4.1439 |            0.2549 |           2.3998 |           2.6473 |          svm | BoxConstraint:     0.012677 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         351.81 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             140.99 |
|    7 |       6 | Best   |           2.2082 |            7.2862 |           2.2082 |           2.2593 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:         0.033855 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              6 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|    8 |       5 | Accept |           4.1439 |           0.83218 |           2.2082 |           2.2593 |          svm | BoxConstraint:       37.191 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         21.113 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             33.874 |
|    9 |       5 | Accept |           2.7394 |            1.4286 |           2.2082 |           2.2593 |          svm | BoxConstraint:     0.057859 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         448.87 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             4.2169 |
|   10 |       4 | Accept |           2.3268 |            6.0389 |           2.2082 |           2.5006 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | LearnRate:              NaN |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             23 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     6 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   11 |       4 | Accept |           3.2336 |            5.2449 |           2.2082 |           2.5006 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:          0.56281 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:            123 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   12 |       4 | Accept |           2.5987 |            6.0197 |           2.2082 |           2.5092 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:          0.89898 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   13 |       4 | Accept |           2.7106 |            5.0205 |           2.2082 |           2.2846 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:          0.74839 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             88 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   14 |       5 | Accept |           2.3047 |            6.3839 |           2.2082 |           2.2846 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:         0.017107 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   15 |       5 | Accept |            2.845 |           0.38816 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0027083 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         413.17 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.13572 |
|   16 |       3 | Accept |           2.6619 |            4.0497 |           2.2082 |           2.2846 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | LearnRate:              NaN |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             46 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   17 |       3 | Accept |            2.845 |             1.475 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0027083 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         413.17 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.13572 |
|   18 |       3 | Accept |            2.845 |            1.3127 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0027083 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         413.17 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.13572 |
|   19 |       6 | Accept |           2.6961 |           0.23596 |           2.2082 |           2.2846 |         tree | MinLeafSize:              5 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:             7 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     5 |
|   20 |       5 | Accept |            4.143 |           0.20641 |           2.2082 |           2.2846 |         tree | MinLeafSize:            138 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:             3 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     7 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   21 |       5 | Accept |           3.4903 |            0.1284 |           2.2082 |           2.2846 |         tree | MinLeafSize:             83 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            41 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   22 |       3 | Accept |           2.2233 |            4.8768 |           2.2082 |           2.2846 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:         0.055038 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   23 |       3 | Accept |           2.3507 |            4.7876 |           2.2082 |           2.2846 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | LearnRate:              NaN |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              2 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   24 |       3 | Accept |            4.143 |          0.055475 |           2.2082 |           2.2846 |         tree | MinLeafSize:            132 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:             8 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     5 |
|   25 |       6 | Accept |           4.1439 |            32.664 |           2.2082 |           2.2846 |          svm | BoxConstraint:      0.15265 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         1.4893 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.44287 |
|   26 |       6 | Accept |           3.2612 |           0.48094 |           2.2082 |           2.2846 |         tree | MinLeafSize:             72 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            76 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     3 |
|   27 |       2 | Accept |           5.9862 |            4.4845 |           2.2082 |           2.2846 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:         0.001143 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:            104 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   28 |       2 | Accept |           2.2467 |             6.314 |           2.2082 |           2.2846 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | LearnRate:              NaN |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             12 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     7 |
|   29 |       2 | Accept |           2.9745 |            6.2592 |           2.2082 |           2.2846 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:         0.010155 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             13 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   30 |       2 | Accept |           2.4555 |           0.24915 |           2.2082 |           2.2846 |         tree | MinLeafSize:              8 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            85 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     5 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   31 |       2 | Accept |           2.5778 |          0.051639 |           2.2082 |           2.2846 |         tree | MinLeafSize:              6 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            43 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   32 |       5 | Accept |            3.031 |          0.066903 |           2.2082 |           2.2846 |         tree | MinLeafSize:             44 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:           265 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   33 |       5 | Accept |           2.8424 |          0.087547 |           2.2082 |           2.2846 |         tree | MinLeafSize:              1 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            90 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   34 |       6 | Accept |           4.1439 |           0.12337 |           2.2082 |           2.2846 |          svm | BoxConstraint:       2.1967 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.02117 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.20631 |
|   35 |       5 | Accept |           2.3629 |            4.8606 |           2.2082 |           2.2846 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | LearnRate:              NaN |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:              3 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   36 |       5 | Accept |           4.1439 |          0.056543 |           2.2082 |           2.2846 |          svm | BoxConstraint:       2.1967 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.02117 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.20631 |
|   37 |       5 | Accept |           4.1439 |          0.053075 |           2.2082 |           2.2846 |          svm | BoxConstraint:       1.5262 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.16982 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.09432 |
|   38 |       6 | Accept |           4.1439 |           0.12616 |           2.2082 |           2.2846 |          svm | BoxConstraint:       488.75 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.047261 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.019147 |
|   39 |       4 | Accept |            2.611 |            14.154 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0057698 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         199.91 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              1.094 |
|   40 |       4 | Accept |           3.1538 |            4.3469 |           2.2082 |           2.2846 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | LearnRate:              NaN |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             82 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     5 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   41 |       4 | Accept |           4.1439 |           0.05576 |           2.2082 |           2.2846 |          svm | BoxConstraint:       488.75 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.047261 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.019147 |
|   42 |       3 | Accept |           14.841 |            32.126 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.022624 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         14.497 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.076166 |
|   43 |       3 | Accept |           4.1439 |           0.10864 |           2.2082 |           2.2846 |          svm | BoxConstraint:       347.06 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.024995 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.012891 |
|   44 |       6 | Accept |            3.539 |          0.049608 |           2.2082 |           2.2846 |         tree | MinLeafSize:              1 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:             1 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     1 |
|   45 |       2 | Accept |           4.1439 |            29.948 |           2.2082 |           2.2846 |          svm | BoxConstraint:       1.6286 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         8.1222 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.032824 |
|   46 |       2 | Accept |            3.024 |          0.090484 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0090015 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         969.06 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.60305 |
|   47 |       2 | Accept |           2.8238 |          0.065909 |           2.2082 |           2.2846 |         tree | MinLeafSize:              2 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            12 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   48 |       2 | Accept |           4.1439 |           0.10484 |           2.2082 |           2.2846 |          svm | BoxConstraint:       45.111 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         2.4682 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              279.1 |
|   49 |       2 | Accept |           3.0246 |          0.068829 |           2.2082 |           2.2846 |         tree | MinLeafSize:             36 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:             3 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     4 |
|   50 |       6 | Accept |           3.1255 |           0.10386 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.003354 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         933.08 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.0432 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   51 |       2 | Accept |           2.8825 |            1.1593 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0086068 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         204.65 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             7.8718 |
|   52 |       2 | Accept |           4.8598 |            6.1993 |           2.2082 |           2.2846 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:        0.0040831 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             10 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   53 |       2 | Accept |           4.1439 |          0.078796 |           2.2082 |           2.2846 |          svm | BoxConstraint:       19.339 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         336.27 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             745.75 |
|   54 |       2 | Accept |           2.5158 |           0.14155 |           2.2082 |           2.2846 |         tree | MinLeafSize:              8 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            80 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     5 |
|   55 |       2 | Accept |           3.3875 |          0.062779 |           2.2082 |           2.2846 |         tree | MinLeafSize:             84 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:             4 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     7 |
|   56 |       3 | Accept |           2.6873 |          0.061071 |           2.2082 |           2.2846 |         tree | MinLeafSize:              9 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:           204 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   57 |       3 | Accept |           4.1439 |           0.11687 |           2.2082 |           2.2846 |          svm | BoxConstraint:      0.42148 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.48707 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             2.0689 |
|   58 |       3 | Accept |           4.1439 |           0.10415 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0012156 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.015427 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.060481 |
|   59 |       3 | Accept |           4.1439 |           0.08245 |           2.2082 |           2.2846 |          svm | BoxConstraint:      0.44269 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.004171 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.12586 |
|   60 |       6 | Accept |           3.0291 |           0.18287 |           2.2082 |           2.2846 |         tree | MinLeafSize:             23 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:             4 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   61 |       2 | Accept |           9.4831 |            19.284 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.012087 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         123.25 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              8.241 |
|   62 |       2 | Accept |           4.1439 |          0.057065 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0056469 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         1.2745 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.83867 |
|   63 |       2 | Accept |           4.1439 |          0.061443 |           2.2082 |           2.2846 |          svm | BoxConstraint:      0.01064 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:       0.001826 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             0.1071 |
|   64 |       2 | Accept |           4.1439 |          0.084129 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.020589 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         910.21 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              441.3 |
|   65 |       2 | Accept |           3.2302 |          0.059381 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.001004 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         971.66 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:           0.041793 |
|   66 |       6 | Accept |           2.8836 |           0.10666 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.003589 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         510.21 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.43831 |
|   67 |       4 | Accept |           5.6326 |            17.631 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0010527 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         108.83 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.5761 |
|   68 |       4 | Accept |           2.3637 |            4.2106 |           2.2082 |           2.2846 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | LearnRate:              NaN |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             18 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     3 |
|   69 |       4 | Accept |           4.1439 |           0.21335 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0040733 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:      0.0012016 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.10292 |
|   70 |       4 | Accept |           2.8784 |           0.14901 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0035987 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         502.49 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.33747 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   71 |       4 | Accept |           2.8658 |           0.16512 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.011138 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         552.68 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.0229 |
|   72 |       4 | Accept |            2.841 |           0.24289 |           2.2082 |           2.2846 |          svm | BoxConstraint:    0.0068794 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         475.75 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.66904 |
|   73 |       2 | Accept |           4.1439 |            29.963 |           2.2082 |           2.2846 |          svm | BoxConstraint:       673.65 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         3.2547 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             1.3911 |
|   74 |       2 | Accept |           12.969 |            29.643 |           2.2082 |           2.2846 |          svm | BoxConstraint:       851.71 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         23.076 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.97056 |
|   75 |       2 | Accept |            3.037 |          0.068788 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.010616 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         951.18 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             3.1446 |
|   76 |       5 | Accept |           2.8903 |          0.072226 |           2.2082 |           2.2846 |          svm | BoxConstraint:     0.045569 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:          923.8 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             2.1758 |
|   77 |       5 | Accept |           4.1439 |          0.062494 |           2.2082 |           2.2846 |          svm | BoxConstraint:       522.62 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.04581 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.02037 |
|   78 |       2 | Accept |           4.1439 |           0.10417 |           2.2045 |           2.2846 |          svm | BoxConstraint:     0.085671 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:      0.0011363 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:            0.13518 |
|   79 |       2 | Best   |           2.2045 |            5.0964 |           2.2045 |           2.2846 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:         0.035513 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             13 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   80 |       2 | Accept |           4.1439 |          0.071938 |           2.2045 |           2.2846 |          svm | BoxConstraint:        1.751 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.15632 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              1.413 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   81 |       2 | Accept |           4.1439 |          0.048361 |           2.2045 |           2.2846 |          svm | BoxConstraint:     0.001317 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.09765 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             2.7812 |
|   82 |       6 | Accept |           4.1439 |          0.059009 |           2.2045 |           2.2846 |          svm | BoxConstraint:       230.13 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         15.715 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             425.18 |
|   83 |       3 | Accept |           4.1439 |          0.071838 |           2.2045 |           2.2846 |          svm | BoxConstraint:       10.653 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:      0.0087342 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             25.431 |
|   84 |       3 | Accept |           2.3706 |             4.013 |           2.2045 |           2.2846 |     ensemble | Method:                 Bag |
|      |         |        |                  |                   |                  |                  |              | LearnRate:              NaN |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             11 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     2 |
|   85 |       3 | Accept |           4.1439 |          0.076126 |           2.2045 |           2.2846 |          svm | BoxConstraint:     0.023202 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         10.791 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             22.244 |
|   86 |       3 | Accept |           4.1439 |          0.087602 |           2.2045 |           2.2846 |          svm | BoxConstraint:       214.12 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         102.84 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             107.38 |
|   87 |       6 | Accept |           2.8921 |           0.25372 |           2.2045 |           2.2846 |          svm | BoxConstraint:    0.0058028 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         306.93 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              6.344 |
|   88 |       1 | Accept |           4.1439 |            31.385 |           2.2045 |           2.2846 |          svm | BoxConstraint:       5.1147 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         2.5073 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:          0.0095496 |
|   89 |       1 | Accept |           2.9511 |           0.16544 |           2.2045 |           2.2846 |          svm | BoxConstraint:    0.0045725 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         345.75 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             6.6158 |
|   90 |       1 | Accept |           4.1439 |          0.053551 |           2.2045 |           2.2846 |          svm | BoxConstraint:        1.252 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:        0.18118 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:             11.522 |
|===================================================================================================================================================|
| Iter | Active  | Eval   | log(1 + valLoss) | Time for training | Observed min     | Estimated min    | Learner      | Hyperparameter:       Value |
|      | workers | result |                  | & validation (sec)| log(1 + valLoss) | log(1 + valLoss) |              |                             |
|===================================================================================================================================================|
|   91 |       1 | Accept |           2.3908 |            4.0338 |           2.2045 |           2.2846 |     ensemble | Method:             LSBoost |
|      |         |        |                  |                   |                  |                  |              | LearnRate:           0.2966 |
|      |         |        |                  |                   |                  |                  |              | MinLeafSize:             78 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:   NaN |
|   92 |       1 | Accept |           2.5157 |          0.073868 |           2.2045 |           2.2846 |         tree | MinLeafSize:              7 |
|      |         |        |                  |                   |                  |                  |              | MaxNumSplits:            95 |
|      |         |        |                  |                   |                  |                  |              | NumVariablesToSample:     7 |
|   93 |       1 | Accept |           3.3193 |          0.084303 |           2.2045 |           2.2846 |          svm | BoxConstraint:    0.0094861 |
|      |         |        |                  |                   |                  |                  |              | KernelScale:         309.46 |
|      |         |        |                  |                   |                  |                  |              | Epsilon:              10.91 |

__________________________________________________________
Optimization completed.
Total iterations: 93
Total elapsed time: 216.3087 seconds
Total time for training and validation: 363.6476 seconds

Best observed learner is an ensemble model with:
	Method:             LSBoost
	LearnRate:         0.035513
	MinLeafSize:             13
	NumVariablesToSample:   NaN
Observed log(1 + valLoss): 2.2045
Time for training and validation: 5.0964 seconds

Best estimated learner (returned model) is an ensemble model with:
	Method:             LSBoost
	LearnRate:         0.033855
	MinLeafSize:              6
	NumVariablesToSample:   NaN
Estimated log(1 + valLoss): 2.2846
Estimated time for training and validation: 7.2769 seconds

Documentation for fitrauto display

The final model returned by fitrauto corresponds to the best estimated learner. Before returning the model, the function retrains it using the entire training data (carsTrain), the listed Learner (or model) type, and the displayed hyperparameter values.

Create Simple Model

Create a simple linear regression model linearMdl by using the fitlm function.

linearMdl = fitlm(carsTrain);

Although the linearMdl object does not have the exact same properties and methods as the autoMdl object, you can use both models to predict response values for new data by using the predict object function.

Compare Test Set Performance of Models

Compare the performance of the linearMdl and autoMdl models on the test data set. For each model, compute the test set mean squared error (MSE). Smaller MSE values indicate better performance.

ypred = predict(linearMdl,carsTest);
linearMSE = mean((carsTest.MPG-ypred).^2,'omitnan')
linearMSE = 11.0981
autoMSE = loss(autoMdl,carsTest,'MPG')
autoMSE = 8.6563

The autoMdl model seems to outperform the linearMdl model.

Input Arguments

collapse all

Sample data, specified as a table. Each row of Tbl corresponds to one observation, and each column corresponds to one predictor. Optionally, Tbl can contain one additional column for the response variable. Multicolumn variables and cell arrays other than cell arrays of character vectors are not accepted.

If Tbl contains the response variable, and you want to use all remaining variables in Tbl as predictors, specify the response variable using ResponseVarName.

If Tbl contains the response variable, and you want to use only a subset of the remaining variables in Tbl as predictors, specify a formula using formula.

If Tbl does not contain the response variable, specify a response variable using Y. The length of the response variable and the number of rows in Tbl must be equal.

Data Types: table

Response variable name, specified as the name of a variable in Tbl. The response variable must be a numeric vector.

You must specify ResponseVarName as a character vector or string scalar. For example, if the response variable Y is stored as Tbl.Y, then specify it as 'Y'. Otherwise, the software treats all columns of Tbl, including Y, as predictors when training a model.

Data Types: char | string

Explanatory model of the response variable and a subset of the predictor variables, specified as a character vector or string scalar in the form 'Y~X1+X2+X3'. In this form, Y represents the response variable, and X1, X2, and X3 represent the predictor variables.

To specify a subset of variables in Tbl as predictors for training the model, use a formula. If you specify a formula, then the software does not use any variables in Tbl that do not appear in formula.

The variable names in the formula must be both variable names in Tbl (Tbl.Properties.VariableNames) and valid MATLAB® identifiers.

You can verify the variable names in Tbl by using the isvarname function. The following code returns logical 1 (true) for each variable that has a valid variable name.

cellfun(@isvarname,Tbl.Properties.VariableNames)
If the variable names in Tbl are not valid, then convert them by using the matlab.lang.makeValidName function.
Tbl.Properties.VariableNames = matlab.lang.makeValidName(Tbl.Properties.VariableNames);

Data Types: char | string

Response data, specified as a numeric vector. The length of Y must be equal to the number of rows in Tbl or X.

To specify the response variable name, use the ResponseName name-value pair argument.

Data Types: single | double

Predictor data, specified as a numeric matrix.

Each row of X corresponds to one observation, and each column corresponds to one predictor.

The length of Y and the number of rows in X must be equal.

To specify the names of the predictors in the order of their appearance in X, use the PredictorNames name-value pair argument.

Data Types: single | double

Note

The software treats NaN, empty character vector (''), empty string (""), <missing>, and <undefined> elements as missing data. The software removes rows of data corresponding to missing values in the response variable. However, the treatment of missing values in the predictor data X or Tbl varies among models (or learners).

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'HyperparameterOptimizationOptions',struct('MaxObjectiveEvaluations',200,'Verbose',2) specifies to run 200 iterations of the optimization process (that is, try 200 model hyperparameter combinations), and to display information in the Command Window about the next model hyperparameter combination to be evaluated.
Optimizer Options

collapse all

Types of regression models to try during the optimization, specified as the comma-separated pair consisting of 'Learners' and a value in the first table below or one or more learner names in the second table. Specify multiple learner names as a string or cell array.

ValueDescription
'auto'fitrauto automatically selects a subset of learners, suitable for the given predictor and response data. The learners can have model hyperparameter values that differ from the default. For more information, see Automatic Selection of Learners.
'all'fitrauto selects all possible learners.
'all-linear'fitrauto selects all linear learners: 'linear' and 'svm' (with a linear kernel).
'all-nonlinear'fitrauto selects all nonlinear learners: 'ensemble', 'gp', 'kernel', 'svm' (with a Gaussian or polynomial kernel), and 'tree'.

Learner NameDescription
'ensemble'Ensemble regression model
'gp'Gaussian process regression model
'kernel'Kernel regression model
'linear'Linear regression model for high-dimensional data
'svm'Support vector machine regression model
'tree'Binary decision regression tree

Example: 'Learners','all'

Example: 'Learners','ensemble'

Example: 'Learners',{'gp','svm'}

Hyperparameters to optimize, specified as the comma-separated pair consisting of 'OptimizeHyperparameters' and 'auto' or 'all'. The optimizable hyperparameters depend on the model (or learner), as described in this table.

Learner NameHyperparameters for 'auto'Additional Hyperparameters for 'all'Notes
'ensemble'Method, NumLearningCycles, LearnRate, MinLeafSizeMaxNumSplits, NumVariablesToSample

When the ensemble Method value is a boosting method, the ensemble NumBins value is 50.

For more information, including hyperparameter search ranges, see OptimizeHyperparameters. Note that you cannot change hyperparameter search ranges when you use fitrauto.

'gp'SigmaBasisFunction, KernelFunction, KernelScale (KernelParameters), Standardize

The fitrauto function ignores all ARD kernel options and, therefore, chooses among the KernelFunction values of 'exponential', 'matern32', 'matern52', 'rationalquadratic', and 'squaredexponential' when the OptimizeHyperparameters value is 'all'.

For more information, including hyperparameter search ranges, see OptimizeHyperparameters. Note that you cannot change hyperparameter search ranges when you use fitrauto.

'kernel'Epsilon, KernelScale, LambdaLearner, NumExpansionDimensionsFor more information, including hyperparameter search ranges, see OptimizeHyperparameters. Note that you cannot change hyperparameter search ranges when you use fitrauto.
'linear'Lambda, LearnerRegularizationFor more information, including hyperparameter search ranges, see OptimizeHyperparameters. Note that you cannot change hyperparameter search ranges when you use fitrauto.
'svm'BoxConstraint, Epsilon, KernelScaleKernelFunction, PolynomialOrder, Standardize

  • When the Learners value is 'all-linear', the fitrauto function does not optimize the KernelFunction or PolynomialOrder hyperparameters when the OptimizeHyperparameters value is 'all'.

  • When the Learners value is 'all-nonlinear', the fitrauto function chooses among the KernelFunction values of 'gaussian' and 'polynomial', regardless of the OptimizeHyperparameters value.

  • The Standardize value is true when the OptimizeHyperparameters value is 'auto'.

For more information, including hyperparameter search ranges, see OptimizeHyperparameters. Note that you cannot change hyperparameter search ranges when you use fitrauto.

'tree'MinLeafSizeMaxNumSplitsFor more information, including hyperparameter search ranges, see OptimizeHyperparameters. Note that you cannot change hyperparameter search ranges when you use fitrauto.

Note

When 'Learners' is set to a value other than 'auto', the default values for the model hyperparameters not being optimized match the default fit function values, unless otherwise indicated in the table notes. When 'Learners' is set to 'auto', the optimized hyperparameter search ranges and nonoptimized hyperparameter values can vary, depending on the characteristics of the training data. For more information, see Automatic Selection of Learners.

Example: 'OptimizeHyperparameters','all'

Options for the optimization, specified as the comma-separated pair consisting of 'HyperparameterOptimizationOptions' and a structure. All fields in the structure are optional.

Field NameValuesDefault
MaxObjectiveEvaluationsMaximum number of iterations (objective function evaluations)30*L, where L is the number of learners (see Learners)
MaxTime

Time limit, specified as a positive real number. The time limit is in seconds, as measured by tic and toc. Run time can exceed MaxTime because MaxTime does not interrupt function evaluations.

Inf
ShowPlotsLogical value indicating whether to show plots. If true, this field plots the best observed and estimated objective function values (so far) against the iteration number.true
SaveIntermediateResultsLogical value indicating whether to save results. If true, this field overwrites a workspace variable named 'BayesoptResults' at each iteration. The variable is a BayesianOptimization object.false
Verbose

Display at the command line:

  • 0 — No iterative display

  • 1 — Iterative display

  • 2 — Iterative display with additional information about the next point to be evaluated

1
UseParallelLogical value indicating whether to run Bayesian optimization in parallel, which requires Parallel Computing Toolbox™. Due to the nonreproducibility of parallel timing, parallel Bayesian optimization does not necessarily yield reproducible results.false
Repartition

Logical value indicating whether to repartition the cross-validation at every iteration. If false, the optimizer uses a single partition for the optimization.

true usually gives the most robust results because this setting takes partitioning noise into account. However, for good results, true requires at least twice as many function evaluations.

false
Specify only one of the following three options.
CVPartitioncvpartition object, created by cvpartition'Kfold',5 if you do not specify any cross-validation field
HoldoutScalar in the range (0,1) representing the holdout fraction
KfoldInteger greater than 1

Example: 'HyperparameterOptimizationOptions',struct('UseParallel',true)

Regression Options

collapse all

Categorical predictors list, specified as the comma-separated pair consisting of 'CategoricalPredictors' and one of the values in this table.

ValueDescription
Vector of positive integersEach entry in the vector is an index value corresponding to the column of the predictor data (X or Tbl) that contains a categorical variable.
Logical vectorA true entry means that the corresponding column of predictor data (X or Tbl) is a categorical variable.
Character matrixEach row of the matrix is the name of a predictor variable. The names must match the entries in PredictorNames. Pad the names with extra blanks so each row of the character matrix has the same length.
String array or cell array of character vectorsEach element in the array is the name of a predictor variable. The names must match the entries in PredictorNames.
'all'All predictors are categorical.

By default, if the predictor data is in a table (Tbl), fitrauto assumes that a variable is categorical if it is a logical vector, categorical vector, character array, string array, or cell array of character vectors. However, learners that use decision trees assume that mathematically ordered categorical vectors are continuous variables. If the predictor data is a matrix (X), fitrauto assumes that all predictors are continuous. To identify any other predictors as categorical predictors, specify them by using the 'CategoricalPredictors' name-value pair argument.

For more information on how fitting functions treat categorical predictors, see Automatic Creation of Dummy Variables.

Example: 'CategoricalPredictors','all'

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

Predictor variable names, specified as the comma-separated pair consisting of 'PredictorNames' and a string array of unique names or cell array of unique character vectors. The functionality of 'PredictorNames' depends on the way you supply the training data.

  • If you supply X and Y, then you can use 'PredictorNames' to assign names to the predictor variables in X.

    • The order of the names in PredictorNames must correspond to the column order of X. That is, PredictorNames{1} is the name of X(:,1), PredictorNames{2} is the name of X(:,2), and so on. Also, size(X,2) and numel(PredictorNames) must be equal.

    • By default, PredictorNames is {'x1','x2',...}.

  • If you supply Tbl, then you can use 'PredictorNames' to choose which predictor variables to use in training. That is, fitrauto uses only the predictor variables in PredictorNames and the response variable during training.

    • PredictorNames must be a subset of Tbl.Properties.VariableNames and cannot include the name of the response variable.

    • By default, PredictorNames contains the names of all predictor variables.

    • A good practice is to specify the predictors for training using either 'PredictorNames' or formula, but not both.

Example: 'PredictorNames',{'SepalLength','SepalWidth','PetalLength','PetalWidth'}

Data Types: string | cell

Response variable name, specified as the comma-separated pair consisting of 'ResponseName' and a character vector or string scalar.

  • If you supply Y, then you can use 'ResponseName' to specify a name for the response variable.

  • If you supply ResponseVarName or formula, then you cannot use 'ResponseName'.

Example: 'ResponseName','response'

Data Types: char | string

Observation weights, specified as the comma-separated pair consisting of 'Weights' and a positive numeric vector or the name of a variable in Tbl. The software weights each observation in X or Tbl with the corresponding value in Weights. The length of Weights must equal the number of rows in X or Tbl.

If you specify the input data as a table Tbl, then Weights can be the name of a variable in Tbl that contains a numeric vector. In this case, you must specify Weights as a character vector or string scalar. For example, if the weights vector W is stored as Tbl.W, then specify it as 'W'. Otherwise, the software treats all columns of Tbl, including W, as predictors or the response variable when training the model.

By default, Weights is ones(n,1), where n is the number of observations in X or Tbl.

The software normalizes Weights to sum to 1.

Data Types: single | double | char | string

Output Arguments

collapse all

Trained regression model, returned as one of the regression model objects in this table.

Optimization results, returned as a BayesianOptimization object. For more information on the Bayesian optimization process, see Bayesian Optimization.

More About

collapse all

Verbose Display

When you set the Verbose field of the HyperparameterOptimizationOptions name-value pair argument to 1 or 2, the fitrauto function provides an iterative display of the optimization results.

The following table describes the columns in the display and their entries.

Column NameDescription
IterIteration number — You can set a limit to the number of iterations by using the MaxObjectiveEvaluations field of the 'HyperparameterOptimizationOptions' name-value pair argument.
Active workersNumber of active parallel workers — This column appears only when you run the optimization in parallel by setting the UseParallel field of the 'HyperparameterOptimizationOptions' name-value pair argument to true.
Eval result

One of the following evaluation results:

  • Best — The learner and hyperparameter values at this iteration give the minimum observed validation loss computed so far. That is, the log(1 + valLoss) value is the smallest computed so far.

  • Accept — The learner and hyperparameter values at this iteration give meaningful (for example, non-NaN) observed and estimated validation loss values.

  • Error — The learner and hyperparameter values at this iteration result in an error (for example, a log(1 + valLoss) value of NaN).

log(1 + valLoss)Log-transformed validation loss computed for the learner and hyperparameter values at this iteration — In particular, fitrauto computes log(1 + valLoss), where valLoss is the cross-validation mean squared error (MSE) by default. You can change the validation scheme by using the CVPartition, Holdout, or Kfold field of the 'HyperparameterOptimizationOptions' name-value pair argument.
Time for training & validation (sec)Time taken to train and compute the validation loss for the model with the learner and hyperparameter values at this iteration (in seconds) — In particular, this value excludes the time required to update the objective function model maintained by the Bayesian optimization process. For more details, see Bayesian Optimization.
Observed min log(1 + valLoss)

Observed minimum log-transformed validation loss computed so far — This value corresponds to the smallest log(1 + valLoss) value computed so far in the optimization process.

By default, fitrauto returns a plot of the optimization that displays dark blue points for the observed minimum log-transformed validation loss values. This plot does not appear when the ShowPlots field of the 'HyperparameterOptimizationOptions' name-value pair argument is set to false.

Estimated min log(1 + valLoss)

Estimated minimum log-transformed validation loss — At each iteration, fitrauto updates an objective function model maintained by the Bayesian optimization process and uses this model to estimate the minimum log-transformed validation loss. For more details, see Bayesian Optimization.

By default, fitrauto returns a plot of the optimization that displays light blue points for the estimated minimum log-transformed validation loss values. This plot does not appear when the ShowPlots field of the 'HyperparameterOptimizationOptions' name-value pair argument is set to false.

LearnerModel type evaluated at this iteration — Specify the learners used in the optimization by using the 'Learners' name-value pair argument.
Hyperparameter: ValueHyperparameter values at this iteration — Specify the hyperparameters used in the optimization by using the 'OptimizeHyperparameters' name-value pair argument.

The display also includes a description of two models:

  • Best observed learner — This model, with the listed learner type and hyperparameter values, yields the final observed minimum validation loss (log-transformed).

  • Best estimated learner — This model, with the listed learner type and hyperparameter values, yields the final estimated minimum validation loss (log-transformed). fitrauto retrains the model on the entire training data set and returns it as the Mdl output.

Tips

  • Depending on the size of your data and the number of learners you specify, fitrauto can take some time to run. If you have a Parallel Computing Toolbox license, you can speed up computations by running the optimization in parallel. To do so, specify 'HyperparameterOptimizationOptions',struct('UseParallel',true). You can include other fields in the structure to control other aspects of the optimization. See HyperparameterOptimizationOptions.

Algorithms

collapse all

Automatic Selection of Learners

When you specify 'Learners','auto', the fitrauto function analyzes the predictor and response data in order to choose appropriate learners. The function considers whether the data set has any of these characteristics:

  • Categorical predictors

  • Missing values for more than 5% of the data

  • Wide data, where the number of predictors is greater than or equal to the number of observations

  • High-dimensional data, where the number of predictors is greater than 100

  • Large data, where the number of observations is greater than 50,000

The selected learners are always a subset of those listed in the Learners table. However, the associated models tried during the optimization process can have different default values for hyperparameters not being optimized, as well as different search ranges for hyperparameters being optimized.

For example, when you specify Learners as 'auto', the fitrauto function tries SVM learners with the given KernelFunction value, based on the data set characteristics in this table.

Categorical PredictorsMissing ValuesWide DataSVM KernelFunction Value
YesNoEither yes or no'polynomial'
NoNoYes'linear'
NoNoNo'gaussian'

Bayesian Optimization

The goal of Bayesian optimization, and optimization in general, is to find a point that minimizes an objective function. In the context of fitrauto, a point is a learner type together with a set of hyperparameter values for the learner (see Learners and OptimizeHyperparameters), and the objective function is log(1 + valLoss), where valLoss is the cross-validation mean squared error (MSE), by default. The Bayesian optimization implemented in fitrauto internally maintains a multi-RegressionGP model of the objective function. That is, the objective function model splits along the learner type and, for a given learner, the model is a Gaussian process regression (GPR) model. (This underlying model differs from the single GPR model employed by other Statistics and Machine Learning Toolbox™ functions that use Bayesian optimization.) Bayesian optimization trains the underlying model by using objective function evaluations, and determines the next point to evaluate by using an acquisition function ('expected-improvement'). For more information, see Expected Improvement. The acquisition function balances between sampling at points with low modeled objective function values and exploring areas that are not well modeled yet. At the end of the optimization, fitrauto chooses the point with the minimum objective function model value, among the points evaluated during the optimization. For more information, see the 'Criterion','min-visited-mean' name-value pair argument of bestPoint.

Alternative Functionality

  • If you are unsure which models work best for your data set, you can alternatively use the Regression Learner app. Using the app, you can perform hyperparameter tuning for different models, and choose the optimized model that performs best. Although you must select a specific model before you can tune the model hyperparameters, Regression Learner provides greater flexibility for selecting optimizable hyperparameters and setting hyperparameter values. The app also allows you to train a variety of linear regression models (see Linear Regression Models). However, you cannot optimize in parallel, choose 'linear' or 'kernel' learners, or specify observation weights in the app. For more information, see Hyperparameter Optimization in Regression Learner App.

  • If you know which models might suit your data, you can alternatively use the corresponding model fit functions and specify the 'OptimizeHyperparameters' name-value pair argument to tune hyperparameters. You can compare the results across the models to select the best regression model. For an example of this process applied to classification models, see Moving Towards Automating Model Selection Using Bayesian Optimization.

Extended Capabilities

Introduced in R2020b