Skip to main content

No project description provided

Project description

lisbon

Release

lisbon aims to be a drop-in replacement for liblinear which scikit-learn leaverages for linear classification problems, currently only supports L2-regularised hinge loss for binary classification by solving the dual problem (routine 3). The APIs follow scikit-learn's liblinear wrapper and importing the Python library will monkey-patch scikit-learn's svm library to use lisbon for the supported calculation.

from sklearn import svm
import lisbon

and the following computations will use lisbon if supported. To switch back lisbon.unload() will swap back the original fit function.

Please see lisbon/__init__.py to see how the runtime patching is done and bench.py for an example.

Install from source if your platform does not support AVX2 instruction set as the PyPI packaged version assumes AVX2 support.

Installation

Install from PyPI

pip install lisbon

Install from source

  • Make sure you have the Rust toolchain rustc, cargo, rust-std installed. The quickest way to do it is curl https://sh.rustup.rs -sSf | sh -s
    • For a minimal installation: curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal
  • With your desired Python environment, pip install maturin
  • Clone this repository and from lisbon's project root, run RUSTFLAGS='-C target-cpu=native' maturin develop --release will install lisbon as a package to your Python environment
    • Note that the RUSTFLAGS='-C target-cpu=native' environmental variable ensures that rustc compiles against your CPU's supported instruction sets to enable more SIMD optimisations (e.g. AVX2, FMA).
  • For dev/benchmark purposes, consider installing the packages listed in requirements-dev.txt

For Windows

To set the rustc flags on windows with powershell:

$Env:RUSTFLAGS = "-C target-cpu=native"
maturin develop --release

Limitations

lisbon's speed up comes from vector instruction sets hence some platforms are not supported if not built from source.

Currently, lisbon only supports L2 regularised hinge loss and does not support

  1. sample weights
  2. class weights
  3. different penalty C for labels
  4. multiclass classification

Deviations from the source implementation

  1. As with scikit-learn's modification, the order of labels are flipped to be consistent with the rest of the scikit-learn family
    • liblinear uses [+1, -1] ordering
    • scikit-learn uses [-1, +1] ordering
  2. Uses a MT19937 + tweaked Lemire post-processor to generate a random number within range

Why is lisbon faster

  • liblinear uses sparse matrix representation for the dot/norm operations, so scikit-learn needs to convert the dense numpy matrix to sparse first then pass to liblinear. lisbon uses the dense matrix directly as sparse represented data can be inefficient and prevents some SIMD optimisations.
  • By reading the numpy C array directly underneath there’s no need to copy/duplicate data which saves memory.
  • Specialised. Some array reads and computations are optimised away as we know what the values are for the L2-regularised hinge loss binary classification routine.

Ref

  1. 2-norm
  2. A Dual Coordinate Descent Method for Large-scale Linear SVM

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in lisbon by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lisbon-0.1.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distributions

lisbon-0.1.0-cp310-none-win_amd64.whl (127.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

lisbon-0.1.0-cp310-cp310-manylinux_2_24_x86_64.whl (187.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.24+ x86-64

lisbon-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl (176.0 kB view details)

Uploaded CPython 3.10 macOS 10.7+ x86-64

lisbon-0.1.0-cp39-none-win_amd64.whl (127.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

lisbon-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl (187.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

lisbon-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl (176.1 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

lisbon-0.1.0-cp38-none-win_amd64.whl (128.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

lisbon-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl (187.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64

lisbon-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl (175.9 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

lisbon-0.1.0-cp37-none-win_amd64.whl (127.9 kB view details)

Uploaded CPython 3.7 Windows x86-64

lisbon-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl (187.3 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.24+ x86-64

lisbon-0.1.0-cp37-cp37m-macosx_10_7_x86_64.whl (175.5 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

lisbon-0.1.0-cp36-none-win_amd64.whl (127.7 kB view details)

Uploaded CPython 3.6 Windows x86-64

lisbon-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl (186.9 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.24+ x86-64

lisbon-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl (176.0 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

Details for the file lisbon-0.1.0.tar.gz.

File metadata

  • Download URL: lisbon-0.1.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.5

File hashes

Hashes for lisbon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e1faa24f275b50428faea8b758f2bf648db787f51edecc18e82a35e77e51d404
MD5 4be855cce0867a3cb6a7e33fec06936b
BLAKE2b-256 199b627e46d2f6201974107937126cfc079dc56ff7b0dcb202f96f2bc22f5570

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp310-none-win_amd64.whl.

File metadata

  • Download URL: lisbon-0.1.0-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 127.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.5

File hashes

Hashes for lisbon-0.1.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 6881fb2b3eab5ddc4e4c9b53e037593f857e62e46d230fdbebc322f5df7ffb76
MD5 f864675fdc562679f4a26346134a63ac
BLAKE2b-256 82e6f0a9f411574ef461768d9f71e301302101937ca0ac88773ec5870dfb7c49

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp310-cp310-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 83f2b5ea87dfb4a2fe4140c264bb70c34ca6bcc6dd3716523ae1dd4e6b8d2bba
MD5 aed2c1d57c959752105f705f48823747
BLAKE2b-256 ce0ac914840d1b2cc0e7e44bdfff004f2a1da2a52aba348601224d1a633da542

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 2ce4188cab9c60a0e5953dfbdebb60ea970beaec837e448e714c358b6a70a379
MD5 5d529dd29fdd295c4bfe1fa16f7aab39
BLAKE2b-256 066223d9e05ee229a4ac0103dea60a8e1eef5b2648209bed2a1ea10e5f158911

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp39-none-win_amd64.whl.

File metadata

  • Download URL: lisbon-0.1.0-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 127.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.5

File hashes

Hashes for lisbon-0.1.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 050fe7ef69bd37025de48b6a668eab4b3bc1277f28f7cd0b7ce3a85f6db865b8
MD5 c981d6caf2991a1b7a4959954d5ee3c4
BLAKE2b-256 706ad7437a5fc2ea99e5cfd948e49d54dd2021b3386bf941bd4ffea4843d69c4

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 10a7d8911536ba52cab9430ff12a7182ba181a13161b9a745d8dd828676fd6dc
MD5 b0ad4bcf4bd2b56287c1aa33b5dd599c
BLAKE2b-256 f743b81acce794dd73729ebcceaa2cccfc38ba9d35ce2bbaa604bd48439023f9

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9a352ebad7a7c3735131b49127f9d28247ba892e7c48a89dbf625bbca5819818
MD5 9613543e2fb4a39d1e1237c9d3226c9d
BLAKE2b-256 658282f02e6fcc3a78af00ceffb77e2f04a33ad26fafad79f19b556868be2ecf

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp38-none-win_amd64.whl.

File metadata

  • Download URL: lisbon-0.1.0-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 128.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.5

File hashes

Hashes for lisbon-0.1.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 8b75ac18b754f1d450eedc8a0496b9c00e85d3bb4245a5aa115a4a155c169ffc
MD5 93b016967cb40d4afe957cf3b8e1ddfe
BLAKE2b-256 8efa49ba7da8cf6b348ada38d500fe2cbd655105a792f912917666dae898c0d3

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 12f816c3ce92b74179117523462e42af34036aa2ea6cc7b56e1ffd576d3b1c2b
MD5 93025b5d7f510b4bc8c7cf70455d874d
BLAKE2b-256 ff7122328129eef0298110f639d3dcf1e3b030e6bde96cbb9f0313cc22124d53

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 8876fb1a72f574d77babc294956359ee25c946875978ec105ebede41aca744ea
MD5 358b2dd8db02464fe3abf44e82fd7ccc
BLAKE2b-256 b086cb027dbff92d422bf7b8fa47be7f19235ccbf1b326d332065cb425bcc6c9

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp37-none-win_amd64.whl.

File metadata

  • Download URL: lisbon-0.1.0-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 127.9 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.5

File hashes

Hashes for lisbon-0.1.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 2eb11d5f5a878e76d714dca647796ddc3e7cefda8dccc1b9b24fb0c96c859e22
MD5 73498eebc487ef59939d75e9f63ebb49
BLAKE2b-256 3beeb720875f6a1f47d2a9b58308048e62827f38c5d78a27f08aecc03629b236

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 54ba4b18e7b8ef5d8ba8954c0b597f5ce48c928347f0d0249cad3835b0333bbb
MD5 bd1d8f07ce9a9878b9ecc353d831888a
BLAKE2b-256 65467e3378e6656447161d0e4ca64ee70a03f6a55ae71c8ce1b65193475ae644

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 40315458eacbeaa767e450409921bc9d3cbd9a747bf1f256284ee20ab6ff7482
MD5 3a128bcea6f16dffe7c65fa87a8fb563
BLAKE2b-256 9ed0f2d099f1a0e5b30a447b0b46e4fe4f1457317b31d7be49734d683db28f62

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp36-none-win_amd64.whl.

File metadata

  • Download URL: lisbon-0.1.0-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 127.7 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.5

File hashes

Hashes for lisbon-0.1.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 61f46aed4742de716cfa7d38cbe32cd81ad87d3ef26b5105214168a361602337
MD5 c6c7f8671187c9b15a430465185266de
BLAKE2b-256 1aa3ffd88f84add17efc80d09b736270842cbc2af7b3ad5227aead3cf1e5a809

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 c5437dabd83ed33de9374c64f126e0d131ce306131362d95b0bad515a125e59c
MD5 de7c5c25e3fcea62529d1d3b229ce2f3
BLAKE2b-256 c2f9893134e52e8b0cc2216aea8a6bb1d1978e3a955c2d8d41eb87cf3d1915db

See more details on using hashes here.

File details

Details for the file lisbon-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for lisbon-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 c7a8e7ef9d264f701346c1bc784d9701af965e3ef0c6ea938d6115ac5a55c2fa
MD5 cb238d9d4204fbd646445463402b6ae5
BLAKE2b-256 1e625318b2c21cd65ea40f0ed02378858f3d8bfa315cde21d5b0266b282d6dee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page