Multi-View NMF

The MultiViewNMF class performs consensus clustering with a shared non-negative representation across views. It can optionally learn per-view weights based on reconstruction quality.

class polyview.cluster.mv_nmf.MultiViewNMF(*args: Any, **kwargs: Any)

Bases: BaseMultiViewClusterer

Multi-view Non-negative Matrix Factorisation clustering.

Finds a shared non-negative coefficient matrix H (the consensus representation) and per-view basis matrices W(v) by jointly minimising weighted Frobenius reconstruction error across all views.

\[\min_{H} \sum_{v=1}^{M} \lambda_v \left\|X^{(v)} - H W^{(v)}\right\|_F^2 \quad \text{s.t.} \quad H \ge 0\]

The row argmax of H gives cluster labels. H itself is a soft assignment matrix useful as a low-dimensional embedding.

Parameters:
  • n_components (int, default=2) – Rank k of the factorisation — number of clusters / latent dims.

  • max_iter (int, default=200) – Maximum number of multiplicative update iterations.

  • n_init (int, default=10) – Number of random initialisations; best (lowest objective) is kept.

  • tol (float, default=1e-4) – Stop when relative change in objective falls below this.

  • learn_weights (bool, default=False) – If True, adapt per-view weights lambda(v) from reconstruction quality. If False (default), use equal weights 1/M.

  • gamma (float, default=2.0) – Controls weight concentration when learn_weights=True. Higher gamma -> more uniform weights (approaches equal weighting). Only used when learn_weights=True.

  • eps (float, default=1e-10) – Small floor added to denominators to prevent division by zero, and used to clip H and W away from exact zero.

  • random_state (int or None, default=None)

H_

Shared non-negative coefficient matrix (soft cluster assignments).

Type:

ndarray of shape (n_samples, n_components)

W_

Per-view basis matrices.

Type:

list of ndarray, shape (n_components, n_features_v)

weights_

Final per-view reconstruction weights lambda(v). Equal to 1/M when learn_weights=False.

Type:

ndarray of shape (n_views,)

labels_

Hard cluster labels = argmax(H_, axis=1).

Type:

ndarray of shape (n_samples,)

reconstruction_errors_

Per-view Frobenius reconstruction error at convergence.

Type:

ndarray of shape (n_views,)

objective_

Weighted sum of reconstruction errors at convergence.

Type:

float

n_iter_

Number of iterations performed in the best run.

Type:

int

Examples

>>> from polyview.cluster.mv_nmf import MultiViewNMF
>>> model = MultiViewNMF(n_components=3, random_state=0)
>>> labels = model.fit_predict([X1, X2])
>>> model.H_.shape
(n_samples, 3)

Use H_ as a soft embedding downstream:

>>> from sklearn.cluster import KMeans
>>> labels = KMeans(n_clusters=3).fit_predict(model.H_)

Or use H_ as cluster probabilities for soft clustering:

>>> labels = np.argmax(model.H_, axis=1)

References

  • Gao, J., He, L., Zhang, X., Zhou, J., & Wu, D. (2013). Multi-view clustering via joint nonnegative matrix factorization. In Proceedings of the 2013 SIAM International Conference on Data Mining (SDM).

fit(views: List, y=None) MultiViewNMF

Fit the model.

Parameters:
  • views (list of array-like of shape (n_samples, n_features_v)) – All values should be non-negative. Negative values are clipped to zero before factorisation with a warning.

  • y (ignored)

Return type:

self

fit_predict(views: List, y=None) numpy.ndarray

Fit and return cluster labels.

fit_transform(views: List, y=None) numpy.ndarray

Fit and return H_ directly (no re-projection needed).

transform(views: List) numpy.ndarray

Project new samples into the shared H space.

Solves the NNLS problem for H given fixed W(v) via the same multiplicative update rule, starting from a uniform initialisation, with W(v) held fixed.

Parameters:

views (list of array-like of shape (n_samples_new, n_features_v))

Returns:

H_new

Return type:

ndarray of shape (n_samples_new, n_components)