Skip to main content

mdapy-v2

mdapy-v2 is a maintained fork of IHCantabria/mdapy, developed by the original author. Version 2.0 introduces the DataColumn API while preserving the mdapy Python import and the original maximum dissimilarity algorithm.

The distributions mdapy-v2, ihc-mdapy, and the unrelated mdapy project all provide a package named mdapy. Treat them as alternatives: do not install them together in the same Python environment.

Installation

Install the maintained distribution from PyPI:

pip install mdapy-v2

The import remains unchanged:

from mdapy import DataColumn, max_diss_alg

The original ihc-mdapy==0.1.0 distribution uses the tuple-based API shown in the legacy section below. Version 2.0 also contains the NaN validation from the historical v0.1.1 tag, which was not published to PyPI.


📋 The Maximum Dissimilarity Algorithm

The Maximum Dissimilarity Algorithm is a technique used to select a specified number of data points from a larger dataset in such a way that the selected points are maximally dissimilar to each other. The algorithm is particularly useful in scenarios where you need to create diverse subsets of data for analysis or for initializing cluster centroids in clustering algorithms.

In this case, directional variables can also be considered, in which case, the distance between two angles is calculated as the shortest distance between the two angles in a circle. For example, the distance between 350° and 10° is 20°, not 340°. This is the approach used in this implementation of the algorithm (see Guanche et al. (2013) for more details).

Algorithm steps

  1. Start with the observation at seed_index (default 0).
  2. For each unselected observation, find its distance to the nearest selected observation.
  3. Select the observation with the greatest nearest distance. Repeat until n_clusters observations have been selected.

Distances are Euclidean after dividing each column's difference by its standard deviation and sqrt(2). Directional differences use the shortest arc in degrees, and their standard deviation is circular. If two candidates have exactly the same distance, the one appearing first in the input is selected.


Usage

Pass one DataColumn per variable. Each column must be one-dimensional, have the same number of observations, and contain only finite values. Columns with zero or undefined standard deviation are rejected. Directional columns are angles in degrees. n_clusters is required and must be between 1 and the number of observations; seed_index must be a valid input position.

from mdapy import DataColumn, max_diss_alg

tp = [14.93, 10.42, 7.46, 7.63, 12.20, 12.05, 14.49, 8.62]
hs = [1.82, 1.45, 0.26, 0.90, 1.30, 5.71, 1.40, 2.18]
direction = [268, 272, 289, 293, 276, 273, 276, 292]

points, indices = max_diss_alg(
    DataColumn(tp),
    DataColumn(hs),
    DataColumn(direction, directional=True),
    n_clusters=3,
)

Input values are converted to float32. points is a float32 NumPy array of shape (n_clusters, n_columns) in selection order. indices is a list of positions in the original input. The first position is seed_index (default 0).

Legacy tuple API

Existing tuple-based calls can use an explicit import:

from mdapy.legacy import max_diss_alg

points, indices = max_diss_alg((tp, hs, direction), 3, seed_index=0, dir_indices=[2])

Passing a tuple to mdapy.max_diss_alg raises an error explaining this import.


©️ Credits

Originally developed by 👨‍💻 Pablo Garcia at 🏢 IHCantabria, and now maintained as the personal mdapy-v2 fork. The historical v0.1.1 fix was contributed by Álvaro Rodríguez. The original IHCantabria copyright notice and MIT terms are preserved in LICENSE.


📚 References

[1] Guanche, Y., Guanche, R., Camus, P., Mendez, F. J., & Medina, R. (2013). A multivariate approach to estimate design loads for offshore wind turbines. Wind Energy, 16(7), 1091-1106.


Metadata

Release files for mdapy-v2 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdapy-v2 2.0.0
File Size Uploaded Provenance
mdapy_v2-2.0.0.tar.gz 6.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mdapy-v2 2.0.0
File Interpreter ABI Platform
mdapy_v2-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.8 kB

Release files / mdapy_v2-2.0.0.tar.gz

Download URL mdapy_v2-2.0.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9914ecee5e95150ab4991f7b890565c263073f9dee19dcd763be812e006601ad
BLAKE2b-256 checksum
How to use checksums
4575571ab5501e1d96522e7fc6d413c30a6672dab9901f5c67fa0d693b9fe5f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mdapy_v2-2.0.0-py3-none-any.whl

Download URL mdapy_v2-2.0.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50feac48ed0467d227a0d456d65ed48511ddac44137b23833826501ade45b30f
BLAKE2b-256 checksum
How to use checksums
3774fd2b89f2e688dc477a700c4489893b339516ca43eb215df6fae4a7ec0c29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for mdapy-v2 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page