fuzzyclust.coclustering.FCCM#

class fuzzyclust.coclustering.FCCM(n_clusters=3, lambda_u=1.0, lambda_w=1.0, tol=0.0001, max_iter=300, init='random', n_init=1, random_state=None, verbose=0)[source]#

Bases: _BaseFuzzyCoClustering

Fuzzy clustering for categorical multivariate data, FCCM (Oh, Honda, and Ichihashi, 2001).

A document–term matrix, a user–item purchase table or any other non-negative cooccurrence matrix \(\mathbf{R}\) has two sets of entities: objects (rows) and items (columns). Co-clustering looks for pairs of an object group and an item group that cooccur strongly – a topic together with its vocabulary. FCCM assigns a fuzzy membership to both the objects and the items of every co-cluster and maximizes the aggregation degree of the pairs, regularized by the entropies of both membership sets so that the solution stays fuzzy. Unlike k-means type clustering of the rows it needs no distance between sparse count vectors, and it returns, per cluster, which items characterize it.

Parameters:
n_clustersint, default=3

Number of co-clusters \(c\).

lambda_ufloat, default=1.0

Entropy weight \(\lambda_u>0\) of the object memberships. It is measured in the units of a row’s aggregation \(a_{ik}=\sum_j w_{ij}r_{kj}\), which is a weighted mean of the row’s entries over the items of the co-cluster – so a value comparable to the typical entry of \(\mathbf{R}\) gives a moderately fuzzy partition, a much smaller value a nearly crisp one.

lambda_wfloat, default=1.0

Entropy weight \(\lambda_w>0\) of the item memberships, in the units of a column’s aggregation \(b_{ij}=\sum_k u_{ik}r_{kj}\), which is a weighted sum over the objects of the co-cluster and therefore grows with the number of objects.

tolfloat, default=1e-4

Termination tolerance on \(\max|\Delta u_{ik}|\).

max_iterint, default=300
init{“random”, “kmeans++”} or ndarray of shape (n_objects, n_clusters), default=”random”
n_initint, default=1

Random restarts; the run with the largest objective is kept.

random_stateint, RandomState instance or None, default=None
verboseint, default=0
Attributes:
membership_ndarray of shape (n_objects, n_clusters)

Object memberships \(u_{ik}\) (rows sum to one).

item_membership_ndarray of shape (n_items, n_clusters)

Item memberships \(w_{ij}\); every column (co-cluster) sums to one, so the entries are the share of the co-cluster’s item mass and are small when the vocabulary of a cluster is large.

labels_ndarray of shape (n_objects,)

Hard object labels.

item_labels_ndarray of shape (n_items,)

Co-cluster in which every item has its largest membership.

aggregation_float

Final aggregation degree \(\sum_{ikj}u_{ik}w_{ij}r_{kj}\).

objective_, objective_history_, n_iter_

Regularized objective (maximized) and its history.

Notes

With object memberships \(u_{ik}\) (cluster \(i\), object \(k\)) and item memberships \(w_{ij}\) (item \(j\)), FCCM maximizes

\[J = \sum_{i=1}^{c}\sum_{k=1}^{N}\sum_{j=1}^{M} u_{ik}w_{ij}r_{kj} - \lambda_u\sum_{i=1}^{c}\sum_{k=1}^{N} u_{ik}\log u_{ik} - \lambda_w\sum_{i=1}^{c}\sum_{j=1}^{M} w_{ij}\log w_{ij}\]

subject to \(\sum_{i}u_{ik}=1\) and \(\sum_{j}w_{ij}=1\). Without the entropy terms the maximum is crisp and degenerate (one cluster takes everything); the terms are the entropy regularization of Miyamoto and Mukaidono, and the necessary conditions are soft-max assignments

\[u_{ik} = \frac{\exp\big(\sum_j w_{ij}r_{kj}/\lambda_u\big)} {\sum_{l=1}^{c}\exp\big(\sum_j w_{lj}r_{kj}/\lambda_u\big)},\qquad w_{ij} = \frac{\exp\big(\sum_k u_{ik}r_{kj}/\lambda_w\big)} {\sum_{l=1}^{M}\exp\big(\sum_k u_{ik}r_{kl}/\lambda_w\big)},\]

iterated alternately until the object memberships settle. New rows receive memberships through the first formula with the fitted item memberships (predict_proba()).

References

[1]

C.-H. Oh, K. Honda, H. Ichihashi, “Fuzzy clustering for categorical multivariate data”, Proc. Joint 9th IFSA World Congress and 20th NAFIPS International Conference, 2154–2159, 2001.

[2]

S. Miyamoto, M. Mukaidono, “Fuzzy c-means as a regularization and maximum entropy approach”, Proc. 7th IFSA World Congress, vol. 2, 86–92, 1997.

Examples

>>> from fuzzyclust.coclustering import FCCM, make_block_matrix
>>> R, rows, cols = make_block_matrix(random_state=0)
>>> fccm = FCCM(n_clusters=3, lambda_u=1.0, lambda_w=20.0, random_state=0).fit(R)
>>> fccm.membership_.shape, fccm.item_membership_.shape
((120, 3), (60, 3))

Examples using fuzzyclust.coclustering.FCCM#

Fuzzy co-clustering of a document–term matrix

Fuzzy co-clustering of a document--term matrix