Skip to main content

Jax coreset algorithms.

Project description

Coreax logo

Coreax

Unit Tests Coverage Pre-commit Checks linting: pylint Python version PyPI

© Crown Copyright GCHQ

Coreax is a library for coreset algorithms, written in JAX for fast execution and GPU support.

About Coresets

For $n$ points in $d$ dimensions, a coreset algorithm takes an $n \times d$ data set and reduces it to $m \ll n$ points whilst attempting to preserve the statistical properties of the full data set. The algorithm maintains the dimension of the original data set. Thus the $m$ points, referred to as the coreset, are also $d$-dimensional.

The $m$ points need not be in the original data set. We refer to the special case where all selected points are in the original data set as a coresubset.

Some algorithms return the $m$ points with weights, so that importance can be attributed to each point in the coreset. The weights, $w_i$ for $i=1,...,m$, are often chosen from the simplex. In this case, they are non-negative and sum to 1: $w_i >0$ $\forall i$ and $\sum_{i} w_i =1$.

Please see the documentation for some in-depth examples.

Example applications

Choosing pixels from an image

In the example below, we reduce the original 180x215 pixel image (38,700 pixels in total) to a coreset approximately 20% of this size. (Left) original image. (Centre) 8,000 coreset points chosen using kernel thinning. (Right) 8,000 points chosen randomly. Run benchmark/david_benchmark.py to replicate.

Original Coreset Random

Video event detection

Here we identify representative frames such that most of the useful information in a video is preserved. Run examples/pounce.py to replicate.

Original Coreset

Setup

Install Coreax from PyPI by adding coreax to your project dependencies or running

pip install coreax

Coreax uses JAX. It installs the CPU version by default, but if you have a GPU or TPU, see the JAX installation instructions for options available to take advantage of the power of your system. For example, if you have an NVIDIA GPU on Linux, add jax[cuda12] to your project dependencies or run

pip install jax[cuda12]

There are optional sets of additional dependencies:

  • coreax[test] is required to run the tests;
  • coreax[example] contains all dependencies for the example scripts;
  • coreax[benchmark] is required to run benchmarking;
  • coreax[doc] is for compiling the Sphinx documentation;
  • coreax[dev] includes all tools and packages a developer of Coreax might need.

Note that the test and dev dependencies include opencv-python-headless, which is the headless version of OpenCV and is incompatible with other versions of OpenCV. If you wish to use an alternative version, remove opencv-python-headless and select an alternative from the OpenCV documentation.

Should the installation of Coreax fail, you can see the versions used by the Coreax development team in uv.lock. You can transfer these to your own project as follows. First, install UV. Then, clone the repo from GitHub. Next, run

uv export --format requirements-txt

which will generate a requirements.txt. Install this in your own project before trying to install Coreax itself,

pip install -r requirements.txt
pip install coreax

Release cycle

We anticipate two release types: feature releases and security releases. Security releases will be issued as needed in accordance with the security policy. Feature releases will be issued as appropriate, dependent on the feature pipeline and development priorities.

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

coreax-1.0.0.tar.gz (89.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coreax-1.0.0-py3-none-any.whl (100.4 kB view details)

Uploaded Python 3

File details

Details for the file coreax-1.0.0.tar.gz.

File metadata

  • Download URL: coreax-1.0.0.tar.gz
  • Upload date:
  • Size: 89.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for coreax-1.0.0.tar.gz
Algorithm Hash digest
SHA256 30031a6eee13e83af67c7a27e608d8868524c7d48f6b19ddfbbc7cc9ca8e1e9d
MD5 108ecbe8eaa31998f820e7ee2e110960
BLAKE2b-256 0d7357509112deb9b30f19d0eebc0733e7137e93c5be3411cb344bee27aaa272

See more details on using hashes here.

File details

Details for the file coreax-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: coreax-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 100.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for coreax-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 354730315736ac842175b27550e2da966a1722ee5bcba5341904cb8017a355a5
MD5 0c43fb73f74b5c5080730b411376bc30
BLAKE2b-256 4e8fc2791ef0a665f45c6fa6fdbcad0b0a9a06393e7d0f32c22a13a81929eac2

See more details on using hashes here.

Supported by

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