Main Content

本页的翻译已过时。点击此处可查看最新英文版本。

模型的构建和评估

特征选择、特色工程、模型选择、超参数优化、交叉验证、预测性能评估和分类准确性比较检验

在构建高质量预测分类模型时,选择正确的特征(或预测变量)并调整超参数(未估计的模型参数)非常重要。

特征选择和超参数调整可能会产生多个模型。您可以比较模型之间的 k 折分类错误率、受试者工作特征 (ROC) 曲线或混淆矩阵。还可以进行统计检验,以检测一个分类模型是否明显优于另一个。

要在训练分类模型之前对新函数进行工程处理,请使用 gencfeatures

要以交互方式构建和评估分类模型,可以使用分类学习器

要自动选择具有调整后的超参数的模型,请使用 fitcauto。此函数尝试选择具有不同超参数值的分类模型类型,并返回预期在新数据上表现良好的最终模型。当您不确定哪些分类器类型最适合您的数据时,请使用 fitcauto

要调整特定模型的超参数,请选择超参数值并使用这些值对模型进行交叉验证。例如,要调整 SVM 模型,可以选择一组框约束和核尺度,然后使用每对值对模型进行交叉验证。某些 Statistics and Machine Learning Toolbox™ 分类函数通过贝叶斯优化、网格搜索或随机搜索提供自动超参数调整。实现贝叶斯优化的主函数 bayesopt 对于许多其他应用来说也足够灵活。请参阅Bayesian Optimization Workflow

要解释分类模型,您可以使用 limeshapleyplotPartialDependence

App

分类学习器使用有监督的机器学习训练模型以对数据进行分类

函数

全部展开

fscchi2Univariate feature ranking for classification using chi-square tests
fscmrmrRank features for classification using minimum redundancy maximum relevance (MRMR) algorithm
fscncaFeature selection using neighborhood component analysis for classification
oobPermutedPredictorImportancePredictor importance estimates by permutation of out-of-bag predictor observations for random forest of classification trees
predictorImportanceEstimates of predictor importance for classification tree
predictorImportanceEstimates of predictor importance for classification ensemble of decision trees
sequentialfsSequential feature selection using custom criterion
relieffRank importance of predictors using ReliefF or RReliefF algorithm
gencfeaturesPerform automated feature engineering for classification
describeDescribe generated features
transformTransform new data using generated features
fitcautoAutomatically select classification model with optimized hyperparameters
bayesoptSelect optimal machine learning hyperparameters using Bayesian optimization
hyperparametersVariable descriptions for optimizing a fit function
optimizableVariableVariable description for bayesopt or other optimizers
crossvalEstimate loss using cross-validation
cvpartitionPartition data for cross-validation
repartitionRepartition data for cross-validation
testTest indices for cross-validation
trainingTraining indices for cross-validation

与模型无关的局部可解释性解释 (LIME)

limeLocal interpretable model-agnostic explanations (LIME)
fitFit simple model of local interpretable model-agnostic explanations (LIME)
plotPlot results of local interpretable model-agnostic explanations (LIME)

Shapley 值

shapleyShapley values
fitCompute Shapley values for query point
plotPlot Shapley values

部分依赖

partialDependenceCompute partial dependence
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
confusionchartCreate confusion matrix chart for classification problem
confusionmatCompute confusion matrix for classification problem
perfcurveReceiver operating characteristic (ROC) curve or other performance curve for classifier output
testcholdoutCompare predictive accuracies of two classification models
testckfoldCompare accuracies of two classification models by repeated cross-validation

对象

全部展开

FeatureSelectionNCAClassificationFeature selection for classification using neighborhood component analysis (NCA)
FeatureTransformerGenerated feature transformations
BayesianOptimizationBayesian optimization results

主题

分类学习器

特征选择

特征工程

自动模型选择

超参数优化

模型解释

交叉验证

分类性能计算