May 2018
Intermediate to advanced
576 pages
14h 42m
English
We can test this algorithm using the Scikit-Learn implementation. Let's start by creating a very dense dataset:
from sklearn.datasets import make_classificationnb_samples = 5000nb_unlabeled = 1000X, Y = make_classification(n_samples=nb_samples, n_features=2, n_informative=2, n_redundant=0, random_state=100)Y[nb_samples - nb_unlabeled:nb_samples] = -1
We can train a LabelSpreading instance with a clamping factor alpha=0.2. We want to preserve 80% of the original labels but, at the same time, we need a smooth solution:
from sklearn.semi_supervised import LabelSpreadingls = LabelSpreading(kernel='rbf', gamma=10.0, alpha=0.2)ls.fit(X, Y)Y_final = ls.predict(X)
The result is shown, as usual, together with the original ...
Read now
Unlock full access