diff --git a/notebooks/1_visualize_text.ipynb b/notebooks/1_visualize_text.ipynb index d7a9690..4084840 100644 --- a/notebooks/1_visualize_text.ipynb +++ b/notebooks/1_visualize_text.ipynb @@ -225,6 +225,10 @@ "source": [ "# lambdas = eigenvalues\n", "print(kpca.lambdas_[:10])\n", + "# check how much \"information\" we would keep if we were to reduce the dimensionality to 20\n", + "# (this is not 100% accurate, since we only computed the first 100 kPCA components, i.e.,\n", + "# normally lambda_ should contain all eigenvalues - but this should be close enough)\n", + "print(\"Percentage of variance retained with 20 components:\", 100*(sum(kpca.lambdas_[:20])/sum(kpca.lambdas_)))\n", "# plot eigenvalue spectrum\n", "plt.figure()\n", "plt.plot(range(1, len(kpca.lambdas_)+1), kpca.lambdas_)\n", diff --git a/notebooks/2_image_quantization.ipynb b/notebooks/2_image_quantization.ipynb index bc17d00..5b4b932 100644 --- a/notebooks/2_image_quantization.ipynb +++ b/notebooks/2_image_quantization.ipynb @@ -54,7 +54,8 @@ "source": [ "# reshape image into a matrix with RGB values for each pixel\n", "h, w, d = img_array.shape\n", - "X = ... # TODO: reshape img_array such that X is a matrix of shape n_pixels x 3 RGB channels\n", + "X = new_X.reshape(h*w, d)\n", + "# 1 pixel = 1 data point; RGB values = features\n", "print(X.shape)" ] }, @@ -122,7 +123,7 @@ "outputs": [], "source": [ "# reshape back into image format\n", - "img_new = new_X.reshape(h, w, d)\n", + "img_new = ... # TODO: reshape new_X such that img_new is a matrix of shape height x width x 3 RGB channels\n", "print(img_new.shape)" ] },