Skip to content

Implementation of Average, Voted Perceptron for B003725 - Artificial Intelligence (Computer Engineering - University of Florence) Project

Notifications You must be signed in to change notification settings

ArturoViti/VotedAveragePerceptron-MNIST

Repository files navigation

Voted Peceptron & Average Perceptron

Python

Implementation of the algorithm Voted Perceptron and its variant Average on MNIST Dataset with 784 variables.

This algorithm classifies MNIST record doing a binary classification: number less of 5 and bigger or equale of 5.

Dataset and Papers

URL Title
Freund & Schapire(1999) Large Margin Classification Using the Perceptron Algorithm
MNIST_784 The MNIST database of handwritten digits with 784 features

Getting Started

Prerequisites

To run this project, is necessary have Python 3.x environment

Installation Guide

After cloning this repository, you need to install the basic dependencies to run the project on your system: pip install -r requirements.txt

You can download MNIST Dataset clicking here.

Usage

You can run this program in the following ways, using shell parameters:

  • Draw Test Error Plot in function of epochs (Figure 2 of Freund & Schapire(1999) paper with $d=1$):

    python3 main.py --drawTestErrorPlot --withAverageModel

  • Predict single record: predict the label of random record of Test Set. In this mode, script print on terminal the correct prediction, a plot of selected record and predicted label. Including --withAverageModel, it also predicts with average perceptron:

    python3 main.py --numberEpoch=100 --withAverageModel

Project Structure

  • dataSetFunctions.py: functions to load, manipolate, split and read dataset
  • parameters.py: global variable to configure dataset splitting
  • perceptronModel.py: perceptron's class with train and predictions
  • dataset/: folder with dataset
  • docs/: folder with documentation and request

Built With

  • Numpy - Fundamental package for math operations with arrays
  • Matplotlib - Package to draw result and MNIST Record
  • Argparse - Library to manage shell arguments
  • Tqdm - Package to draw and manage progress bar

About

Implementation of Average, Voted Perceptron for B003725 - Artificial Intelligence (Computer Engineering - University of Florence) Project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages