Skip to main content

GTM (Generative Topographic Mapping) is a dimensionality reduction algorithm (like t-SNE, LLE, etc.) created by Bishop et al. and a probabilistic counterpart of Kohonen maps. ugtm implements GTM and GTM-based prediction algorithms, including a kernel variant (kGTM), classification (GTC) and regression (GTR) maps, sklearn-compatible estimators, and repeated cross-validation.

Full documentation: https://ugtm.readthedocs.io/

Quick start

import ugtm
import numpy as np

data   = np.random.randn(100, 50)
labels = np.random.choice([1, 2], size=100)

gtm = ugtm.runGTM(data=data)

coordinates = gtm.matMeans   # mean positions  (n_samples, 2)
modes       = gtm.matModes   # mode positions  (n_samples, 2)
resp        = gtm.matR       # responsibilities (n_samples, n_nodes)

sklearn-compatible estimators

from ugtm import eGTM, eGTC, eGTR

transformed      = eGTM().fit(X_train).transform(X_test)
predicted_labels = eGTC().fit(X_train, y_train).predict(X_test)
predicted_values = eGTR().fit(X_train, y_train).predict(X_test)

Large datasets: incremental GTM (iGTM)

For datasets too large to hold the full N×K responsibility matrix in RAM, use iGTM (Gaspar et al. 2014). Data is processed in blocks; only two small accumulators are kept per iteration instead of the full N×K matrix:

from ugtm import runIGTM, eIGTM

# Low-level wrapper — same interface as runGTM
model = runIGTM(data, n_blocks=10)
coordinates = model.matMeans   # (n_samples, 2)

# sklearn transformer — n_blocks=0 chooses block size automatically
transformed = eIGTM().fit(X_train).transform(X_test)

# Block-wise projection for large test sets (generator, bounded memory)
for block in eIGTM().fit(X_train).transform_blocks(X_test, block_size=1000):
    pass  # process each (block_size, 2) chunk here

Visualisation

ugtm outputs are plain NumPy arrays — use any plotting library:

import matplotlib.pyplot as plt

gtm    = ugtm.runGTM(data=data)
coords = gtm.matMeans

plt.scatter(coords[:, 0], coords[:, 1], c=labels, cmap="Spectral_r")
plt.colorbar()
plt.show()

See https://ugtm.readthedocs.io/ for richer examples.

Predictions and cross-validation

# GTM classification / regression
predicted = ugtm.GTC(train=train, test=test, labels=labels)
predicted = ugtm.GTR(train=train, test=test, labels=activity)

# Repeated cross-validation
ugtm.crossvalidateGTC(data=train, labels=labels, s=1, regul=1)
ugtm.crossvalidateGTR(data=train, labels=activity, s=1, regul=1)

References

  1. GTM algorithm — Bishop et al. (1998)

  2. Kernel GTM — https://www.elen.ucl.ac.be/Proceedings/esann/esannpdf/es2010-44.pdf

  3. GTM classification models — https://www.ncbi.nlm.nih.gov/pubmed/24320683

  4. GTM regression models — https://www.ncbi.nlm.nih.gov/pubmed/27490381

  5. ugtm paper — https://openresearchsoftware.metajnl.com/articles/10.5334/jors.235/

  6. Incremental GTM — Gaspar et al. (2014), Chemical Data Visualization and Analysis with Incremental GTM: Big Data Challenge

Release files for ugtm 2.3.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 ugtm 2.3.0
File Size Uploaded
ugtm-2.3.0.tar.gz 47.2 kB Details

Built distribution (wheel)

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

Total release size: 84.7 kB

Release files / ugtm-2.3.0.tar.gz

Download URL ugtm-2.3.0.tar.gz
Size 47.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cadb80e2fda29f5d48d13cb31f0780d70a94150fa9c5fd87602603cc570ddb16
BLAKE2b-256 checksum
How to use checksums
2c01ecf686f48d78bc8bb9af692c56ee48e467cab02f06ef1033e3315d5da4a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / ugtm-2.3.0-py3-none-any.whl

Download URL ugtm-2.3.0-py3-none-any.whl
Size 37.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db46ecef9d00ef83bb5a146579ab8dbf40e8d5082e2b58ec8a44c0d6a43e8874
BLAKE2b-256 checksum
How to use checksums
7c37aea7fd0074c11833161f4d1358c3ee2171c25671bc67d00466854445ea0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

2.3.0 This release

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.0.0

1 release file

1.1.8

1 release file

1.1.7

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

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