Skip to main content

Package to build TDA networks based on multiple MSTs

Project description

Multi-MST

multi_mst is a Python package for generating robust graph representations of high-dimensional data using iterative minimum spanning trees (MSTs). It supports exploratory analysis within the framework of topological data analysis (TDA).

The package constructs MSTs from pairwise distances between datapoints in a multidimensional space. By perturbing the distance matrix slightly and recalculating the MST multiple times, it captures multiple plausible connections between points. The resulting graph (i.e. the aggregate of these MSTs) offers a more stable and interpretable topological structure for visualisation and further analysis.

Installation

pip install simple-multi-mst

If you want to visualise the network within marimo:

pip install simple-multi-mst[visual]

Usage

import simple_multi_mst
import pandas as pd

df = pd.read_csv("http://aida-lab.be/assets/horse.csv").sample(n=200)
m_mst = simple_multi_mst.MultiMST(df, metric="euclidean", iterations=100)
m_mst.run()
m_mst.export()

API

class MultiMST

Creates and aggregates multiple perturbed MSTs from input data.

Constructor

MultiMST(df, cols=[], metric='euclidean', max_amount=0, iterations=10)
  • df: pandas DataFrame with data points
  • cols: list of columns to use (excluding ‘id’)
  • metric: distance metric (passed to scipy.spatial.distance.pdist)
  • max_amount: maximum amount of perturbation applied to the distances
  • iterations: number of MSTs to compute and combine

Methods

  • run(): computes the MSTs and returns the resulting graph as a JSON-serialisable dictionary.
  • export(format='json', base_filename='output'): writes the output graph to a file.
    • format: "json" for single JSON file; "csv" for separate nodes.csv and links.csv

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

simple_multi_mst-0.1.1.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

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

simple_multi_mst-0.1.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file simple_multi_mst-0.1.1.tar.gz.

File metadata

  • Download URL: simple_multi_mst-0.1.1.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for simple_multi_mst-0.1.1.tar.gz
Algorithm Hash digest
SHA256 36c53311330ae187ee58182f6a6f5ad30db6a17cc54ce22467e32010a72ed489
MD5 d9d7be1618d5c3f8829730ad8190cd79
BLAKE2b-256 d42b289c927ffd72df75f0fcc231b0ea8626727b93fb7194d9635605fd9c9486

See more details on using hashes here.

File details

Details for the file simple_multi_mst-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_multi_mst-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6bbf2da0be59e80be298d168ce28a34bf90f2913a44716e73ed2a9d3e34368f3
MD5 1943175ac0464999794d32ed2aa2ec1a
BLAKE2b-256 5b01116261b61b04ff181f4e1e5816dc31d7d85867dcb3afafab00b617a005e9

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