2 ML Supervised LearningClassification Models
In this chapter, we will handle the case where we have a set of predictor data on the one hand and a response variable on the other hand. However, the response variable will resonate between two or more values (i.e., categorical or discrete) rather than having continuous values. In the latter case, it will be dealt with under regression, not classification, models.
Our approach will consist of the following steps, as shown in Figure 2.1:

Figure 2.1 Typical MATLAB machine learning workflow.
- Data preparation
- Selection of algorithm
- Model fitting
- Model evaluation
- Model update
- Make predictions
Fitting Data Using Different Classification Models
We can use the function
fitc*
(replace * by the name of the classifier) to fit a classifier.
For example, the following syntax creates a k-nearest neighbor (k-NN) classification model.
>>knnModel = fitcknn(tbl,'response')
Where
knnModel: Variable containing information about the classification model
tbl: Training data, stored in a table or matrix
response: Name of the response variable stored in the input table.
Customizing a Model
Because of the prior knowledge we have about the data or after looking at the classification results, we may want to customize the classifier. We can update and customize the model by setting different options using the fitting functions.
Set the options by providing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access