Code Monkey home page Code Monkey logo

williamd4112 / simple-linear-classification Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 2.0 7.38 MB

A python implementation of linear classification algorithm (including Probabilistic Generative Model, Probabilistic Discriminative Model). (See Pattern Recognition and Machine Learning, Bishop)

License: MIT License

Python 80.95% Shell 19.05%
machine-learning artificial-intelligence regression logistic-regression softmax-regression classification bishop lda pca probabilistic-generative-model

simple-linear-classification's Introduction

Introduction

This project is implementation of Probabilistic Generative Model and Probabilistic Discriminative Model for multi-class classification. (see Pattern Recognition and Machine Learning, Bishop 2006) Classifcation task can be splitted into two stages - inference and decision. Probabilistic Generative Model solve class posteriror via solving class conditional probabilities and class priors. Probabilistic Discriminative Model solve directly optimize linear combination weight with Iterative Reweighted Least Squares (IRLS) - Newton-Raphson to find class posteriror. All datas are processed with Principle Component Analysis (PCA) or Linear Discriminant Analysis (LDA).

Dependencies

  • numpy v1.12
  • tqdm
  • OpenCV

Dataset

Database of Faces ( AT&T Laboratories Cambridge)
Reference : http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html

Results

Best error rate of each model

Probabilistic Generative Model Probabilistic Discriminative Model
0.025 0.0

Visualization (Decision boundary)

Probabilistic Generative Model Probabilistic Discriminative Model
gen dis

To train the model (examples)

Training scripts use default training data in data/class*.npy and default training hyperparameters. If you want to use your own data, please see the manual of main.py

./train_generative.sh {model output path}
./train_dicriminative.sh {model output path}
./train_dicriminative_lda.sh {model output path}

To validate the model (examples)

./validate_generative.sh
./validate_dicriminative.sh 
./validate_dicriminative_lda.sh 

To test the model (examples)

./test.sh {model input} {result output} {testing data} {model type [dis|gen]}

e.g.
./test.sh model/model-dis data/class1.npy,data/class2.npy,data/class3.npy dis

To run demo

./demo.sh {model input} {model type [dis|gen]}

e.g.
./demo.sh model/model-dis dis

[04/11/2017 02:06:24 AM] Convert images at ./Demo to data/demo.npy
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 600/600 [00:00<00:00, 76795.31it/s]
Demo images convertion done
[04/11/2017 02:06:24 AM] Load 600 data from ./data/demo.npy
[04/11/2017 02:06:24 AM] Loading stddev from model/model-dis_std.npy ...
[04/11/2017 02:06:24 AM] Loading basis from model/model-dis_basis.npy ...
[04/11/2017 02:06:24 AM] Loading model from model/model-dis.npy success [K = 3, M = 3]
[04/11/2017 02:06:24 AM] Use model dis with 3-dim (with bias) feautre space
[04/11/2017 02:06:24 AM] Converting to one-hot ...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 600/600 [00:00<00:00, 908841.60it/s]
[04/11/2017 02:06:24 AM] Writing result to ./result/DemoTarget.csv ...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 600/600 [00:00<00:00, 263848.02it/s]

simple-linear-classification's People

Contributors

williamd4112 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.