fuzzyclust.large.extend_partition#

fuzzyclust.large.extend_partition(X, V, m=2.0, chunk_size=None)[source]#

Memberships of (many) samples in fixed prototypes (the extension step).

One FCM membership step with the prototypes held fixed,

\[\mu_{ik}=\frac{1}{\sum_{j=1}^{c}\big(D_{ik}/D_{jk}\big)^{2/(m-1)}},\qquad D^2_{ik}=\norm{\mathbf{x}_k-\mathbf{v}_i}^2 ,\]

evaluated chunk by chunk so that the working memory stays \(O(\text{chunk size}\cdot c)\). This is how rseFCM, spFCM and oFCM assign the whole data set to the clusters they found on samples or chunks.

Parameters:
Xarray_like of shape (n_samples, n_features)
Varray_like of shape (n_clusters, n_features)
mfloat, default=2.0
chunk_sizeint or None, default=None

Samples per chunk; None processes all samples at once.

Returns:
Undarray of shape (n_samples, n_clusters)
d2ndarray of shape (n_samples, n_clusters)

Squared Euclidean distances.

Examples

>>> import numpy as np
>>> from fuzzyclust.large import extend_partition
>>> X = np.array([[0.0], [1.0], [9.0], [10.0]])
>>> U, d2 = extend_partition(X, np.array([[0.5], [9.5]]))
>>> U.argmax(axis=1)
array([0, 0, 1, 1])