Example of TSVM

In our Python implementation, we are going to use a bidimensional dataset similar to one employed in the previous method; however, in this case, we impose 400 unlabeled samples out of a total of 500 points:

from sklearn.datasets import make_classificationnb_samples = 500nb_unlabeled = 400X, Y = make_classification(n_samples=nb_samples, n_features=2, n_redundant=0, random_state=1000)Y[Y==0] = -1Y[nb_samples - nb_unlabeled:nb_samples] = 0

The corresponding plot is shown in the following graph:

Original labeled and unlabeled dataset

The procedure is similar to the one we used before. First of all, we need to initialize our variables: ...

Get Python: Advanced Guide to Artificial Intelligence 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.