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.0.tar.gz (25.4 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.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for simple_multi_mst-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cf11f81d896e73ef4723af92f9448ad7c3e33560bb6d20a4ad33df949abc76be
MD5 12656b8bdf3a6f3111b6efc9d4c29c8b
BLAKE2b-256 4ea3d83e4540f3911b400ac927ce0cd5088c648f18fa399c6fcc9a627c24d0f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_multi_mst-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77d8ca9db3d7511cd40bf178dc252a0621c0f9b8ed9604bff1a617921e240fff
MD5 bcc9e37838331d48b4b041237a8fcc02
BLAKE2b-256 2e238b91ad14c0117ba5e7c4b30a31c8cc635d34ec9a38635d2af446913325ac

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