For this Python example of label propagation based on Markov random walks, we are going to use a bidimensional dataset containing 50 labeled samples belonging to two different classes, and 1,950 unlabeled samples:
from sklearn.datasets import make_blobsnb_samples = 2000nb_unlabeled = 1950nb_classes = 2X, Y = make_blobs(n_samples=nb_samples, n_features=2, centers=nb_classes, cluster_std=2.5, random_state=500)Y[nb_samples - nb_unlabeled:] = -1
The plot of the dataset is shown in the following diagram (the crosses represent the unlabeled samples):
We can now ...