Primal SVM

Python2
5
0.1.3

Files

Loading...

Readme.md

Primal SVM implementation in python

This project is python port of Matlab Primal SVM - fast linear Primal SVM implementation by Olivier Chapelle

The main advantage is that it can handle realy big datasets eficiently in terms of seconds rather than days.

There are two solvers implemented:

  • Newton method solver - Newton solver is better suited for problems with large number of examples (>1M) but small dimension (less than 1000)
  • Conjugate Gradient solver - better for large and sparse problems

How to use

The api is very simple, if you work with scikit-leran you won't have any trouble

mnist = fetch_mldata('MNIST original', data_home='./')

# data field is 70k x 784 array, each row represents pixels from 28x28=784 image
images = mnist.data
targets = mnist.target

psvm = lsvm.PrimalSVM(l2reg=0.1)
start_time = dt.datetime.now()
print('Start learning at {}'.format(str(start_time)))
psvm.fit(X_train, y_train)
end_time = dt.datetime.now() 
print('Stop learning {}'.format(str(end_time)))
elapsed_time= end_time - start_time
print('Elapsed learning {}'.format(str(elapsed_time)))

Examples

Project containse two simple examples:

  • iris dataset classification
  • mnist handwritten image classification

Code

Changelog

  • [2017-06-05 09:53:15] v0.1.3: Update Readme, change image internals.

[2016-5-4 22:0] v0.1.2 - Update readme, add github reference [2016-5-4 21:59] v0.1.1 - first version, implemented only newton solver