Skip to main content

napkinXC is an extremely simple and fast library for extreme multi-class and multi-label classification.

Project description

napkinXC

C++ build Python build Documentation Status PyPI version

napkinXC is an extremely simple and fast library for extreme multi-class and multi-label classification, that focus on implementing various methods for Probabilistic Label Trees. It allows training a classifier for very large datasets in just a few lines of code with minimal resources.

Right now, napkinXC implements the following features both in Python and C++:

  • Probabilistic Label Trees (PLTs) and Hierarchical softmax (HSM),
  • different types of inference methods (top-k, above a given threshold, etc.),
  • fast prediction with labels weight, e.g., propensity scores,
  • efficient online F-measure optimization (OFO) procedure,
  • different tree building methods, including hierarchical k-means clustering method,
  • training of tree node
  • support for custom tree structures, and node weights,
  • helpers to download and load data from XML Repository,
  • helpers to measure performance (precision@k, recall@k, nDCG@k, propensity-scored precision@k, and more).

Please note that this library is still under development and also serves as a base for experiments. API may not be compatible between releases and some of the experimental features may not be documented. Do not hesitate to open an issue in case of a question or problem!

The napkinXC is distributed under the MIT license. All contributions to the project are welcome!

Python Quick Start and Documentation

Install via pip:

pip install napkinxc

We provide precompiled wheels for many Linux distros, macOS, and Windows for Python 3.7+. In case there is no wheel for your os, it will be quickly compiled from the source. Compilation from source requires modern C++17 compiler, CMake, Git, and Python 3.7+ installed.

The latest (master) version can be installed directly from the GitHub repository (not recommended):

pip install git+https://github.com/mwydmuch/napkinXC.git

A minimal example of usage:

from napkinxc.datasets import load_dataset
from napkinxc.models import PLT
from napkinxc.measures import precision_at_k

X_train, Y_train = load_dataset("eurlex-4k", "train")
X_test, Y_test = load_dataset("eurlex-4k", "test")
plt = PLT("eurlex-model")
plt.fit(X_train, Y_train)
Y_pred = plt.predict(X_test, top_k=1)
print(precision_at_k(Y_test, Y_pred, k=1)) 

More examples can be found under python/examples directory, and napkinXC's documentation is available at https://napkinxc.readthedocs.io.

Executable

napkinXC can also be used as executable to train and evaluate models using data in LIBSVM format. See documentation for more details.

References and acknowledgments

This library implements methods from the following papers (see experiments directory for scripts to replicate the results):

Another implementation of PLT model is available in extremeText library, that implements approach described in this NeurIPS paper.

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

napkinxc-0.6.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distributions

napkinxc-0.6.0-cp310-cp310-win_amd64.whl (319.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

napkinxc-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (539.0 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

napkinxc-0.6.0-cp310-cp310-macosx_11_0_x86_64.whl (338.9 kB view details)

Uploaded CPython 3.10 macOS 11.0+ x86-64

napkinxc-0.6.0-cp39-cp39-win_amd64.whl (317.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

napkinxc-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (539.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

napkinxc-0.6.0-cp39-cp39-macosx_11_0_x86_64.whl (338.9 kB view details)

Uploaded CPython 3.9 macOS 11.0+ x86-64

napkinxc-0.6.0-cp38-cp38-win_amd64.whl (319.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

napkinxc-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (539.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

napkinxc-0.6.0-cp38-cp38-macosx_11_0_x86_64.whl (339.0 kB view details)

Uploaded CPython 3.8 macOS 11.0+ x86-64

napkinxc-0.6.0-cp37-cp37m-win_amd64.whl (320.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

napkinxc-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (541.5 kB view details)

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

napkinxc-0.6.0-cp37-cp37m-macosx_11_0_x86_64.whl (335.8 kB view details)

Uploaded CPython 3.7m macOS 11.0+ x86-64

File details

Details for the file napkinxc-0.6.0.tar.gz.

File metadata

  • Download URL: napkinxc-0.6.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0.tar.gz
Algorithm Hash digest
SHA256 cefef16210d5de6d158827973d80b590d5dd020f82379c84158c44c702a1295b
MD5 f440314cd3fa5aec0e83ca078107d22e
BLAKE2b-256 329243f44864dce464c088d2edc4145ab6eff8d1f1fb175d75962ced19657a0d

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: napkinxc-0.6.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 319.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 32773b8f00d25398ca199ee13d0a3844c3c4bea894dc258ffb9a0c5d5aef8f7d
MD5 c3698cea1577afb535fb3e053adb35eb
BLAKE2b-256 d9f6fb2faec0ad9c45aac8145c641db801b2f00ff50837b577f43e59aa3a55c5

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for napkinxc-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0c650232234fa82f19ea3167f66972f87e4169fee6b2f75af1fbfc536974102
MD5 652d2edd1ac5338dc335e20fb5a92cfc
BLAKE2b-256 90bc7782676dd0db984e7d45c3d2d9db348613ae3a6997a4c2569d14c184611d

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

  • Download URL: napkinxc-0.6.0-cp310-cp310-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 338.9 kB
  • Tags: CPython 3.10, macOS 11.0+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 cebcbae5a58dd136e4474487e3064f48792a577f419fa7bec7f97944da5106f5
MD5 78069b0025101be844ce84636eb0bb13
BLAKE2b-256 09ae8889bc6a7b6dc0dc9cfb3133d625daf1f5c7558439858e87260b91a5f110

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: napkinxc-0.6.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 317.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 562cbd2703a2b5e4df2361ddc05fc3cc52fa7df1e145061d18cf12354876921a
MD5 e66422c980b475d4375c2939b25c5034
BLAKE2b-256 dbf79f1cf559c9d144398a67873f1c2f90c9da15f79ff32d8ded87712154e50b

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for napkinxc-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8de049748450ad708f26eddf87c762afa627e79f9977e7734c3dc691dd832d3b
MD5 008bfff19ef51170c897804fb497d24f
BLAKE2b-256 b7862e316d6f98b1b7aa82794a33d095bf7f248b4f4c6920fff026ae7acd4cd7

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

  • Download URL: napkinxc-0.6.0-cp39-cp39-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 338.9 kB
  • Tags: CPython 3.9, macOS 11.0+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 c2c909f278f8f07c17a1db7fab086cd1cb3f85336551c2493a7dca800f6150cf
MD5 61e4901c5db70a9a9d35f97c290b6ab0
BLAKE2b-256 cff0f9b334ba07633640210918d84cd36924ac1c02beb97a5255e3b1b348481e

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: napkinxc-0.6.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 319.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9732fa0964bfc1fa3538de3fe6e320338cd38227237a1437675cf9fc004092c1
MD5 210b963675c55b31b0a5f08fec874bab
BLAKE2b-256 7a3119203ba1aa5737f0134049e474d4637cfecf6d08a513b8a81da8f53a1437

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for napkinxc-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a4e4e8ac6ee24b752d6cdaf168c35150d89c0b90c539225220e07aa6f73bf97c
MD5 69a3d2c69a09281c16a404f373dbf4bc
BLAKE2b-256 6fc60acd3617a49dfbf01a9b282742cf795d6c2f3057ee882263ff7d6982549a

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

  • Download URL: napkinxc-0.6.0-cp38-cp38-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 339.0 kB
  • Tags: CPython 3.8, macOS 11.0+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 e118cb4090becd0d051ebcb696bc20ba8dc504e27b62e094090405f97c7e41de
MD5 2d524ca45294b06a8c2d2fb88260664d
BLAKE2b-256 40d1c7940201fbfa1578b2c490db702817b8e1c4b95cd3ec8375e2d36912651e

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: napkinxc-0.6.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 320.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5c25393e702a8dd726a42ca59f94c014acee13e1b1f5e17b389e41ae37b62d6f
MD5 c1f5551cdda09a2d224c732da600e105
BLAKE2b-256 3e33b8657f8054002fcee1f5591b480ceb0d7d9b1edce31f1002db8cab5c1e3e

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for napkinxc-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d1a923f87e360b1f9d3545103691ebc405a29f179c2faabee964793aa3f29b28
MD5 0c30e87d2594fb61ff2b219201478415
BLAKE2b-256 37b8f3582dfd2766ea61ba191b3c4053b4ca15e8921caedc444141714a02b049

See more details on using hashes here.

File details

Details for the file napkinxc-0.6.0-cp37-cp37m-macosx_11_0_x86_64.whl.

File metadata

  • Download URL: napkinxc-0.6.0-cp37-cp37m-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 335.8 kB
  • Tags: CPython 3.7m, macOS 11.0+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

File hashes

Hashes for napkinxc-0.6.0-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a6f8971b21edf7667a55eefb4e3d65f20811a5e26d6f5e819efc10268187c506
MD5 6883632f633de86e2e17a8b9b45a4930
BLAKE2b-256 7b73a0161de0fbcc8216af23c85be29b5a2cb673b1c425c22701c4c145077232

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