Байесова оптимизация с длинными массивами

В этом примере показано, как использовать Байесовую оптимизацию, чтобы выбрать оптимальные параметры для обучения классификатор ядра при помощи 'OptimizeHyperparameters' аргумент пары "имя-значение". Выборочные данные установили airlinesmall.csv большой набор данных, который содержит табличный файл данных о полете. Этот пример составляет длинную таблицу, содержащую данные, и использует длинную таблицу, чтобы запустить процедуру оптимизации.

Когда вы выполняете вычисления на длинных массивах, MATLAB® использует любого параллельный пул (значение по умолчанию, если у вас есть Parallel Computing Toolbox™), или локальный сеанс работы с MATLAB. Если вы хотите запустить пример с помощью локального сеанса работы с MATLAB, когда у вас есть Parallel Computing Toolbox, можно изменить глобальную среду выполнения при помощи mapreducer функция.

Получите данные в MATLAB®

Создайте datastore, который ссылается на местоположение папки с данными. Данные могут содержаться в одном файле, наборе файлов или целой папке. Для папок, которые содержат набор файлов, можно задать целое местоположение папки или использовать подстановочный символ, '*.csv', включать несколько файлов с тем же расширением файла в datastore. Выберите подмножество переменных, чтобы работать с и обработать 'NA' значения как недостающие данные так, чтобы datastore заменяет их на NaN значения. Составьте длинную таблицу, которая содержит данные в datastore.

ds = datastore('airlinesmall.csv');
ds.SelectedVariableNames = {'Month','DayofMonth','DayOfWeek',...
                            'DepTime','ArrDelay','Distance','DepDelay'};
ds.TreatAsMissing = 'NA';
tt  = tall(ds) % Tall table
tt =

  M×7 tall table

    Month    DayofMonth    DayOfWeek    DepTime    ArrDelay    Distance    DepDelay
    _____    __________    _________    _______    ________    ________    ________

     10          21            3          642          8         308          12   
     10          26            1         1021          8         296           1   
     10          23            5         2055         21         480          20   
     10          23            5         1332         13         296          12   
     10          22            4          629          4         373          -1   
     10          28            3         1446         59         308          63   
     10           8            4          928          3         447          -2   
     10          10            6          859         11         954          -1   
      :          :             :           :          :           :           :
      :          :             :           :          :           :           :

Подготовьте метки класса и данные о предикторе

Определите рейсы, которые являются поздними на 10 минут или больше путем определения логической переменной, которая верна для позднего рейса. Эта переменная содержит метки класса. Предварительный просмотр этой переменной включает первые несколько строк.

Y = tt.DepDelay > 10 % Class labels
Y =

  M×1 tall logical array

   1
   0
   1
   1
   0
   1
   0
   0
   :
   :

Создайте длинный массив для данных о предикторе.

X = tt{:,1:end-1} % Predictor data
X =

  M×6 tall double matrix

          10          21           3         642           8         308
          10          26           1        1021           8         296
          10          23           5        2055          21         480
          10          23           5        1332          13         296
          10          22           4         629           4         373
          10          28           3        1446          59         308
          10           8           4         928           3         447
          10          10           6         859          11         954
          :           :            :          :           :           :
          :           :            :          :           :           :

Удалите строки в X и Y это содержит недостающие данные.

R = rmmissing([X Y]); % Data with missing entries removed
X = R(:,1:end-1); 
Y = R(:,end); 

Выполните байесовую оптимизацию Используя OptimizeHyperparameters

Оптимизируйте гиперпараметры автоматически с помощью 'OptimizeHyperparameters' аргумент пары "имя-значение".

Стандартизируйте переменные предикторы.

Z = zscore(X);

Найдите оптимальные значения для 'KernelScale' и 'Lambda' аргументы пары "имя-значение", которые минимизируют пятикратную потерю перекрестной проверки. Для воспроизводимости используйте 'expected-improvement-plus' функция приобретения и набор seed генераторов случайных чисел с помощью rng и tallrng. Результаты могут варьироваться в зависимости от количества рабочих и среды выполнения для длинных массивов. Для получения дополнительной информации смотрите Управление Где Ваши Запуски Кода.

rng('default') 
tallrng('default')
Mdl = fitckernel(Z,Y,'Verbose',0,'OptimizeHyperparameters','auto',...
    'HyperparameterOptimizationOptions',struct('AcquisitionFunctionName','expected-improvement-plus'))
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 2: Completed in 0.76 sec
- Pass 2 of 2: Completed in 0.89 sec
Evaluation completed in 2.1 sec
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.99 sec
Evaluation completed in 1.1 sec
|=====================================================================================================|
| Iter | Eval   | Objective   | Objective   | BestSoFar   | BestSoFar   |  KernelScale |       Lambda |
|      | result |             | runtime     | (observed)  | (estim.)    |              |              |
|=====================================================================================================|
|    1 | Best   |     0.19672 |      108.54 |     0.19672 |     0.19672 |       1.2297 |    0.0080902 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.88 sec
Evaluation completed in 1 sec
|    2 | Accept |     0.19672 |      48.301 |     0.19672 |     0.19672 |     0.039643 |   2.5756e-05 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.83 sec
Evaluation completed in 0.95 sec
|    3 | Accept |     0.19672 |      47.758 |     0.19672 |     0.19672 |      0.02562 |   1.2555e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.83 sec
Evaluation completed in 0.95 sec
|    4 | Accept |     0.19672 |      53.626 |     0.19672 |     0.19672 |       92.644 |   1.2056e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.9 sec
Evaluation completed in 1 sec
|    5 | Best   |     0.11469 |      83.486 |     0.11469 |     0.12698 |       11.173 |   0.00024836 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.79 sec
Evaluation completed in 0.91 sec
|    6 | Best   |     0.11365 |      77.926 |     0.11365 |     0.11373 |       10.609 |   0.00025761 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|    7 | Accept |     0.19672 |      47.829 |     0.11365 |     0.11373 |    0.0059498 |   0.00043861 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.81 sec
Evaluation completed in 0.92 sec
|    8 | Accept |     0.12122 |      86.316 |     0.11365 |     0.11371 |        11.44 |   0.00045722 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.81 sec
Evaluation completed in 0.93 sec
|    9 | Best   |     0.10417 |      40.776 |     0.10417 |     0.10417 |       8.0424 |   6.7998e-05 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.84 sec
Evaluation completed in 0.96 sec
|   10 | Accept |     0.10433 |      41.187 |     0.10417 |     0.10417 |       9.6694 |   1.4948e-05 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.81 sec
Evaluation completed in 0.93 sec
|   11 | Best   |     0.10409 |      41.285 |     0.10409 |     0.10411 |       6.2099 |   6.1093e-06 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.8 sec
Evaluation completed in 0.92 sec
|   12 | Best   |     0.10383 |      43.397 |     0.10383 |     0.10404 |       5.6767 |   7.6134e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.79 sec
Evaluation completed in 0.91 sec
|   13 | Accept |     0.10408 |      43.496 |     0.10383 |     0.10365 |       8.1769 |   8.5993e-09 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.8 sec
Evaluation completed in 0.93 sec
|   14 | Accept |     0.10404 |      40.596 |     0.10383 |     0.10361 |       7.6191 |   6.4079e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.81 sec
Evaluation completed in 0.92 sec
|   15 | Best   |     0.10351 |      40.494 |     0.10351 |     0.10362 |       4.2987 |   9.2645e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.8 sec
Evaluation completed in 0.92 sec
|   16 | Accept |     0.10404 |      43.342 |     0.10351 |     0.10362 |       4.8747 |   1.7838e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.86 sec
Evaluation completed in 0.97 sec
|   17 | Accept |     0.10657 |      85.643 |     0.10351 |     0.10357 |       4.8239 |   0.00016344 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.8 sec
Evaluation completed in 0.91 sec
|   18 | Best   |     0.10299 |      40.505 |     0.10299 |     0.10358 |       3.5555 |   2.7165e-06 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.81 sec
Evaluation completed in 0.93 sec
|   19 | Accept |     0.10366 |      40.458 |     0.10299 |     0.10324 |       3.8035 |   1.3542e-06 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.8 sec
Evaluation completed in 0.92 sec
|   20 | Accept |     0.10337 |      40.697 |     0.10299 |     0.10323 |        3.806 |   1.8101e-06 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.82 sec
Evaluation completed in 0.94 sec
|=====================================================================================================|
| Iter | Eval   | Objective   | Objective   | BestSoFar   | BestSoFar   |  KernelScale |       Lambda |
|      | result |             | runtime     | (observed)  | (estim.)    |              |              |
|=====================================================================================================|
|   21 | Accept |     0.10345 |      40.482 |     0.10299 |     0.10322 |       3.3655 |    9.082e-09 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.8 sec
Evaluation completed in 0.92 sec
|   22 | Accept |     0.19672 |      59.828 |     0.10299 |     0.10322 |       999.62 |   1.2609e-06 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.85 sec
Evaluation completed in 0.97 sec
|   23 | Accept |     0.10315 |      40.397 |     0.10299 |     0.10306 |       3.6716 |   1.2445e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.3 sec
Evaluation completed in 1.4 sec
|   24 | Accept |     0.19672 |      48.555 |     0.10299 |     0.10306 |    0.0010004 |   2.6214e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.82 sec
Evaluation completed in 0.94 sec
|   25 | Accept |     0.19672 |       49.25 |     0.10299 |     0.10306 |      0.21865 |    0.0026529 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.81 sec
Evaluation completed in 0.93 sec
|   26 | Accept |     0.19672 |      60.201 |     0.10299 |     0.10306 |       299.92 |    0.0032109 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.79 sec
Evaluation completed in 0.9 sec
|   27 | Accept |     0.19672 |      47.556 |     0.10299 |     0.10306 |     0.002436 |    0.0040428 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.89 sec
Evaluation completed in 1 sec
|   28 | Accept |     0.19672 |      50.991 |     0.10299 |     0.10305 |      0.50559 |   3.3667e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.83 sec
Evaluation completed in 0.94 sec
|   29 | Accept |     0.10354 |      41.183 |     0.10299 |     0.10313 |       3.7754 |   9.5626e-09 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.86 sec
Evaluation completed in 0.97 sec
|   30 | Accept |     0.10405 |      40.938 |     0.10299 |     0.10315 |       8.9864 |   2.3136e-07 |

__________________________________________________________
Optimization completed.
MaxObjectiveEvaluations of 30 reached.
Total function evaluations: 30
Total elapsed time: 1596.4676 seconds.
Total objective function evaluation time: 1575.037

Best observed feasible point:
    KernelScale      Lambda  
    ___________    __________

      3.5555       2.7165e-06

Observed objective function value = 0.10299
Estimated objective function value = 0.10332
Function evaluation time = 40.5048

Best estimated feasible point (according to models):
    KernelScale      Lambda  
    ___________    __________

      3.6716       1.2445e-08

Estimated objective function value = 0.10315
Estimated function evaluation time = 40.9846
Mdl = 
  ClassificationKernel
            PredictorNames: {'x1'  'x2'  'x3'  'x4'  'x5'  'x6'}
              ResponseName: 'Y'
                ClassNames: [0 1]
                   Learner: 'svm'
    NumExpansionDimensions: 256
               KernelScale: 3.6716
                    Lambda: 1.2445e-08
             BoxConstraint: 665.9442


  Properties, Methods

Выполните байесовую оптимизацию при помощи bayesopt

В качестве альтернативы можно использовать bayesopt функционируйте, чтобы найти оптимальные значения гиперпараметров.

Разделите набор данных в наборы обучающих данных и наборы тестов. Задайте 1/3 выборку затяжки для набора тестов.

rng('default') % For reproducibility
tallrng('default') % For reproducibility
Partition = cvpartition(Y,'Holdout',1/3);
trainingInds = training(Partition); % Indices for the training set
testInds = test(Partition);         % Indices for the test set

Извлеките данные об обучении и тестировании и стандартизируйте данные о предикторе.

Ytrain = Y(trainingInds); % Training class labels
Xtrain = X(trainingInds,:);
[Ztrain,mu,stddev] = zscore(Xtrain); % Standardized training data

Ytest = Y(testInds); % Testing class labels
Xtest = X(testInds,:);
Ztest = (Xtest-mu)./stddev; % Standardized test data

Задайте переменные sigma и lambda найти оптимальные значения для 'KernelScale' и 'Lambda' аргументы в виде пар имя-значение. Используйте optimizableVariable и задайте широкий спектр для переменных, потому что оптимальные значения неизвестны. Примените логарифмическое преобразование к переменным, чтобы искать оптимальные значения на логарифмической шкале.

N = gather(numel(Ytrain)); % Evaluate the length of the tall training array in memory
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 0.86 sec
Evaluation completed in 1 sec
sigma = optimizableVariable('sigma',[1e-3,1e3],'Transform','log');
lambda = optimizableVariable('lambda',[(1e-3)/N, (1e3)/N],'Transform','log');

Создайте целевую функцию для Байесовой оптимизации. Целевая функция берет в таблице, которая содержит переменные sigma и lambda, и затем вычисляет значение классификации потерь для бинарной Гауссовой модели классификации ядер, обученной с помощью fitckernel функция. Установите 'Verbose',0 в fitckernel подавить итеративное отображение диагностической информации.

minfn = @(z)gather(loss(fitckernel(Ztrain,Ytrain, ...
    'KernelScale',z.sigma,'Lambda',z.lambda,'Verbose',0), ...
    Ztest,Ytest));

Оптимизируйте параметры [sigma,lambda] из модели классификации ядер относительно потери классификации при помощи bayesopt. По умолчанию, bayesopt отображает итеративную информацию об оптимизации в командной строке. Для воспроизводимости установите AcquisitionFunctionName опция к 'expected-improvement-plus'. Функция приобретения по умолчанию зависит от времени выполнения и, поэтому, может дать различные результаты.

results = bayesopt(minfn,[sigma,lambda],'AcquisitionFunctionName','expected-improvement-plus')
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|=====================================================================================================|
| Iter | Eval   | Objective   | Objective   | BestSoFar   | BestSoFar   |        sigma |       lambda |
|      | result |             | runtime     | (observed)  | (estim.)    |              |              |
|=====================================================================================================|
|    1 | Best   |     0.19651 |      83.058 |     0.19651 |     0.19651 |       1.2297 |     0.012135 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.1 sec
|    2 | Accept |     0.19651 |      110.79 |     0.19651 |     0.19651 |     0.039643 |   3.8633e-05 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.2 sec
Evaluation completed in 1.3 sec
|    3 | Accept |     0.19651 |      79.818 |     0.19651 |     0.19651 |      0.02562 |   1.8832e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|    4 | Accept |     0.19651 |      51.801 |     0.19651 |     0.19651 |       92.644 |   1.8084e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.1 sec
|    5 | Accept |     0.19651 |      51.765 |     0.19651 |     0.19651 |       978.95 |   0.00015066 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|    6 | Accept |     0.19651 |       89.56 |     0.19651 |     0.19651 |    0.0089609 |    0.0059189 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|    7 | Accept |     0.19651 |      51.515 |     0.19651 |     0.19651 |       97.709 |   0.00010771 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.1 sec
|    8 | Accept |     0.19651 |      49.878 |     0.19651 |     0.19651 |       422.03 |    4.841e-06 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|    9 | Accept |     0.19651 |      77.645 |     0.19651 |     0.19651 |    0.0012826 |   5.5116e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.1 sec
|   10 | Accept |     0.19651 |      93.166 |     0.19651 |     0.19651 |     0.031682 |   3.1742e-05 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   11 | Best   |     0.10029 |      34.959 |     0.10029 |      0.1003 |       3.9327 |   3.5022e-06 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|   12 | Accept |     0.10059 |      34.975 |     0.10029 |      0.1003 |       3.1844 |    7.385e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|   13 | Accept |     0.10098 |      37.019 |     0.10029 |     0.10031 |       5.2372 |   4.9773e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|   14 | Accept |     0.10133 |      37.468 |     0.10029 |    0.099825 |       4.2748 |    1.262e-06 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   15 | Accept |     0.10141 |      39.708 |     0.10029 |     0.10059 |       3.3388 |   2.1269e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|   16 | Accept |     0.12235 |      72.467 |     0.10029 |     0.10058 |       9.0019 |    0.0010713 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|   17 | Accept |     0.10668 |      73.693 |     0.10029 |     0.10042 |       3.6288 |   0.00063589 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   18 | Best   |     0.10016 |      37.482 |     0.10016 |     0.10058 |        4.311 |   1.2975e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   19 | Accept |     0.10034 |      37.389 |     0.10016 |     0.10001 |       3.8228 |   8.1818e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   20 | Accept |     0.10123 |      37.345 |     0.10016 |     0.10004 |       6.3387 |   1.2575e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|=====================================================================================================|
| Iter | Eval   | Objective   | Objective   | BestSoFar   | BestSoFar   |        sigma |       lambda |
|      | result |             | runtime     | (observed)  | (estim.)    |              |              |
|=====================================================================================================|
|   21 | Accept |     0.10113 |      38.547 |     0.10016 |    0.099988 |       5.1223 |   1.2705e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|   22 | Accept |     0.10041 |      38.701 |     0.10016 |     0.10006 |       3.6363 |   4.4732e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   23 | Accept |     0.10061 |      35.066 |     0.10016 |     0.10019 |       3.7705 |   2.8022e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.1 sec
|   24 | Accept |     0.10044 |      37.191 |     0.10016 |     0.10025 |       3.6538 |   3.4072e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|   25 | Accept |     0.19651 |      108.42 |     0.10016 |     0.10026 |      0.24021 |   1.3156e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   26 | Best   |     0.10016 |      37.264 |     0.10016 |     0.10024 |       3.5161 |   4.6627e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   27 | Accept |     0.16207 |      31.762 |     0.10016 |     0.10024 |       28.573 |    1.356e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   28 | Accept |     0.10036 |       37.74 |     0.10016 |     0.10025 |       3.5285 |   7.3662e-07 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1.1 sec
Evaluation completed in 1.2 sec
|   29 | Accept |     0.19651 |      84.085 |     0.10016 |     0.10025 |    0.0038154 |   1.3372e-08 |
Evaluating tall expression using the Parallel Pool 'local':
- Pass 1 of 1: Completed in 1 sec
Evaluation completed in 1.2 sec
|   30 | Accept |     0.19651 |      86.677 |     0.10016 |     0.10024 |      0.12353 |     0.012337 |

__________________________________________________________
Optimization completed.
MaxObjectiveEvaluations of 30 reached.
Total function evaluations: 30
Total elapsed time: 1821.1885 seconds.
Total objective function evaluation time: 1716.9623

Best observed feasible point:
    sigma       lambda  
    ______    __________

    3.5161    4.6627e-07

Observed objective function value = 0.10016
Estimated objective function value = 0.10027
Function evaluation time = 37.2644

Best estimated feasible point (according to models):
    sigma       lambda  
    ______    __________

    3.6538    3.4072e-07

Estimated objective function value = 0.10024
Estimated function evaluation time = 36.8542
results = 
  BayesianOptimization with properties:

                      ObjectiveFcn: @(z)gather(loss(fitckernel(Ztrain,Ytrain,'KernelScale',z.sigma,'Lambda',z.lambda,'Verbose',0),Ztest,Ytest))
              VariableDescriptions: [1×2 optimizableVariable]
                           Options: [1×1 struct]
                      MinObjective: 0.1002
                   XAtMinObjective: [1×2 table]
             MinEstimatedObjective: 0.1002
          XAtMinEstimatedObjective: [1×2 table]
           NumObjectiveEvaluations: 30
                  TotalElapsedTime: 1.8212e+03
                         NextPoint: [1×2 table]
                            XTrace: [30×2 table]
                    ObjectiveTrace: [30×1 double]
                  ConstraintsTrace: []
                     UserDataTrace: {30×1 cell}
      ObjectiveEvaluationTimeTrace: [30×1 double]
                IterationTimeTrace: [30×1 double]
                        ErrorTrace: [30×1 double]
                  FeasibilityTrace: [30×1 logical]
       FeasibilityProbabilityTrace: [30×1 double]
               IndexOfMinimumTrace: [30×1 double]
             ObjectiveMinimumTrace: [30×1 double]
    EstimatedObjectiveMinimumTrace: [30×1 double]

Возвратите лучшую допустимую точку в модели Bayesian results при помощи bestPoint функция. Используйте критерий по умолчанию min-visited-upper-confidence-interval, который определяет лучшую допустимую точку как посещаемую точку, которая минимизирует верхний доверительный интервал на значении целевой функции.

zbest = bestPoint(results)
zbest=1×2 table
    sigma       lambda  
    ______    __________

    3.6538    3.4072e-07

Таблица zbest содержит оптимальные ориентировочные стоимости для 'KernelScale' и 'Lambda' аргументы в виде пар имя-значение. Можно задать эти значения когда обучение новый оптимизированный классификатор ядра при помощи

Mdl = fitckernel(Ztrain,Ytrain,'KernelScale',zbest.sigma,'Lambda',zbest.lambda)

Для длинных массивов может занять много времени процедура оптимизации. Если набор данных является слишком большим, чтобы запустить процедуру оптимизации, можно попытаться оптимизировать параметры только при помощи частичных данных. Используйте datasample функционируйте и задайте 'Replace','false' к выборочным данным без замены.

Смотрите также

| | | | | | | |

Для просмотра документации необходимо авторизоваться на сайте