Example of label propagation based on Markov random walks

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):

Partially labeled dataset

We can now ...

Get Mastering Machine Learning Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.