Skip to main content

Saturn coefficient to assess the results of an UMAP dimensionality reduction

Project description

Saturn score

Article

More information about this package can be found in the following article:

Davide Chicco, Simone Melzi, Francesca Gasparini and Giuseppe Jurman, "The advantages of our proposed Saturn coefficient over continuity and trustworthiness for UMAP dimensionality reduction evaluation", PeerJ Computer Science 12:e3424, pages 1-34 (2026). https://doi.org/10.7717/peerj-cs.3424

Article on PeerJ Computer Science

Summary

A Python package that computes the Saturn coefficient of a matrix to assess the quality of its UMAP dimensionality reduction.

Please notice that I developed the Saturn coefficient package originally in R, which is programming language I know better and is also where I was able to make more tests. I then ported this software package from R to Python, and here you can find the outcome. If you find anything that should be improved, please let me know.

Installation and example execution

You can run the following Python code to test your package installation. It will first install the needed packages and then apply the Saturn coefficient calculation:

import subprocess
import sys

bash_command = sys.executable +" -m pip install --upgrade pip"
# Execute the bash command
print("bash_command:\n", bash_command)
result = subprocess.run(bash_command, shell=True, capture_output=True, text=True)

# List of libraries to check/install
libraries = ["numpy", "pandas", "scipy", "umap-learn", "scikit-learn", "saturnscore"]

for lib in libraries:
    try:
        __import__(lib)
        print(f"{lib} is already installed.")
    except ImportError:
        print(f"{lib} not found. Installing...")
        subprocess.check_call([sys.executable, "-m", "pip", "install", lib])

# Print the output and errors (if any)
print("output:\t", result.stdout)
error = result.stderr
if(error):
    print("errors:\t", error)

import numpy as np
import pandas as pd
import scipy
import umap.umap_ as umap
from saturnscore import Saturn_coefficient
from sklearn.preprocessing import StandardScaler

base = 120
height = 200
this_random_seed = 0
np.random.seed(this_random_seed)  # Set random seed for reproducibility

these_n_neighbors = 20
this_min_dist = 0.01
these_n_components = 2
this_metric = 'euclidean'
this_random_state = 42
this_n_jobs = 1
this_n_epochs = 200

print("these_n_neighbors = ", these_n_neighbors)
print("this_min_dist = ", this_min_dist)
print("these_n_components = ", these_n_components)
print("this_metric = ", this_metric)

umap_verbose = False
fit = umap.UMAP(n_neighbors=these_n_neighbors,
min_dist=this_min_dist,
n_components=these_n_components,
metric=this_metric,
n_jobs=this_n_jobs,
random_state=this_random_state,
n_epochs = this_n_epochs,
verbose=umap_verbose)

umap_output_layout = fit.fit_transform(input_data)

result = Saturn_coefficient.SaturnCoefficient(input_data, umap_output_layout)
print(f"Saturn coefficient =  ", result, " in the [0, 1] interval (the higher, the better)")

The final command should print something like Saturn coefficient = 0.1029461972317906 (this value might be slightly different because of the random component of UMAP).

Contact

The SaturnScore package was developed by Davide Chicco. Questions should be addressed to davidechicco(AT)davidechicco.it

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

saturnscore-1.2.4.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

saturnscore-1.2.4-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file saturnscore-1.2.4.tar.gz.

File metadata

  • Download URL: saturnscore-1.2.4.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for saturnscore-1.2.4.tar.gz
Algorithm Hash digest
SHA256 13be3a60c4197b198d453f412fc1ab5df01e653897bc7959a1374cbda6f5c36d
MD5 7ca3ac33870bc0dbc49e0095f1cd7c2b
BLAKE2b-256 5e7fc8a4bbc1bb0cc74d293d95005ed7d1366dd54f1d2e9a6b9a1de269ef444b

See more details on using hashes here.

File details

Details for the file saturnscore-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: saturnscore-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for saturnscore-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a2aa42a59286e526f0dcea62c808aa20fed03e3198aa810f99606de511243a5d
MD5 6c7ba5f1c642ed47d635f5ebc8c19322
BLAKE2b-256 f6aa9e241e298bc1eda34ec9c4cec8885e8c193004b9303cdfde5194f0c94332

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