Skip to main content

Generative Topographic Mapping (GTM) for Python: GTM classification and regression

Project description

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)

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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ugtm-2.2.1.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ugtm-2.2.1-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file ugtm-2.2.1.tar.gz.

File metadata

  • Download URL: ugtm-2.2.1.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ugtm-2.2.1.tar.gz
Algorithm Hash digest
SHA256 0ee0847ae36239c8db05ffc1e0f4ce11b36585ee8d21a1a4188e8362a9e98485
MD5 16ec11815edf7dc0d8f4af6e39aed103
BLAKE2b-256 0bd0ccd0176d99f7d89199ff33af44cced5d9b6af5131ebd44f58569219c93f8

See more details on using hashes here.

File details

Details for the file ugtm-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: ugtm-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ugtm-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0cc8539ed0574f8d4c1dcd5434050deee959f0fc27c253ccc7c0d2238b38c957
MD5 94c1dfb84da954c380d0160e0d3b7469
BLAKE2b-256 37dc2441ead006ce6b461f65f898c427fb6074c181ab3bf91ea526e7d9021925

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page