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.2.tar.gz (4.5 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.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: microagg1d-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 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.2.tar.gz
Algorithm Hash digest
SHA256 2d0d439850fd480e371aaf5896827eb41f941db2b9da4c55263c97355f8687ef
MD5 c586ba5099345b1ab18defe4ecf887de
BLAKE2b-256 370fc6ccd30d819a928ad132d0658c678d08e16e64c36fa164f14c55fc4c6230

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microagg1d-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 370a5ec3a2c972ae7fa5c8a7776b4f056c34f24ca35d394811835c6261e213cf
MD5 a9e4de258dbcc5d43efd2cb639e786ec
BLAKE2b-256 6885800889a430e073d6056d32ba2fd8d0193660359eee0a44414392a3c7aa30

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