Model Building and Assessment
When you build a high-quality, predictive classification model, it is important to select the right features (or predictors) and tune hyperparameters (model parameters that are not estimated).
Feature selection and hyperparameter tuning can yield multiple models. You can compare the k-fold misclassification rates, receiver operating characteristic (ROC) curves, or confusion matrices among the models. Or, conduct a statistical test to detect whether a classification model significantly outperforms another.
To engineer new features before training a classification model, use
To build and assess classification models interactively, use the Classification Learner app.
To automatically select a model with tuned hyperparameters, use
fitcauto. This function tries a selection of classification model types with different hyperparameter values and returns a final model that is expected to perform well on new data. Use
fitcauto when you are uncertain which classifier types best suit your data.
To tune hyperparameters of a specific model, select the hyperparameter values and
cross-validate the model using those values. For example, to tune an SVM model, choose a set of
box constraints and kernel scales, and then cross-validate a model for each pair of values.
Certain Statistics and Machine Learning Toolbox™ classification functions offer automatic hyperparameter tuning through Bayesian
optimization, grid search, or random search.
bayesopt, the main function for implementing Bayesian optimization, is flexible
enough for many other applications as well. See Bayesian Optimization Workflow.
|Classification Learner||Train models to classify data using supervised machine learning|
|Univariate feature ranking for classification using chi-square tests (Since R2020a)|
|Rank features for classification using minimum redundancy maximum relevance (MRMR) algorithm (Since R2019b)|
|Feature selection using neighborhood component analysis for classification|
|Predictor importance estimates by permutation of out-of-bag predictor observations for random forest of classification trees|
|Estimates of predictor importance for classification tree|
|Estimates of predictor importance for classification ensemble of decision trees|
|Rank importance of predictors using ReliefF or RReliefF algorithm|
|Select important features for NCA classification or regression (Since R2023b)|
|Sequential feature selection using custom criterion|
Automated Model Selection
Local Interpretable Model-Agnostic Explanations (LIME)
|Local interpretable model-agnostic explanations (LIME) (Since R2020b)|
|Fit simple model of local interpretable model-agnostic explanations (LIME) (Since R2020b)|
|Plot results of local interpretable model-agnostic explanations (LIME) (Since R2020b)|
|Shapley values (Since R2021a)|
|Compute Shapley values for query point (Since R2021a)|
|Plot Shapley values (Since R2021a)|
Classification Performance Evaluation
|Create confusion matrix chart for classification problem|
|Compute confusion matrix for classification problem|
Receiver Operating Characteristic (ROC) Curve
|Receiver operating characteristic (ROC) curve and performance metrics for binary and multiclass classifiers (Since R2022a)|
|Compute additional classification performance metrics (Since R2022a)|
|Compute performance metrics for average receiver operating characteristic (ROC) curve in multiclass problem (Since R2022a)|
|Plot receiver operating characteristic (ROC) curves and other performance curves (Since R2022a)|
|Receiver operating characteristic (ROC) curve or other performance curve for classifier output|
Classification Learner App
- Train Classification Models in Classification Learner App
Workflow for training, comparing and improving classification models, including automated, manual, and parallel training.
- Visualize and Assess Classifier Performance in Classification Learner
Compare model accuracy values, visualize results by plotting class predictions, and check performance per class in the confusion matrix.
- Feature Selection and Feature Transformation Using Classification Learner App
Identify useful predictors using plots or feature ranking algorithms, select features to include, and transform features using PCA in Classification Learner.
- Introduction to Feature Selection
Learn about feature selection algorithms and explore the functions available for feature selection.
- Sequential Feature Selection
This topic introduces sequential feature selection and provides an example that selects features sequentially using a custom criterion and the
- Neighborhood Component Analysis (NCA) Feature Selection
Neighborhood component analysis (NCA) is a non-parametric method for selecting features with the goal of maximizing prediction accuracy of regression and classification algorithms.
- Tune Regularization Parameter to Detect Features Using NCA for Classification
This example shows how to tune the regularization parameter in
- Regularize Discriminant Analysis Classifier
Make a more robust and simpler model by removing predictors without compromising the predictive power of the model.
- Select Features for Classifying High-Dimensional Data
This example shows how to select features for classifying high-dimensional data.
- Automated Feature Engineering for Classification
gencfeaturesto engineer new features before training a classification model. Before making predictions on new data, apply the same feature transformations to the new data set.
Automated Model Selection
- Automated Classifier Selection with Bayesian and ASHA Optimization
fitcautoto automatically try a selection of classification model types with different hyperparameter values, given training predictor and response data.
- Bayesian Optimization Workflow
Perform Bayesian optimization using a fit function or by calling
- Variables for a Bayesian Optimization
Create variables for Bayesian optimization.
- Bayesian Optimization Objective Functions
Create the objective function for Bayesian optimization.
- Constraints in Bayesian Optimization
Set different types of constraints for Bayesian optimization.
- Optimize Cross-Validated Classifier Using bayesopt
Minimize cross-validation loss using Bayesian Optimization.
- Optimize Classifier Fit Using Bayesian Optimization
Minimize cross-validation loss using the
OptimizeParametersname-value argument in a fitting function.
- Bayesian Optimization Plot Functions
Visually monitor a Bayesian optimization.
- Bayesian Optimization Output Functions
Monitor a Bayesian optimization.
- Bayesian Optimization Algorithm
Understand the underlying algorithms for Bayesian optimization.
- Parallel Bayesian Optimization
How Bayesian optimization works in parallel.
- Implement Cross-Validation Using Parallel Computing
Speed up cross-validation using parallel computing.