Git Product home page Git Product logo

pegasos's Introduction

pegasos

pegasos is a pure-python package for fitting SVM and logistic models using the Primal Estimated sub-GrAdient SOlver. This implementation is based on the google tool sofia-ml. The package has an sklearn-like interface so can easily be used with existing sklearn functionality. At each training step, the pegasos solver randomly samples a batch from the training data. The runtime of the training algorithm scales linearly with the regularization parameter lambda and the number of training steps; as such the model is well suited to large datasets. For details on the training algorithm see:

http://eprints.pascal-network.org/archive/00004062/01/ShalevSiSr07.pdf

API support

  • sparse or dense matrix support
  • binary classification (multiclass via sklearn.multiclass)
  • balanced class weightings via training loops
  • probabilistic predictions for logistic model
  • model serialisation via cPickle

See example.py for how to use the library.

speed

There are benchmarks against sklearn's SGDClassifier in the benchmarks folder.

samples   pegasos  liblinear  libsvm
------------------------------------
10^4      4.08     0.55       10.42
10^5      4.09     17.35      2638.62
10^6      4.63     230.71     *
10^7      6.87     3318.32    *

* libsvm times are missing because the models converge sometime around the heat-death of the universe

The near-constant training time of pegasos is due to the constant number of training steps. For larger datasets the number of iterations should be increased. A grid-search on the lambda regularization parameter may also be benifical. The accuracy of the classifiers is generally ordered as libsvm > liblinear > pegasos but the differences are only 0.5-1%

Note that training time will increase by a constant amount for sparse matrices

build

Requirements are:

  • scikit-learn >= 0.13.1
  • numpy >= 1.7.1
  • scipy >= 0.10.1

and nose for tests:

python setup.py nosetests

todo

  • more tests
  • training batches (with online learning)

pegasos's People

Contributors

ejlb avatar

Watchers

James Cloos 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.