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.1.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

pycosep-0.1.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycosep-0.1.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pycosep-0.1.0.tar.gz
Algorithm Hash digest
SHA256 494a750c39fce034d9de17eabf02c0b2ba86abce001d80aad80e9c3a6619b73f
MD5 c7cff3df92f68adab230d6fe05f0c6cb
BLAKE2b-256 4e1a1c8519c494421e4399ffafb64869bc5d559ecf150cf0a44c4caf9a3d8876

See more details on using hashes here.

Provenance

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

Publisher: publish.yaml on aacevedot/pycosep

Attestations:

File details

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

File metadata

  • Download URL: pycosep-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pycosep-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f037c2956b6b141e6cb3b4cc548d1f57c21cd0c032a0fb582a44be73fe51e2f
MD5 4cbffde8ee3f1c0a3e6de1d1776c9aa3
BLAKE2b-256 06c9930a8e2598f61764f3b1ace67ac0ba7ea473c8a43802bf9855e016488041

See more details on using hashes here.

Provenance

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

Publisher: publish.yaml on aacevedot/pycosep

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page