Valérie Monbet

teaching/enseignement

Machine Learning

LABS

2. Dimension reduction methods

Goal : use the dimension reduction methods on the digits dataset.
Example : code examples are provided for the old poteries data.

Steps
# Python
import matplotlib.pyplot as plt
from urllib.request import urlopen
url="https://perso.univ-rennes1.fr/valerie.monbet/doc/cours/digits_extrait_images.csv"
url="https://perso.univ-rennes1.fr/valerie.monbet/doc/cours/digits_extrait_labels.csv"
plt.imshow(np.reshape(digits[1,:],[28,28])) # plot of the 1st image
# R
url="https://perso.univ-rennes1.fr/valerie.monbet/doc/cours/digits_extrait_images.csv"
digits = digits[,-1]
url="https://perso.univ-rennes1.fr/valerie.monbet/doc/cours/digits_extrait_labels.csv"
labels = labels[,2]
image(matrix(as.matrix(digits[1,]),28,28,byrow=TRUE)) # plot of the 1st image

2. Vizualization with PCA
Run the PCA, plot the observations on the first plan with a color per digit

3. Reconstruction with PCA
Run the PCA, use the eigenvalues barplot to select a good number of components, reconstruct the images in the low dimension space.
Choose one image in the dataset, plot the initial image and its approximation.

4. Vizualization with MDS
Compare the plot obtained in 2. with the one obtained using MDS

5. Vizualization with t-SNE
Run t-SNE on the digits data for different perplexity.
Plot the results with a color per digit.

Codes: Poteries_DimensionReduction_FC.py, Poteries_DimensionReduction.R, digits_DimensionReduction_ToStart.py, digits_DimensionReduction_ToStart.R,