Main Content

Train Support Vector Machines Using Classification Learner App

此示例显示如何在分类学习者应用程序中构建支持向量机(SVM)分类器,使用金宝appGydF4y2Ba电离层GydF4y2Badata set that contains two classes. You can use a support vector machine (SVM) with two or more classes in Classification Learner. An SVM classifies data by finding the best hyperplane that separates all data points of one class from those of another class. In the电离层GydF4y2Ba数据,响应变量是分类的两个级别:GydF4y2BaGGydF4y2Ba代表良好的雷达回报,GydF4y2BaB.GydF4y2Barepresents bad radar returns.

  1. In MATLAB®GydF4y2Ba,加载GydF4y2Ba电离层GydF4y2Badata set and define some variables from the data set to use for a classification.

    加载GydF4y2Ba电离层GydF4y2BaIonoSphere = Array2Table(x);Ionophery.group = Y;GydF4y2Ba

    Alternatively, you can load the电离层GydF4y2Ba数据集并保持GydF4y2BaXGydF4y2BaandyGydF4y2Ba数据作为单独的变量。GydF4y2Ba

  2. 在这方面GydF4y2Ba应用GydF4y2Batab, in theMachine Learning and Deep Learning组,点击GydF4y2Ba分类Learner。GydF4y2Ba

  3. 在这方面GydF4y2Ba分类Learnertab, in theFile部分,点击GydF4y2BaNew Session > From Workspace。GydF4y2Ba

    分类学习者选项卡GydF4y2Ba

    在里面New Session from Workspace dialog box, select the table电离层GydF4y2Bafrom the数据集变量GydF4y2Ba列表。观察该应用程序基于其数据类型选择了选定的响应和预测变量。响应变量GydF4y2Ba团体GydF4y2Ba有两个级别。所有其他变量都是预测的。GydF4y2Ba

    或者,如果您保持预测的数据GydF4y2BaXGydF4y2Baand response variableyGydF4y2Ba作为两个单独的变量,您可以先选择矩阵GydF4y2BaXGydF4y2Bafrom the数据集变量GydF4y2Ba列表。Then, underResponse, click the来自工作区GydF4y2Ba选项按钮并选择GydF4y2BayGydF4y2Bafrom the list. TheyGydF4y2Bavariable is the same as the团体GydF4y2Ba多变的。GydF4y2Ba

  4. 点击GydF4y2BaStart Session。GydF4y2Ba

    分类Learner creates a scatter plot of the data.

  5. Use the scatter plot to visualize which variables are useful for predicting the response. Select different variables in the X- and Y-axis controls. Observe which variables separate the class colors most clearly.

  6. 训练选择SVM模型,在GydF4y2Ba分类Learnertab, in theModels部分,单击向下箭头以展开分类器列表,然后GydF4y2Ba金宝app支持矢量机器GydF4y2Ba, click所有SVMSGydF4y2Ba。Then, in theTrain部分,点击GydF4y2Ba训练所有GydF4y2Ba并选择GydF4y2Ba训练所有GydF4y2Ba。GydF4y2Ba

    笔记GydF4y2Ba

    • If you have Parallel Computing Toolbox™, then the app has the使用并行GydF4y2BaB.utton toggled on by default. After you click训练所有GydF4y2Ba并选择GydF4y2Ba训练所有GydF4y2BaorTrain Selected,该应用程序打开了一个平行的工人池。在此期间,您无法与软件进行互动。池开放后,您可以在并行模型列车时继续与应用程序进行交互。GydF4y2Ba

    • If you do not have Parallel Computing Toolbox, then the app has the使用背景培训GydF4y2Bacheck box in the训练所有GydF4y2Bamenu selected by default. After you click to train models, the app opens a background pool. After the pool opens, you can continue to interact with the app while models train in the background.

    分类学习者列出了图库中的每个SVM选项之一,以及默认的精细树模型。在里面GydF4y2BaModels窗格,应用程序概述了一个框中GydF4y2BaAccuracy (Validation)得分最佳模型。分类学习者还显示了第一个SVM模型的验证混淆矩阵(GydF4y2BaLinear SVM)。GydF4y2Ba

    SVM分类器建模的电离层数据的验证混淆矩阵。蓝色值表示正确的分类,红色值表示不正确的分类。GydF4y2Ba

    笔记GydF4y2Ba

    验证将一些随机性引入结果。您的模型验证结果可能因此示例中显示的结果而异。GydF4y2Ba

  7. To view the results for a model, select the model in theModels窗格,检查GydF4y2BaSummary标签。TheSummary标签显示GydF4y2Ba培训结果GydF4y2Ba在验证集上计算的指标。GydF4y2Ba

  8. 对于所选模型,请检查每个类中预测的准确性。在这方面GydF4y2Ba分类Learnertab, in the绘图GydF4y2Ba部分,单击箭头以打开图库,然后单击GydF4y2Ba混乱矩阵(验证)GydF4y2Bain theValidation Results团体。查看真实类和预测类结果的矩阵。GydF4y2Ba

  9. For each remaining model, select the model in theModels窗格,打开验证混淆矩阵,然后将结果与模型进行比较。GydF4y2Ba

  10. Choose the best model in theModelspane (the best score is highlighted in a box). To improve the model, try including different features in the model. See if you can improve the model by removing features with low predictive power.

    首先重复最好的模型。在这方面GydF4y2Ba分类Learnertab, in theModels部分,点击GydF4y2BaDuplicate。GydF4y2Ba

  11. 要调查包含或排除的功能,请使用并行坐标绘图。在这方面GydF4y2Ba分类Learnertab, in the绘图GydF4y2Ba部分,单击箭头以打开图库,然后单击GydF4y2BaParallel Coordinatesin theValidation Results团体。Keep predictors that separate classes well.

    您可以指定在模型中培训期间使用的预测器GydF4y2BaSummary标签。点击GydF4y2BaFeature Selectionto expand the section, and specify predictors to remove from the model.

  12. 或者,您可以使用特征排名算法来确定在模型训练期间使用的功能。在这方面GydF4y2Ba分类Learnertab, in the选项GydF4y2Ba部分,点击GydF4y2BaFeature Selection。在里面GydF4y2Ba默认功能选择GydF4y2Ba选项卡,指定要使用的特征排名算法。指定要保持最高排名功能的功能数量。您可以使用条形图来帮助确定要使用的功能。GydF4y2Ba

    点击GydF4y2BaSave and Apply保存更改。新功能选择应用于现有的现有模型GydF4y2BaModelspane and will be applied to new draft models that you create using the gallery in theModels部分GydF4y2Ba分类Learner标签。GydF4y2Ba

  13. 训练模型。在这方面GydF4y2Ba分类Learnertab, in theTrain部分,点击GydF4y2Ba训练所有GydF4y2Ba并选择GydF4y2BaTrain Selected使用新选项培训模型。比较分类器之间的结果GydF4y2BaModelspane.

  14. Choose the best model in theModelspane. To try to improve the model further, try changing its hyperparameters. First, duplicate the model using theDuplicate按钮在GydF4y2BaModelssection. Then, try changing a hyperparameter setting in the modelSummary标签。点击培训新模型GydF4y2Ba训练所有GydF4y2Ba并选择GydF4y2BaTrain Selectedin theTrainsection. For information on settings, see金宝app支持矢量机器GydF4y2Ba。GydF4y2Ba

  15. 您可以将培训的模型的完整或紧凑版本的版本导出到工作区。在这方面GydF4y2Ba分类Learnertab, in theExport部分,点击GydF4y2Ba出口模式GydF4y2Ba并选择任一个GydF4y2Ba出口模式GydF4y2Baor出口紧凑型号GydF4y2Ba。SeeExport Classification Model to Predict New Data。GydF4y2Ba

  16. To examine the code for training this classifier, click生成函数GydF4y2Ba。For SVM models, see also生成C代码以进行预测GydF4y2Ba。GydF4y2Ba

使用相同的工作流程来评估和比较您可以在分类学习者中培训的其他分类器类型。GydF4y2Ba

To try all the nonoptimizable classifier model presets available for your data set:

  1. 在这方面GydF4y2Ba分类Learnertab, in theModels部分,单击阿罗主持w to open the gallery of classification models.

  2. 在里面GydF4y2Ba开始GydF4y2Ba组,点击GydF4y2BaAll。Then, in theTrain部分,点击GydF4y2Ba训练所有GydF4y2Ba并选择GydF4y2Ba训练所有GydF4y2Ba。GydF4y2Ba

    Option selected for training all available classifier types

要了解其他分类器类型,请参阅GydF4y2BaTrain Classification Models in Classification Learner App。GydF4y2Ba

Related Topics