Skip to main content

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.

Metadata

Release files for lisbon 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lisbon 0.1.0
File Size Uploaded
lisbon-0.1.0.tar.gz 14.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for lisbon 0.1.0
File
lisbon-0.1.0-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details
lisbon-0.1.0-cp310-cp310-manylinux_2_24_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ x86-64 Details
lisbon-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.7+ x86-64 Details
lisbon-0.1.0-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
lisbon-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.24+ x86-64 Details
lisbon-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.7+ x86-64 Details
lisbon-0.1.0-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
lisbon-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.24+ x86-64 Details
lisbon-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details
lisbon-0.1.0-cp37-none-win_amd64.whl CPython 3.7 none Windows x86-64 Details
lisbon-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.24+ x86-64 Details
lisbon-0.1.0-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details
lisbon-0.1.0-cp36-none-win_amd64.whl CPython 3.6 none Windows x86-64 Details
lisbon-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.24+ x86-64 Details
lisbon-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64 Details

Total release size: 2.5 MB

Release files / lisbon-0.1.0.tar.gz

Download URL lisbon-0.1.0.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e1faa24f275b50428faea8b758f2bf648db787f51edecc18e82a35e77e51d404
BLAKE2b-256 checksum
How to use checksums
199b627e46d2f6201974107937126cfc079dc56ff7b0dcb202f96f2bc22f5570
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp310-none-win_amd64.whl

Download URL lisbon-0.1.0-cp310-none-win_amd64.whl
Size 127.5 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
6881fb2b3eab5ddc4e4c9b53e037593f857e62e46d230fdbebc322f5df7ffb76
BLAKE2b-256 checksum
How to use checksums
82e6f0a9f411574ef461768d9f71e301302101937ca0ac88773ec5870dfb7c49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp310-cp310-manylinux_2_24_x86_64.whl

Download URL lisbon-0.1.0-cp310-cp310-manylinux_2_24_x86_64.whl
Size 187.3 kB
Tags CPython 3.10 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
83f2b5ea87dfb4a2fe4140c264bb70c34ca6bcc6dd3716523ae1dd4e6b8d2bba
BLAKE2b-256 checksum
How to use checksums
ce0ac914840d1b2cc0e7e44bdfff004f2a1da2a52aba348601224d1a633da542
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl

Download URL lisbon-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl
Size 176.0 kB
Tags CPython 3.10 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
2ce4188cab9c60a0e5953dfbdebb60ea970beaec837e448e714c358b6a70a379
BLAKE2b-256 checksum
How to use checksums
066223d9e05ee229a4ac0103dea60a8e1eef5b2648209bed2a1ea10e5f158911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp39-none-win_amd64.whl

Download URL lisbon-0.1.0-cp39-none-win_amd64.whl
Size 127.7 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
050fe7ef69bd37025de48b6a668eab4b3bc1277f28f7cd0b7ce3a85f6db865b8
BLAKE2b-256 checksum
How to use checksums
706ad7437a5fc2ea99e5cfd948e49d54dd2021b3386bf941bd4ffea4843d69c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl

Download URL lisbon-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl
Size 187.4 kB
Tags CPython 3.9 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
10a7d8911536ba52cab9430ff12a7182ba181a13161b9a745d8dd828676fd6dc
BLAKE2b-256 checksum
How to use checksums
f743b81acce794dd73729ebcceaa2cccfc38ba9d35ce2bbaa604bd48439023f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl

Download URL lisbon-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl
Size 176.1 kB
Tags CPython 3.9 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
9a352ebad7a7c3735131b49127f9d28247ba892e7c48a89dbf625bbca5819818
BLAKE2b-256 checksum
How to use checksums
658282f02e6fcc3a78af00ceffb77e2f04a33ad26fafad79f19b556868be2ecf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp38-none-win_amd64.whl

Download URL lisbon-0.1.0-cp38-none-win_amd64.whl
Size 128.0 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
8b75ac18b754f1d450eedc8a0496b9c00e85d3bb4245a5aa115a4a155c169ffc
BLAKE2b-256 checksum
How to use checksums
8efa49ba7da8cf6b348ada38d500fe2cbd655105a792f912917666dae898c0d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl

Download URL lisbon-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl
Size 187.7 kB
Tags CPython 3.8 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
12f816c3ce92b74179117523462e42af34036aa2ea6cc7b56e1ffd576d3b1c2b
BLAKE2b-256 checksum
How to use checksums
ff7122328129eef0298110f639d3dcf1e3b030e6bde96cbb9f0313cc22124d53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl

Download URL lisbon-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl
Size 175.9 kB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
8876fb1a72f574d77babc294956359ee25c946875978ec105ebede41aca744ea
BLAKE2b-256 checksum
How to use checksums
b086cb027dbff92d422bf7b8fa47be7f19235ccbf1b326d332065cb425bcc6c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp37-none-win_amd64.whl

Download URL lisbon-0.1.0-cp37-none-win_amd64.whl
Size 127.9 kB
Tags CPython 3.7 Windows x86-64
SHA-256 checksum
How to use checksums
2eb11d5f5a878e76d714dca647796ddc3e7cefda8dccc1b9b24fb0c96c859e22
BLAKE2b-256 checksum
How to use checksums
3beeb720875f6a1f47d2a9b58308048e62827f38c5d78a27f08aecc03629b236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl

Download URL lisbon-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Size 187.3 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
54ba4b18e7b8ef5d8ba8954c0b597f5ce48c928347f0d0249cad3835b0333bbb
BLAKE2b-256 checksum
How to use checksums
65467e3378e6656447161d0e4ca64ee70a03f6a55ae71c8ce1b65193475ae644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL lisbon-0.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
Size 175.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
40315458eacbeaa767e450409921bc9d3cbd9a747bf1f256284ee20ab6ff7482
BLAKE2b-256 checksum
How to use checksums
9ed0f2d099f1a0e5b30a447b0b46e4fe4f1457317b31d7be49734d683db28f62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp36-none-win_amd64.whl

Download URL lisbon-0.1.0-cp36-none-win_amd64.whl
Size 127.7 kB
Tags CPython 3.6 Windows x86-64
SHA-256 checksum
How to use checksums
61f46aed4742de716cfa7d38cbe32cd81ad87d3ef26b5105214168a361602337
BLAKE2b-256 checksum
How to use checksums
1aa3ffd88f84add17efc80d09b736270842cbc2af7b3ad5227aead3cf1e5a809
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl

Download URL lisbon-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl
Size 186.9 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
c5437dabd83ed33de9374c64f126e0d131ce306131362d95b0bad515a125e59c
BLAKE2b-256 checksum
How to use checksums
c2f9893134e52e8b0cc2216aea8a6bb1d1978e3a955c2d8d41eb87cf3d1915db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release files / lisbon-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl

Download URL lisbon-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
Size 176.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
c7a8e7ef9d264f701346c1bc784d9701af965e3ef0c6ea938d6115ac5a55c2fa
BLAKE2b-256 checksum
How to use checksums
1e625318b2c21cd65ea40f0ed02378858f3d8bfa315cde21d5b0266b282d6dee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

16 release files

0.0.6

12 release files

0.0.5

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page