主要内容

在回归学习者应用中使用超参数优化的火车回归模型

此示例显示了如何通过在回归学习者应用程序中使用超参数优化来调整回归集合的超参数。比较受过训练的优化集合的测试集性能与表现最好的预设合奏模型的测试集。

  1. 在matlab中®Command Window, load thecarbigdata set, and create a table containing most of the variables.

    loadcarbigcartable =表(加速度,气缸,位移,。。。Horsepower,Model_Year,Weight,Origin,MPG);
  2. 开放回归学习者。点击Apps标签,然后单击右侧的箭头Apps部分打开应用程序画廊。在里面机器学习和深度学习group, click回归学习者

  3. 回归学习者标签,在文件section, select新会话>来自工作区

  4. 在里面New Session from Workspace dialog box, selectcartable来自Data Set Variablelist. The app selects the response and predictor variables. The default response variable isMPG。The default validation option is 5-fold cross-validation, to protect against overfitting.

    在里面Test部分,单击“复选框”框以列出测试数据集。指定使用15percent of the imported data as a test set.

    New Session from Workspace dialog box with 15 percent of the imported data set aside for testing

  5. 要接受选项并继续,请单击开始会话

  6. 训练所有预设合奏模型。在回归学习者标签,在Modelssection, click the arrow to open the gallery. In the树木的合奏group, click所有合奏。在里面Trainsection, clickTrain Alland selectTrain All。The app trains one of each ensemble model type, as well as the default fine tree model, and displays the models in theModels窗格。

    Note

    • 如果您具有并行计算工具箱™,则该应用具有Use Parallel按钮默认打开。点击之后Train Alland selectTrain All或者选择火车应用程序打开一个并行池of workers. During this time, you cannot interact with the software. After the pool opens, you can continue to interact with the app while models train in parallel.

    • 如果您没有并行计算工具箱,则该应用具有Use Background Training复选框Train All默认选择菜单。单击训练型号后,该应用将打开一个背景池。池打开后,您可以在模型在后台训练时继续与应用程序进行交互。

    Response plot of the car data modeled by a boosted trees ensemble model

    这个应用程序显示一个response plot for the first ensemble model (model 2.1). Blue points are true values, and yellow points are predicted values. TheModels左侧的窗格显示了每个模型的验证RMSE。

    Note

    Validation introduces some randomness into the results. Your model validation results can vary from the results shown in this example.

  7. Select an optimizable ensemble model to train. On the回归学习者标签,在Modelssection, click the arrow to open the gallery. In the树木的合奏group, clickOptimizable Ensemble

  8. Select the model hyperparameters to optimize. In the概括tab, you can select优化check boxes for the hyperparameters that you want to optimize. By default, all the check boxes are selected. For this example, accept the default selections.

    摘要选项卡与合奏超参数选择进行优化

  9. 训练优化模型。在里面Trainsection of the回归学习者tab, clickTrain Alland select选择火车

  10. 这个应用程序显示一个最小MSE图在运行优化过程时。在每次迭代中,该应用程序都会尝试使用高参数值的不同组合,并通过观察到该迭代的最小验证平方误差(MSE)更新图,以深蓝色指示。当应用完成优化过程时,它选择了由红色正方形指示的优化超参数集。有关更多信息,请参阅最小MSE图

    The app lists the optimized hyperparameters in both the优化结果情节右侧的部分优化的合奏模型超参数模型部分概括tab.

    Minimum MSE plot for the optimizable ensemble model

    Note

    In general, the optimization results are not reproducible.

  11. Compare the trained preset ensemble models to the trained optimizable model. In theModelspane, the app highlights the lowestRMSE(验证)(validation root mean squared error) by outlining it in a box. In this example, the trained optimizable ensemble outperforms the two preset models.

    受过训练的优化模型并不总是比受过训练的预设模型低。如果训练有素的优化模型表现不佳,则可以通过运行更长的优化来尝试获得更好的结果。在回归学习者标签,在Optionssection, click优化r。在对话框中,增加Iterationsvalue. For example, you can double-click the default value of30并输入一个值60。Then click保存并申请。The options will be applied to future optimizable models created using theModelsgallery.

  12. Because hyperparameter tuning often leads to overfitted models, check the performance of the optimizable ensemble model on a test set and compare it to the performance of the best preset ensemble model. Use the data you reserved for testing when you imported data into the app.

    首先,在Modelspane, click the star icons next to theBagged Treesmodel and theOptimizable Ensemblemodel.

  13. For each model, select the model in theModels窗格。在里面Testsection of the回归学习者tab, clickTest All然后选择选择测试。The app computes the test set performance of the model trained on the rest of the data, namely the training and validation data.

  14. 根据测试集RMSE对模型进行排序。在里面Modelspane, open the排序方式list and selectRMSE(测试)

    In this example, the trained optimizable ensemble does not perform as well as the trained preset model on the test set data. Unfortunately, neither model has a test set RMSE that is as low as its validation RMSE.

    Trained models sorted by test RMSE

相关话题