24 Chapter 15, Machine Learning: Classification, Regression and Clustering
In [3]: from sklearn.manifold import TSNE
In [4]: tsne = TSNE(n_components=2, random_state=11)
c. When using TSNE on the Digits dataset bundled with scikit-learn, the TSNE es-
timator’s random_state keyword argument in Part (b) ensures the reproduci-
bility of the “render sequence” when we display the digit clusters, for example.
d. All of the above statements are true.
15.6 Q5: Which of the following statements a), b) or c) is false?
a. Dimensionality reduction in scikit-learn typically involves two steps—training
the estimator with the dataset, then using the estimator to transform the data into
the specified number of dimensions.
b. The steps mentioned in Part (a) can be performed separately with the TSNE
methods fit and transform, or they can be performed in one statement using
the fit_transform method, as in:
In [5]: reduced_data = tsne.fit_transform(digits.data)
c. TSNE’s fit_transform method takes some time to train the estimator then
perform the reduction. When the method completes its task, it returns an array
with the same number of rows as digits.data, but only the number of columns
specified by the n_components argument when you created the estimator object.
You can confirm this by checking reduced_data’s shape.
d. All of the above statements are true.
15.7 Case Study: Unsupervised Machine Learning,
Part 2—k-Means Clustering
15.7 Q1: Which of the following statements is false?
a. k-means clustering is perhaps the simplest unsupervised machine learning al-
gorithm.
b. The k-means clustering algorithm analyzes unlabeled samples and attempts to
place them in clusters that appear to be related.
c. The k in “k–means” represents the number of clusters to impose on the data.
d. The k-means clustering algorithm organizes samples into the number of clus-
ters you specify in advance, using distance calculations similar to the k-nearest
neighbors clustering algorithm.