Skip to content

I implemented the perceptron learning algorithm to differentiate between Thai currency, specifically Thai coins.

Notifications You must be signed in to change notification settings

nps6-uwf/perceptron-THB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

perceptron-THB

Overview

Using the perceptron learning algorithm to differentiate between Thai currency, specifically Thai coins: (เหรียญ riianR).

This repository contains two files:

  1. perceptron_THB.py- Implentation of the perceptron classifcation algorithm and perceptron learning algorithm from scratch. This file does the testing and training.
  2. THB_data.py - Creates an artificial data set using the specifications of Thai coins.

Data

specs = { "1 satang": { "diameter": 15, # mm "mass": 0.5 # g }, "5 satang": { "diameter": 16, # mm "mass": 0.6 # g }, "10 satang": { "diameter": 17.5, # mm "mass": 0.8 # g }, "25 satang": { "diameter": 16, # mm "mass": 1.9 # g }, "50 satang": { "diameter": 18, # mm "mass": 2.4 # g }, "1 baht": { "diameter": 20, # mm "mass": 3 # g }, "2 baht": { "diameter": 21.75, # mm "mass": 4 # g }, "5 baht": { "diameter": 24, # mm "mass": 6 # g }, "10 baht": { "diameter": 26, # mm "mass": 8.5 # g } }

Artificial data is generated by the THB_data.py file. This file contains two importable methods:

  1. gen_dataset- Genrates an artificial dataset by randomly selecting two coins from the specs dictionary shown above, introduces random error to the diameter and mass of each coin, generates an N length sample.
  2. plot_data - Use matplotlib library to create simple data visualization.

Results

The more error I introduce into the dataset, the more interesting the results become. The separating hyperplane is rather obvious without error.

Sample output after running "perceptron-THB.py":

Using perceptron to classify['1 satang', '50 satang']
Weights[ 11. 3.56406557 -63.21304217]
Misclassifications:0
Found a separating hyperplace in:968 iterations
Accuracy:100.00%

Conclusions/ Improvements

  • The algorithm is only capable of binary classifcation which is kind of boring in this case because there are much more than 2 THai coins.
  • No consideration was made on finding the optimal hyperplane.
  • It might be interesting to add a parameter to the perceptron learning algorithm "allowed_misclassifcations", this will allow more leniency.
  • Add hyperparameter "learning rate" to PLA

About

I implemented the perceptron learning algorithm to differentiate between Thai currency, specifically Thai coins.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages