Skip to main content

FloDR

Documentation

Dimensionality reduction built on an invertible normalising flow. The first n_components coordinates of the flow are the map and the rest are a residual, so the fitted map has an exact inverse and an exact density. FloDR follows the scikit-learn estimator interface, like UMAP.

Installation

Python 3.11 or newer. Training uses the GPU when PyTorch sees one.

pip install flodr

Usage

import matplotlib.pyplot as plt
from flodr import FloDR, audit, viz

model = FloDR(random_state=0).fit(X)
Y = model.embedding_                         # the map

Y_new = model.transform(X_new)               # one pass through the flow
Y_opt = model.transform_opt(X_new)           # optimised against the training map, as UMAP's transform
X_back = model.inverse_transform(Y[:10])     # positions back to the input
Z = model.transform_latent(X_new)            # the map, then the residual
X_same = model.inverse_latent(Z)             # exact up to float precision

logp = model.score_samples(X_new)            # log density
cert = model.coverage_certificate(X_new)     # is the density a law of new points?

res = audit(Y, X=X, labels=labels)           # what the map hides about the labels

fig, ax = plt.subplots(1, 3, figsize=(12, 4))
viz.plot_embedding(Y, labels, ax=ax[0])
viz.plot_ranks([cert["fibre"]["ranks"], cert["map"]["ranks"]], ax=ax[1])
viz.plot_audit(res, axes=ax[2], show_labels=False)
Parameter Default
n_components 2 dimension of the map
w 2.0 weight of the distance order: 0 keeps neighbourhoods only, larger keeps more global structure
axes "variance" start from the leading principal components, or "heat" from the heat geometry of the neighbour graph
density True fit the density, needed by score_samples and the certificates
max_iter None training steps, 6,400 by default
random_state 0 seed
device None the GPU when there is one

examples/quickstart.ipynb runs these calls on Fashion-MNIST.

Development

git clone https://github.com/daenuprobst/flodr
cd flodr
uv sync --extra dev
uv run pytest

The documentation is a Starlight site built from docs/docs/*.md and the signatures in src/flodr: cd docs && npm install && npm run dev.

Reproducing the paper

scripts/ holds one script per figure and table of the paper, named after it (fig2.py, ed_table1.py, supp_fig1.py, ...), and scripts/common.py with the data, the methods and the scores they share. Each script fits what it needs, caches it under scripts/cache, so scripts that share fits reuse them, and writes its figure or table to scripts/out.

uv sync --extra paper
uv pip install git+https://github.com/hyhuang00/ParamRepulsor.git
uv run python scripts/fig2.py

Raw data go into data/ (or the folder named by DATA); the data availability statement of the paper lists the sources, and each script names the files it reads. Three tools need interpreters of their own, named by PCUMAP_PYTHON (Parametric UMAP: TensorFlow 2.15 with umap-learn 0.5.5), DREAMS_PYTHON (DREAMS: the authors' openTSNE fork) and SCVI_PYTHON (scvi-tools, for the zebrafish latent); the population-genetics test needs plink2.

Metadata

Release files for flodr 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flodr 0.2.0
File Size Uploaded Provenance Actions
flodr-0.2.0.tar.gz 55.9 kB Without provenance Details for flodr-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flodr 0.2.0
File Interpreter ABI Platform Actions
flodr-0.2.0-py3-none-any.whl Python 3 none any Details for flodr-0.2.0-py3-none-any.whl

Total release size: 116.0 kB

Release files / flodr-0.2.0.tar.gz

Download URL flodr-0.2.0.tar.gz
Size 55.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7766b18719156fd5acdf843222e42765683de21c7c0c89070b1cf828318a5d8e
BLAKE2b-256 checksum
How to use checksums
6c881648e9480574f542ca271ef40d65ee97303e5a43feef0b5e79d37f5a812f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / flodr-0.2.0-py3-none-any.whl

Download URL flodr-0.2.0-py3-none-any.whl
Size 60.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f9da7b410248f21fc6f2215016cb5c29c62f376e2c7a4770d77219f90e09d1f
BLAKE2b-256 checksum
How to use checksums
90796a76aa139694890a3286be497136d0e6438d48a9602c7ea45cee91569c4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for flodr 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page