Skip to main content

polymahalanobis

A polynomial Mahalanobis distance classifier for multivariate / multispectral data.

Given a set of reference samples, PolyMahalanobis builds a nested sequence of polynomial-expanded subspaces (via SVD) and evaluates how far a new sample is from that reference distribution — useful for anomaly detection, similarity scoring, and multispectral classification (e.g. vegetation health from satellite/drone imagery bands).

Only dependency: numpy.

Install

pip install polymahalanobis

Usage

import numpy as np
from polymahalanobis import PolyMahalanobis

# samples.txt: one reference sample per line, band values space-separated
model = PolyMahalanobis("samples.txt", num_levels=3)
model.makeSpace()

new_pixels = np.array([[120.0, 45.0, 200.0]], dtype=np.float32)
distances = model.evaluate(new_pixels)  # shape (N, num_levels)

final_distance = distances[:, -1]  # accumulated distance, last level
  • evaluate(spectral_values): batched evaluation, (N, n_bands) -> (N, num_levels).
  • evaluate_single(spectral_value): convenience for a single (n_bands,) sample.
  • evaluate_image(image_multispectral): convenience for a full (H, W, n_bands) array, with de-duplication of repeated pixel values.

Full project

This library is the core algorithm extracted from the PolynomialMahalanobis project, which also includes a parallelized command-line pipeline for classifying multispectral GeoTIFF orthophotos. That pipeline is not part of this PyPI package — see the repository for it.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polymahalanobis-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

polymahalanobis-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polymahalanobis-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for polymahalanobis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c8c91bd9c661eddefcbe1516858e24dde8ef0ba87995281836ba0db5e1429164
MD5 8d92376db6b5099a9e754f9936ba97e1
BLAKE2b-256 5cfdba4afe6d4e40904724ae285d89a259b1e2c7fab4e3a4e6ac673272621000

See more details on using hashes here.

Provenance

The following attestation bundles were made for polymahalanobis-0.1.0.tar.gz:

Publisher: publish.yml on CodeWracker/PolynomialMahalanobis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for polymahalanobis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e96af9da50f5f196f93b788bf14106e216a6615976d118605bbbfe17fbc905d
MD5 300ed457711e837253b72af3ca147e61
BLAKE2b-256 819663b4bec345772184da40a222b5c4f775e363ea84edeb8f9f43b460b1c711

See more details on using hashes here.

Provenance

The following attestation bundles were made for polymahalanobis-0.1.0-py3-none-any.whl:

Publisher: publish.yml on CodeWracker/PolynomialMahalanobis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Supported by

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