Machine Learning Coding Tutorial 5. Build Our Own Classifier

In this tutorial, we are going to write machine learning program with our own classifier.

1. Steps

First, we need to create a classifier class ScrappyKNN.

Inside ScrappyKNN class, we will have fit and predict functions.

In the example, naive_predict is using a random guess approach to make predictions. closet_predict is using closet distance approach to make predictions.

2. Coding

Let’s head into Python for a programmatic example.

Create a python file classifier.py and write following code to program.

Please read comments carefully to understand the meaning of codes.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *