# Classification

This category groups posts on classification models. Each post focuses on a specific algorithm. The emphasis is on understanding how these models actually work at a technical level. Here you will learn to build classification models in Python from scratch.

## Explaining the Gini Impurity with Examples in Python

Explaining the Gini Impurity with Examples in Python What is the Gini Impurity? The Gini Impurity is a loss function that describes the likelihood of misclassification for a single sample, according to the distribution of a certain set of labelled data. It is typically used within Decision Trees. More specifically, the Gini Impurity is used …

## Implement the KNN Algorithm in Python from Scratch

Implement the KNN Algorithm in Python from Scratch What is the KNN Algorithm? K Nearest Neighbours (KNN) is a supervised machine learning algorithm that makes predictions based on the ‘closest‘ training data points to our point of interest, in data space. We evaluate the closest data points through the use of a distance metric, of …

## A Complete Introduction to Cross Validation in Machine Learning

A Complete Introduction to Cross Validation in Machine Learning What is Cross Validation? A natural question to ask, when building any predictive model, is how good are the predictions? Having a clear, quantitative measure for the expected model performance, is a key element to any machine learning project.   Cross validation is a family of …

## Understanding the Adaboost Classification Algorithm

Understanding the Adaboost Classification Algorithm Motivation: What is a Adaboost Classifier? In this post, we will describe the Adaboost classification algorithm. We will start with the basic assumptions and mathematical foundations of this algorithm, and work straight through to an implementation in Python from scratch. Adaboost stands for “Adaptive Boosting”, and this was the first boosting technique …

## Introduction to Simple Boosting Classification in Python

Introduction to Simple Boosting Classification in Python Motivation for Boosting Classification This post will consist of a simple introduction to boosting classification in Python. In my previous article, I introduced boosting with a basic regression algorithm. Here, we will adapt that procedure to handle classification problems. Boosting is a popular ensemble technique, and forms the …

## 6 Methods to Measure Performance of a Classification Model

6 Methods to Measure Performance of a Classification Model How do we Measure Performance of a Classification Model? In this post, we will cover how to measure performance of a classification model. Classification is one of the most common tasks in machine learning. This is the case where the dependent variable only has discrete values. …

## Build a Random Forest in Python from Scratch

Build a Random Forest in Python from Scratch Motivation to Build a Random Forest Model For this post, we will Build a Random Forest in Python from scratch. I will include examples in classification and regression. Bagging ensembles are an approach to reduce variance, and thereby increase model performance. In this algorithm, multiple weak learner models produce predictions …

## Build a Bagging Classifier in Python from Scratch

Build a Bagging Classifier in Python from Scratch Motivation to Build a Bagging Classifier In this article, we will build a bagging classifier in Python from the ground-up. Through this exercise it is hoped that you will gain a deep intuition for how bagging works.  We saw in a previous post that the bootstrap method was …

## Build a Decision Tree in Python from Scratch

Build a Decision Tree in Python from Scratch Motivation to Build a Decision Tree Model In this post, we will build a Decision Tree model in Python from scratch. Both classification and regression examples will be included. Decision trees comprise a family of non-parametric1 supervised learning models that are based upon simple boolean decision rules to …

## Build a Logistic Regression Classifier in Python from Scratch

Build a Logistic Regression Classifier in Python from Scratch Motivation to Build a Logistic Regression Classifier For this post, we will build a logistic regression classifier in Python. We will start from first principles, and work straight through to code implementation.  The problem of predicting a categorical variable is generally termed as classification.  Classification is …