Skip to main content

Travelling Salesman Path - Python wrapper

Project description

Travelling salesman path - Python wrapper

This Python package is based on the MATLAB implementation available at biomedical-cybernetics/travelling-salesman-path.

Article Source: Geometric separability of mesoscale patterns in embedding representation and visualization of multidimensional data and complex networks. Acevedo A, Wu Y, Traversa FL, Cannistraci CV (2024) Geometric separability of mesoscale patterns in embedding representation and visualization of multidimensional data and complex networks. PLOS Complex Systems 1(2): e0000012. https://doi.org/10.1371/journal.pcsy.0000012

Before starting

This package requires Concorde to execute calculations. Check the requirements and follow the instructions to install this dependency in your operating system.

Installation

Run the following to install:

pip install pycosep

Usage

Computing the community separability of a given embedding.

from sklearn.datasets import load_iris

from pycosep import community_separability
from pycosep.separability_variants import SeparabilityVariant

# Sample data. Details at https://scikit-learn.org/stable/datasets/toy_dataset.html
data = load_iris()

# Community separability variant
#   CPS: centroid projection separability
#   LDPS: linear discriminant projection separability
#   TSPS: travelling salesman projection separability
variant = SeparabilityVariant.TSPS

indices, _ = community_separability.compute_separability(
    embedding=data.data,
    communities=data.target,
    variant=variant)

print(f"AUC index: {indices['auc']}")
print(f"AUPR index: {indices['aupr']}")
print(f"MCC index: {indices['mcc']}")

Computing the community separability of a given embedding for 1000 permutations.

from sklearn.datasets import load_iris

from pycosep import community_separability
from pycosep.separability_variants import SeparabilityVariant

# Sample data. Details at https://scikit-learn.org/stable/datasets/toy_dataset.html
data = load_iris()

# Community separability variant
#   CPS: centroid projection separability
#   LDPS: linear discriminant projection separability
#   TSPS: travelling salesman projection separability
variant = SeparabilityVariant.LDPS

# Number of iterations for the Null model
permutations = 1000

index_permutations, _ = community_separability.compute_separability(
    embedding=data.data,
    communities=data.target,
    variant=variant,
    permutations=permutations)

auc_results = index_permutations['auc']
print(f"AUC original value: {auc_results['original_value']}")
print(f"AUC p-value: {auc_results['p_value']}")
print(f"AUC mean: {auc_results['mean']}")
print(f"AUC max: {auc_results['max']}")
print(f"AUC min: {auc_results['min']}")
print(f"AUC standard_deviation: {auc_results['standard_deviation']}")
print(f"AUC standard_error: {auc_results['standard_error']}")

aupr_results = index_permutations['aupr']
print(f"AUPR original value: {aupr_results['original_value']}")
print(f"AUPR p-value: {aupr_results['p_value']}")
print(f"AUPR mean: {aupr_results['mean']}")
print(f"AUPR max: {aupr_results['max']}")
print(f"AUPR min: {aupr_results['min']}")
print(f"AUPR standard deviation: {aupr_results['standard_deviation']}")
print(f"AUPR standard error: {aupr_results['standard_error']}")

mcc_results = index_permutations['mcc']
print(f"MCC original value: {mcc_results['original_value']}")
print(f"MCC p-value: {mcc_results['p_value']}")
print(f"MCC mean: {mcc_results['mean']}")
print(f"MCC max: {mcc_results['max']}")
print(f"MCC min: {mcc_results['min']}")
print(f"MCC standard deviation: {mcc_results['standard_deviation']}")
print(f"MCC standard error: {mcc_results['standard_error']}")

Reporting an issue

For reporting problems, questions, and suggestions; please, use the Issues section.

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

pycosep-0.2.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

pycosep-0.2.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file pycosep-0.2.0.tar.gz.

File metadata

  • Download URL: pycosep-0.2.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pycosep-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cb628415df3e3a84c536aef17804ab56ed8de4ff62d95e17f76f236878fb5563
MD5 1625d861b442dbbb9204cbdbf51e1bac
BLAKE2b-256 d6c96fdb74e43e7fc95908783a9c91257ac0083d70a69df1387596314cb55fee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycosep-0.2.0.tar.gz:

Publisher: publish.yaml on aacevedot/pycosep

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

File details

Details for the file pycosep-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pycosep-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pycosep-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c593a9ef9fe5ba133ac1b7a6050360ca781aa300362b0150fc16259a54c47ac8
MD5 dd08926bb892bc7c7a7ed9929cff925b
BLAKE2b-256 06d0528a59876d9849a26c0073d4a9eee33a134b77cad542ce0fbb59ff388294

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycosep-0.2.0-py3-none-any.whl:

Publisher: publish.yaml on aacevedot/pycosep

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

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