Basic Classification using MATLAB
Itachi443
MATLAB is a high-level language and interactive environment for numerical computation, visualization, and programming. Using MATLAB, we will analyse data, develop algorithms, and create models and applications.
The Fisher's Iris data set is a multivariate data set introduced by Sir Ronald Fisher (1936) as an example of discriminant analysis. It is sometimes called Anderson's Iris data set because Edgar Anderson collected the data to quantify the morphologic variation of Iris flowers of three related species.
We will use MATLAB software to classify the Fisher's IRIS dataset and then will get into detail of this code line by line
Preview
Getting into detail of this code
First line was
What this line does?
Loads inbuilt Fisher's iris data into workspace as a collection of matrix(meas) with dimension 150x4 and vector(species) with dimension 150x1

Second line was
What this line does?
Creates a scatter plot of
Third line
What this line does?
Adds label to the graph, xlabel adds label to x-axis and ylabel adds label to y-axis.
The Fisher's Iris data set is a multivariate data set introduced by Sir Ronald Fisher (1936) as an example of discriminant analysis. It is sometimes called Anderson's Iris data set because Edgar Anderson collected the data to quantify the morphologic variation of Iris flowers of three related species.
We will use MATLAB software to classify the Fisher's IRIS dataset and then will get into detail of this code line by line
Preview
load fisheriris;
gscatter(meas(:,1), meas(:,2), species,'rgb','osd');
xlabel('Sepal length');
ylabel('Sepal width');
Outputgscatter(meas(:,1), meas(:,2), species,'rgb','osd');
xlabel('Sepal length');
ylabel('Sepal width');
Getting into detail of this code
First line was
load fisheriris;
What this line does?
Loads inbuilt Fisher's iris data into workspace as a collection of matrix(meas) with dimension 150x4 and vector(species) with dimension 150x1

Second line was
gscatter(meas(:,1), meas(:,2), species,'rgb','osd');
What this line does?
Creates a scatter plot of
- meas(:,1) [column1 from meas matrix]
- meas(:,2) [column2 from meas matrix]
Third line
xlabel('Sepal length');
ylabel('Sepal width');
ylabel('Sepal width');
What this line does?
Adds label to the graph, xlabel adds label to x-axis and ylabel adds label to y-axis.
21:56
Code
Basic Supervised Learning Algorithm
Itachi443
Discriminant function analysis is a statistical analysis to predict a categorical dependent variable (called a grouping variable) by one or more continuous or binary independent variables (called predictor variables). Discriminant analysis works by creating one or more linear combinations of predictors, creating a new latent variable for each function. These functions are called discriminant functions. - Wikipedia.
![]() |
| Supervised Learning |
Steps to predict the class:
- For given test samples extract vector f.
- Evaluate Di(f) for 1 ≤ i ≤ k.
- The class which is predicted is the class with highest D(f) value.
Let us see small pseudo-code for taking decision and applying learning rule
Initialize the coefficients randomly.
while( ! converged ){
for every training sample{
predict class ( say j )
let actual class j'
if(j==j')
Do Nothing
else
apply learning rule and increment error
}
check for convergence
}
while( ! converged ){
for every training sample{
predict class ( say j )
let actual class j'
if(j==j')
Do Nothing
else
apply learning rule and increment error
}
check for convergence
}
Let us see simple MATLAB code to classify the flowers in IRIS dataset
load fisheriris;
gscatter(meas(:,1), meas(:,2), species,'rgb','osd');
xlabel('Sepal length');
ylabel('Sepal width');
We'll explore the code in other tutorial (Basic Classification using MATLAB). gscatter(meas(:,1), meas(:,2), species,'rgb','osd');
xlabel('Sepal length');
ylabel('Sepal width');
The output of this MATLAB code shows how the data from dataset is classified as different flowers.
07:53
Supervised Learning
Subscribe to:
Posts
(
Atom
)



