Skip to main content

Saturn coefficient to assess the results of an UMAP dimensionality reduction

Project description

Saturn score

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

You can execute the following command to install this package and its dependencies:

pip3 install numpy pandas scipy umap-learn scikit-learn saturnscore

Example

You can run the following Python code to test your package installation:

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

np.random.seed(0)  # Set random seed for reproducibility
input_data = np.random.randn(120, 200)  # Generate random matrix X1

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)

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.1.tar.gz (9.6 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.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: saturnscore-1.2.1.tar.gz
  • Upload date:
  • Size: 9.6 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.1.tar.gz
Algorithm Hash digest
SHA256 eba8e8292da21986e8d93c4ee6f8dcfea9af714634d5d76426bf018a57449468
MD5 6de29b112368265a2662ecb65c914125
BLAKE2b-256 c30807625810e516dcf59c268f4b90bfd08894078097ea625a6889698e055cef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: saturnscore-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 587c0c997c76fcc8d96cea3b88aa1aa41c599b054918d5f01f22bfb7052132da
MD5 4059f4ebfae40784ad636b5fa2502a58
BLAKE2b-256 d3e9315d888e7f4f46c5b1bdc86371d78e39be8a897c8b51a79141c8c65aeed2

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