Skip to main content

A python package for optimal univariate microaggregation in 1d

Project description

build

microagg1d

A Python library which implements a dynamic program for optimal univariate microaggregation. For an input array of length n and minimal class size k it has runtime max(O(n log(n)), O(kn)). It has space requirements of O(n).

The code is written in Python and relies on the numba compiler for speed.

Requirements

microagg1d relies on numpy and numba which currently support python 3.8-3.10.

Installation

microagg1d is available on PyPI, the Python Package Index.

$ pip3 install microagg1d

Example Usage

import microagg1d

x = [5, 1, 1, 1.1, 5, 1, 5]
k = 3

clusters = microagg1d.optimal_univariate_microaggregation_1d(x, k)

print(clusters)   # [1 0 0 0 1 0 1]

Important notice: On first usage the the code is compiled once which may take about 30s. On subsequent usages this is no longer necessary and execution is much faster.

Tests

Tests are in tests/.

# Run tests
$ python3 -m pytest .

License

The code in this repository has an BSD 2-Clause "Simplified" License.

See LICENSE.

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

microagg1d-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

microagg1d-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: microagg1d-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for microagg1d-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8337ae02a08d729c604737b9cf7c6658b960ddd53940953a9ddcc4b1a6d40509
MD5 9242ff33c6fcca3be862ebabfe141daf
BLAKE2b-256 64cc0af007d011f931db01aeeb27fb068d05c80e1844b216356db65810ddddad

See more details on using hashes here.

File details

Details for the file microagg1d-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: microagg1d-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for microagg1d-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae66dae356db20c09fb2561cd95e408382e8bdc19b10a9a4d5b51f6dcaed3aa7
MD5 08ed3009cfddd10988d57e6483b36f6f
BLAKE2b-256 a76576fd7d2f02c95205a47831ba03fadf8a92e293af3de0c6d08ab3637bfc19

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