gemclus.add_mlcl_constraint

gemclus.add_mlcl_constraint(gemini_model, must_link=None, cannot_link=None, factor=1.0)[source]

Adds must-link and/or cannot-link constraints to a discriminative clustering model. The contraints are ensure by respectively minimising or maximising the \(\ell_2\) norm between the prediction vectors. It is thus possible that not all constraints are fully satisfied.

Parameters:
gemini_model: MLP___, Linear___ or Categorical___

A GemClus model that involves gemini maximisation with gradient descent.

must_link: ndarray of shape (n_constraints, 2) or None, default=None

The constraints of samples being together must be described by a list of pairs of indices [(i1,j1),…, (iN, jN)]. If set to None, no must-link constraint is applied on the model.

cannot_link: ndarray of shape (n_constraints, 2) or None, default=None

The constraints of samples which must not be in the same cluster must be described by a list of pairs of indices [(i1,j1),…, (iN, jN)]. If set to None, no cannot-link constraint is applied on the model.

factor: float, default=1.0

A weighting hyperparameter for the constraints in gradient descent.

Returns:
The model gemini model with decorated gradient functions to satisfy must-link / cannot-link constraints.

Examples using gemclus.add_mlcl_constraint

Consensus clustering with linking constraints on sample pairs

Consensus clustering with linking constraints on sample pairs