graphclust.vq.LBG#

class graphclust.vq.LBG(n_nodes=16, *, delta=0.001, max_iter=100, tol=1e-06, graph=True, random_state=None)[source]#

Bases: BaseTopologyLearner

Linde–Buzo–Gray vector quantizer: k-means with codebook splitting.

Starts from the centroid of the data, doubles the codebook by splitting every codevector \(\mathbf{w}\to\mathbf{w}(1\pm\delta)\) and refines the doubled codebook with k-means (Lloyd) iterations, until n_nodes codevectors exist (the last split adds only as many as needed). With graph=True the nodes are linked afterwards by competitive Hebbian learning (graphclust.graphs.competitive_hebbian_graph()).

Examples

>>> import numpy as np
>>> X = np.random.default_rng(0).normal(size=(200, 2))
>>> LBG(n_nodes=8, random_state=0).fit(X).nodes_.shape
(8, 2)