Skip to main content

PyPI version fury.io Downloads

sklearn_minisom

MiniSom is Numpy based implementation of the Self Organizing Maps (SOM). SOM is a type of Artificial Neural Network able to convert complex, nonlinear statistical relationships between high-dimensional data items into simple geometric relationships on a low-dimensional display. Minisom is designed to allow researchers to easily build on top of it and to give students the ability to quickly grasp its details.

This is MiniSom library wrapper for seamless integration with SciKit-learn package.

Credits to:

This wrapper aims to integrate SklearnMinisom library into SciKit-learn ecosystem. It enables easy integration with Scikit-learn pipelines and tools like GridSearchCV for hyperparameter optimization. It also provides easy, scikit-learn like API for developers to interact with while aiming to sustain high flexibility and capabilities of MiniSom library.

Example clustering datasets from Comparation of clustering algorithms on SciKit-learn

image

This is separate project and not part of MiniSom library due to creator's of the original project aim to keep their as lightweight as possible.

Table of content

Installation

Just use pip:

pip install sklearn_minisom

or uv:

uv add sklearn_minisom

Dependencies:

  • minisom>=2.3.6
  • scikit-learn
  • numpy

Examples

Just use it like any other scikit-learn cluster algorithm.

Let's start with importing required libraries and dataset.

from sklearn.datasets import load_wine
from sklearn_minisom import SklearnMinisom
from sklearn.preprocessing import StandardScaler

data = load_wine()
X = data.data
X = StandardScaler().fit_transform(X)

You can use fit and predict separately.

som = SklearnMinisom(3, 1, random_seed=40)
som.fit(X)
y = som.predict(X)

Or simply use convenient function.

som = SklearnMinisom(3, 1, random_seed=40)
y = som.fit_predict(X)

Alternatively you can also use SciKit-learn pipelines.

from sklearn.pipeline import Pipeline

pipeline = ([
    ('scaler', StandardScaler()),
    ('classifier', SklearnMinisom(3, 1, random_seed=40))
])

y = pipeline.fit_predict(X)

Now let's take a look at what we've got.

image-1

Contributing

This project follows Google Code Style guidelines. There is already configured pre-commit hook which is also part of CI. Before commiting please make sure you have pre-commit installed and run:

pre-commit install

After that, formatter and basic linters will be run automatically before each commit.

Release files for sklearn_minisom 0.1.1

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

Source distribution (sdist)

Source distribution for sklearn_minisom 0.1.1
File Size Uploaded
sklearn_minisom-0.1.1.tar.gz 5.7 kB Details

Built distribution (wheel)

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

Total release size: 12.5 kB

Release files / sklearn_minisom-0.1.1.tar.gz

Download URL sklearn_minisom-0.1.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
de2952e170327114ba85a7870bf57656fcb2f111f5752d9ef1a83ba737e673f9
BLAKE2b-256 checksum
How to use checksums
a7098c75c89fe78e2a483f33a2b0fb754080f604c23ca7b663b1da4d3fedce71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.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 / sklearn_minisom-0.1.1-py3-none-any.whl

Download URL sklearn_minisom-0.1.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
000771264bb5babd38cee3d6b2caab4d0d923195390e0f74e49c89b4ee6d40fa
BLAKE2b-256 checksum
How to use checksums
919c62255c5a135e75b83643d9369700bf366182b8ff5fe3c3e35f946611ffb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.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 history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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