April 2018
Beginner to intermediate
300 pages
7h 34m
English
Let's first reorder the data points according to the handwritten numbers:
import numpy as npX = np.vstack([digits.data[digits.target==i]for i in range(10)])y = np.hstack([digits.target[digits.target==i] for i in range(10)])
y will become array([0, 0, 0, ..., 9, 9, 9]).
Note that the t-SNE transformation can take minutes to compute on a regular laptop, and the tSNE command can be simply run as follows. We will first try running t-SNE with 250 iterations:
#Here we run tSNE with 250 iterations and time it%%timeittsne_iter_250 = TSNE(init='pca',method='exact',n_components=2,n_iter=250).fit_transform(X)
Let's draw a scatter plot to see how the data cluster:
#We import the pandas and matplotlib librariesimport ...
Read now
Unlock full access