hatvis.learning.label_spreading#
- hatvis.learning.label_spreading(H, labels, alpha=0.9, class_mass_normalization=False)[source]#
Semi-supervised classification on a hypergraph (Zhou et al. 2006).
labelsmaps a subset of the vertices to classes (missing orNaNmeans unlabeled). The class scores are \(\mathbf{F}=(1-\alpha)(\mathbf{I}-\alpha\boldsymbol{\Theta})^{-1}\mathbf{Y}\), the minimizer of a smoothness term on the hypergraph plus a fit term. Returns the score matrix;.idxmax(axis=1)gives the predicted classes.The total score of a class grows with its number of labeled vertices, so an unbalanced labeled set biases the prediction towards the larger class.
class_mass_normalization=Truedivides every column of \(\mathbf{F}\) by its sum (class mass normalization with uniform class priors, after Zhu, Ghahramani and Lafferty 2003), which removes the bias.>>> H = Hypergraph([["a", "b", "c"], ["c", "d"], ["d", "e", "f"]]) >>> label_spreading(H, {"a": 0, "f": 1}).idxmax(axis=1).tolist() [0.0, 0.0, 0.0, 1.0, 1.0, 1.0]