Classification
Example of classification using the Iris Dataset
Dataset cleaned: Yes
Dataset name: iris_dataset.csv
Dataset link: here
Sepal Length Sepal Width Petal Length Petal Width Species
5.1 3.5 1.4 0.2 Iris-setosa
4.9 3.0 1.4 0.2 Iris-setosa
4.7 3.2 1.3 0.2 Iris-setosa
4.6 3.1 1.5 0.2 Iris-setosa
5.0 3.6 1.4 0.2 Iris-setosa
Sepal Length Sepal Width Petal Length Petal Width
count 150.00 150.00 150.00 150.00
mean 5.84 3.06 3.76 1.20
std 0.83 0.44 1.77 0.76
min 4.30 2.00 1.00 0.10
25% 5.10 2.80 1.60 0.30
50% 5.80 3.00 4.35 1.30
75% 6.40 3.30 5.10 1.80
max 7.90 4.40 6.90 2.50
Classes distribution
Num. element per class Species
Iris-setosa 50
Iris-versicolor 50
Iris-virginica 50
Relationship between Sepal Length and Width
Logistic Regression



Logistic Regression:
Training Accuracy: 1.0
  • Binary Classification: Logistic regression is used for binary classification problems.
  • Logistic Function: It uses the logistic (sigmoid) function to estimate the probability of belonging to a class.
  • Decision Boundary: Logistic regression determines a threshold-based decision boundary to classify inputs.
Confusion Matrix:
Predicted label 1 2 3
True label
1 10 0 0
2 0 9 0
3 0 0 11
Decision Tree Classifier:
Training Accuracy: 1.0
  • Multiple Classification: Decision tree classifiers can handle both binary and multi-class classification problems.
  • Splitting Criteria: Decision trees split the data based on different criteria, such as Gini impurity or information gain, to create homogeneous child nodes.
  • Decision Rules: Decision trees create decision rules based on the features' values, allowing for easy interpretation and understanding of the classification process.
Confusion Matrix:
Predicted label 1 2 3
True label
1 10 0 0
2 0 9 0
3 0 0 11
Support Vector Machine:
Training Accuracy: 1.0
  • Binary and Multiclass Classification: Support Vector Machines can be used for both binary and multiclass classification tasks.
  • Maximum Margin: SVM aims to find the decision boundary that maximizes the margin between the classes, promoting better generalization.
  • Kernel Trick: SVM can utilize the kernel trick to transform the input space, allowing for nonlinear decision boundaries.
Confusion Matrix:
Predicted label 1 2 3
True label
1 10 0 0
2 0 9 0
3 0 0 11
K-nearest neighbors:
Training Accuracy: 1.0
  • Instance-Based Classification: KNN is an instance-based classification algorithm that assigns a class label to a new instance based on its similarity to the k nearest neighbors in the training data.
  • Distance Metric: KNN relies on a distance metric, such as Euclidean distance, to measure the similarity between instances and determine their neighbors.
  • K Parameter: The value of k in KNN represents the number of neighbors considered in the classification decision. It is an important parameter that affects the model's bias-variance trade-off.
Confusion Matrix:
Predicted label 1 2 3
True label
1 10 0 0
2 0 9 0
3 0 0 11