Giter Site home page Giter Site logo

knn-mnist's Introduction

mnistConverter and KNN

mnistConverter converts the datas from MNIST database of handwritten digits from bin to txt and png.

convert2txt.py converts the 't10k-images-idx3-ubyte' or 'train-images-idx3-ubyte' from bin to txt. It generates a series of 28*28 matrixes and write them to data.txt. Modify a few parameters to generate the quantity you want. It can be used to generate both training set and test set.

convert2pic.py converts the 't10k-images-idx3-ubyte' or 'train-images-idx3-ubyte' from bin to png. I just add a matplotlib module and use the matrixes to plot the figures and save them in ./trainSet/pic or ./testSet/pic. It can be used to generate both training set and test set.

convert2num.py converts the 't10k-labels-idx1-ubyte' or 'train-labels-idx1-ubyte' from bin to txt, which contains the labels of figures.

KNN finds the k nearest neighbors and then the test sample is assigned to the class most common among its k nearest neighbors.

The function knn requires one argument k to determine how many nearest neighbors you need. If you run the run.py, wait a few seconds and there it will show you a random test sample in png and print the predicted label.

knn-mnist's People

Watchers

James Cloos avatar  avatar

Forkers

lonelam

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.