Rust-accelerated batch-learning SOM for FlowSOM
Project description
flowsom-rs
Rust SOM training for FlowSOM, via PyO3.
Implements the batch-learning SOM from Otsuka et al. 2025 with rayon parallelism. Unlike FlowSOM's online SOM, the batch algorithm processes all events simultaneously each epoch, so results are deterministic regardless of input event order.
Install
pip install flowsom-rs
Requires Python ≥ 3.10 and numpy ≥ 1.24.
Quick start
import numpy as np
import flowsom_rs
from scipy.spatial.distance import pdist, squareform
data = np.random.randn(500_000, 7)
# SOM grid setup (same format FlowSOM_Python uses)
grid = [(x, y) for x in range(10) for y in range(10)]
nhbrdist = squareform(pdist(grid, metric="chebyshev"))
radii = (np.quantile(nhbrdist, 0.67), 0.0)
codes = data[np.random.choice(len(data), 100, replace=False)]
# Train
codes, bmu_idx, bmu_dist = flowsom_rs.train_batch_som(
data, codes, nhbrdist, radii, rlen=10
)
Functions
train_batch_som(data, codes, nhbrdist, radii, rlen, n_threads=None)
Batch-learning SOM. Parallel BMU search + accumulation. Deterministic.
Returns (codes, bmu_indices, bmu_distances).
train_online_som(data, codes, nhbrdist, alphas, radii, rlen, seed)
Sequential Kohonen SOM, same algorithm as FlowSOM_Python's SOMEstimator.
train_replicas_som(data, codes, nhbrdist, alphas, radii, rlen, num_replicas=10, seed=42, n_threads=None)
Parallel replicas merged via median, same approach as FlowSOM_Python's BatchSOMEstimator.
map_data_to_codes(data, codes)
Parallel nearest-code assignment. Returns (indices, distances).
Benchmarks
10×10 grid, 10 epochs, Apple Silicon:
| Events | Numba Online | Rust Batch | Speedup |
|---|---|---|---|
| 50K | 364 ms | 44 ms | 5.9× |
| 100K | 491 ms | 85 ms | 6.4× |
| 500K | 2,709 ms | 391 ms | 6.9× |
Thread scaling at 500K events: 1→2→4→8 threads gives 1.0→2.0→3.3→4.6× speedup.
Build from source
pip install maturin
maturin develop --release
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flowsom_rs-0.1.0.tar.gz.
File metadata
- Download URL: flowsom_rs-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e2c1fa82aea328ef1b0633114f738b2d1ab18eeef87676d053e8a8cb70762d2
|
|
| MD5 |
6665d74d566fa5fdc5b0b23d305dc498
|
|
| BLAKE2b-256 |
7623f66c1514c1483f0b9d5c1c164546520c0385d9be328c713820e3840a59af
|
File details
Details for the file flowsom_rs-0.1.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: flowsom_rs-0.1.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 309.2 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51c7aea7c7a371bdd027f949dc3486edc44d28d92adf9913b4b81a3b62945580
|
|
| MD5 |
e195e477555f2310a4cf8699317b8fe9
|
|
| BLAKE2b-256 |
b71a9890424c67b5e1be458c1b7e2fa2e7ebd5bce6d6db03297eba3c56674b58
|
File details
Details for the file flowsom_rs-0.1.0-cp314-cp314-macosx_10_12_x86_64.whl.
File metadata
- Download URL: flowsom_rs-0.1.0-cp314-cp314-macosx_10_12_x86_64.whl
- Upload date:
- Size: 324.3 kB
- Tags: CPython 3.14, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b282854696166400a9287a3ceeaf9da9af394fb1a505f339fae507873e66f05
|
|
| MD5 |
9d2c6685f9d6ff6f2d2e3f68b6fc90e8
|
|
| BLAKE2b-256 |
420593b52c6b84db35890712e176ef2bd03df5dcbd6eb08ae5fc004a05c1cd4c
|
File details
Details for the file flowsom_rs-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: flowsom_rs-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 226.1 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f786f9d36790c37e3407f9d9f7686ac770ebb7380de44c888ebba5194bdeb26d
|
|
| MD5 |
f15728bfb0a1e529cdea8c4197b9b17d
|
|
| BLAKE2b-256 |
5d8d0884d978b23fd0e6b7bbfdd6a093fe815d4f7433fa05c9f98fb08fcbe1b0
|
File details
Details for the file flowsom_rs-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: flowsom_rs-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 355.3 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
068ca3c269a81283813dac76666d3ddc4f0d3e3559f600a287bfbe284b964d37
|
|
| MD5 |
8fe5bbb0fff02ff717906a42d41f2c86
|
|
| BLAKE2b-256 |
12c0d4ad2052eb87af7b6334fafa177c70b86a59632a924a48717f383967c9f7
|