torchsom

TorchSOM is a PyTorch-based library for training Self-Organizing Maps (SOMs), a type of unsupervised learning algorithm used for clustering and dimensionality reduction. Designed for scalability and ease of use, this implementation is optimized for large-scale data.

https://github.com/michelin/torchsom

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: springer.com
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.6%) to scientific vocabulary

Keywords

clustering clustering-algorithm data-visualisation dimensionality-reduction-algorithms dimensionality-reduction-technique just-in-time just-in-time-learning pytorch pytorch-implementation self-organizing-maps unsupervised-machine-learning
Last synced: 6 months ago · JSON representation

Repository

TorchSOM is a PyTorch-based library for training Self-Organizing Maps (SOMs), a type of unsupervised learning algorithm used for clustering and dimensionality reduction. Designed for scalability and ease of use, this implementation is optimized for large-scale data.

Basic Info
Statistics
  • Stars: 8
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 3
Topics
clustering clustering-algorithm data-visualisation dimensionality-reduction-algorithms dimensionality-reduction-technique just-in-time just-in-time-learning pytorch pytorch-implementation self-organizing-maps unsupervised-machine-learning
Created 12 months ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

torchsom: The Reference PyTorch Library for Self-Organizing Maps

[![PyPI version](https://img.shields.io/pypi/v/torchsom.svg?color=blue)](https://pypi.org/project/torchsom/) [![Python versions](https://img.shields.io/pypi/pyversions/torchsom.svg?color=blue)](https://pypi.org/project/torchsom/) [![PyTorch versions](https://img.shields.io/badge/PyTorch-2.7-EE4C2C.svg)](https://pytorch.org/) [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/license/apache-2-0) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=michelin_TorchSOM&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=michelin_TorchSOM) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=michelin_TorchSOM&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=michelin_TorchSOM) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=michelin_TorchSOM&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=michelin_TorchSOM) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=michelin_TorchSOM&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=michelin_TorchSOM) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=michelin_TorchSOM&metric=coverage)](https://sonarcloud.io/summary/new_code?id=michelin_TorchSOM) [![Tests](https://github.com/michelin/TorchSOM/workflows/Tests/badge.svg)](https://github.com/michelin/TorchSOM/actions/workflows/test.yml) [![Code Quality](https://github.com/michelin/TorchSOM/workflows/Code%20Quality/badge.svg)](https://github.com/michelin/TorchSOM/actions/workflows/code-quality.yml) [![Downloads](https://static.pepy.tech/badge/torchsom)](https://pepy.tech/project/torchsom) [![GitHub stars](https://img.shields.io/github/stars/michelin/TorchSOM.svg?style=social&label=Star)](https://github.com/michelin/TorchSOM) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Imports: isort](https://img.shields.io/badge/imports-isort-6c757d.svg?color=blue)](https://pycqa.github.io/isort/) [![Ruff](https://img.shields.io/badge/linter-ruff-6c757d.svg?color=blue)](https://github.com/astral-sh/ruff)

TorchSOM_logo

**A modern, comprehensive and GPU-accelerated PyTorch implementation of Self-Organizing Maps for scalable ML workflows** [📚 Documentation](https://opensource.michelin.io/TorchSOM/) | [🚀 Quick Start](#-quick-start) | [📊 Examples](notebooks/) | [🤝 Contributing](CONTRIBUTING.md) **⭐ If you find [`torchsom`](https://github.com/michelin/TorchSOM) valuable, please consider starring this repository ⭐**

🎯 Overview

Self-Organizing Maps (SOMs) remain highly relevant in modern machine learning (ML) due to their interpretability, topology preservation, and computational efficiency. They excel and are widely used in domains such as energy systems, biology, internet of things (IoT), environmental science, and industrial applications.

Despite their utility, the SOM ecosystem is fragmented. Existing implementations are often outdated, unmaintained, and lack GPU acceleration or modern deep learning (DL) framework integration, limiting adoption and scalability.

torchsom addresses these gaps as a reference PyTorch library for SOMs. It provides:

  • GPU-accelerated training
  • Advanced clustering capabilities
  • A scikit-learn-style API for ease of use
  • Rich visualization tools
  • Robust software engineering practices

torchsom enables researchers and practitioners to integrate SOMs seamlessly into workflows, from exploratory data analysis to advanced model architectures.

This library accompanies the paper: torchsom: The Reference PyTorch Library for Self-Organizing Maps. If you use torchsom in academic or industrial work, please cite both the paper and the software (see CITATION).

Note: See the comparison table below to understand how torchsom differs from other SOM libraries, and explore our Visualization Gallery for example outputs.

⚡ Why torchsom?

Unlike legacy implementations, torchsom is engineered from the ground up for modern ML workflows:

| | torchsom | MiniSom | SimpSOM | SOMPY | somoclu | som-pbc | |---|---|---|---|---|---|---| | Architecture Section | | | | | | | | Framework | PyTorch | NumPy | NumPy | NumPy | C++/CUDA | NumPy | | GPU Acceleration | ✅ CUDA | ❌ | ✅ CuPy/CUML | ❌ | ✅ CUDA | ❌ | | API Design | scikit-learn | Custom | Custom | MATLAB | Custom | custom | | Development Quality Section | | | | | | | | Maintenance | ✅ Active | ✅ Active | ⚠️ Minimal | ⚠️ Minimal | ⚠️ Minimal | ❌ | | Documentation | ✅ Rich | ❌ | ⚠️ Basic | ❌ | ⚠️ Basic | ⚠️ Basic | | Test Coverage | ✅ ~86% | ❌ | 🟠 ~53% | ❌ | ⚠️ Minimal | ❌ | | PyPI Distribution | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | | Functionality Section | | | | | | | | Visualization | ✅ Advanced | ❌ | 🟠 Moderate | 🟠 Moderate | ⚠️ Basic | ⚠️ Basic | | Clustering | ✅ Advanced | ❌ | ❌ | ❌ | ❌ | ❌ | | JITL support | ✅ Built-in | ❌ | ❌ | ❌ | ❌ | ❌ | | SOM Variants | 🚧 In development | ❌ | 🟠 PBC | ❌ | 🟠 PBC | 🟠 PBC | | Extensibility | ✅ High | 🟠 Moderate | ⚠️ Low | ⚠️ Low | ⚠️ Low | ⚠️ Low |

Note: torchsom supports Just-In-Time Learning (JITL). Given an online query, JITL collects relevant datapoints to form a local buffer (selected first by topology, then by distance). A lightweight local model is then trained on this buffer, enabling efficient supervised learning (regression or classification).


📑 Table of Contents


🚀 Quick Start

Get started with torchsom in just a few lines of code:

```python import torch from torchsom.core import SOM from torchsom.visualization import SOMVisualizer

Create a 10x10 map for 3D input

som = SOM(x=10, y=10, num_features=3, epochs=50)

Train SOM for 50 epochs on 1000 samples

X = torch.randn(1000, 3) som.initialize_weights(data=X, mode="pca") QE, TE = som.fit(data=X)

Visualize results

visualizer = SOMVisualizer(som=som, config=None) visualizer.plottrainingerrors(quantizationerrors=QE, topographicerrors=TE, savepath=None) visualizer.plothitmap(data=X, batchsize=256, savepath=None) visualizer.plotdistancemap( savepath=None, distancemetric=som.distancefnname, neighborhoodorder=som.neighborhood_order, scaling="sum" ) ```

📓 Tutorials

Explore our comprehensive collection of Jupyter notebooks:

🎨 Visualization Gallery

🗺️ D-Matrix Visualization

Michelin production line (regression)

U-Matrix
📍 Hit Map Visualization

Michelin production line (regression)

Hit Map
📊 Mean Map Visualization

Michelin production line (regression)

Mean Map
🗺️ Component Planes Visualization

Another Michelin line (regression)

Component Plane 1 Component Plane 2
🏷️ Classification Map

Wine dataset (multi-classification)

Classification Map
📊 Cluster Metrics

Clustering analysis

Cluster Metrics
📈 K-Means Elbow

Optimal cluster selection

K-Means Elbow
🎯 HDBSCAN Cluster Map

Cluster visualization

HDBSCAN Cluster Map


💾 Installation

📦 PyPI

bash pip install torchsom

🔧 Development Version

bash git clone https://github.com/michelin/TorchSOM.git cd TorchSOM python3.9 -m venv .torchsom_env source .torchsom_env/bin/activate pip install -e ".[all]"


📚 Documentation

Comprehensive documentation is available at opensource.michelin.io/TorchSOM


📝 Citation

If you use torchsom in your academic, research or industrial work, please cite both the paper and software:

```bibtex @inproceedings{Berthier2025TorchSOM, title={torchsom: The Reference PyTorch Library for Self-Organizing Maps}, author={Berthier, Louis}, booktitle={Conference Name}, year={2025} }

@software{BerthierTorchSOMTheReference2025, author={Berthier, Louis}, title={torchsom: The Reference PyTorch Library for Self-Organizing Maps}, url={https://github.com/michelin/TorchSOM}, version={1.0.0}, year={2025} } ```

For more details, please refer to the CITATION file.


🤝 Contributing

We welcome contributions from the community! See our Contributing Guide and Code of Conduct for details.


🙏 Acknowledgments


📄 License

torchsom is licensed under the Apache License 2.0. See the LICENSE file for details.


📚 Related Work and References

📖 Foundational Literature Papers

🔗 Related Softwares

  • MiniSom: Minimalistic Python SOM
  • SimpSOM:Simple Self-Organizing Maps
  • SOMPY: Python SOM library
  • somoclu: Massively Parallel Self-Organizing Maps
  • som-pbc: A simple self-organizing map implementation in Python with periodic boundary conditions
  • SOM Toolbox: MATLAB implementation

Owner

  • Name: Michelin
  • Login: michelin
  • Kind: organization
  • Location: Clermont-Ferrand, France

Michelin Open Source Platform

GitHub Events

Total
  • Release event: 1
  • Watch event: 5
  • Delete event: 1
  • Push event: 31
  • Pull request event: 2
  • Create event: 5
Last Year
  • Release event: 1
  • Watch event: 5
  • Delete event: 1
  • Push event: 31
  • Pull request event: 2
  • Create event: 5

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • LouisTier (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 223 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
pypi.org: torchsom

torchsom: The Reference PyTorch Library for Self-Organizing Maps

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 223 Last month
Rankings
Dependent packages count: 8.7%
Average: 28.8%
Dependent repos count: 48.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

pyproject.toml pypi
  • matplotlib *
  • numpy *
  • torch *
  • tqdm *
.github/workflows/docs.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • peaceiris/actions-gh-pages v3 composite