<jupyter_start><jupyter_text>Plot first eigenvectors of PCA<jupyter_code>fig, axs = plt.subplots(3,5, figsize = (15,9))
fig.suptitle('First components of PCA')

for idx, ax in enumerate(axs.flatten()):
    ax.imshow(np.reshape(-eig_vec[:,idx],[28,28]), interpolation='nearest', cmap='binary')
    ax.axis('off')<jupyter_output><empty_output><jupyter_text>Write digit using first N eigen vectors<jupyter_code>def digit_decomposition(digit, eigen_vec, terms=10):
       
    return np.dot(digit, eigen_vec)[:terms]
idx = np.random.randint(len(train_X))
display_image(train_X[idx,:])

digit_decomp = digit_decomposition(trian_X_vectors[idx], eig_vec, 100)
a = (digit_decomp * eig_vec[:,:len(digit_decomp)])
display_image(a.sum(axis=1))
digit_decomposition(trian_X_vectors[:1], eig_vec, 2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15460122699386503, 'fraction_numerical': 0.020858895705521473, 'mean_word_length': 8.379310344827585, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '356736', 'license': 'MIT', 'n_tokens_mistral': 344, 'n_tokens_neox': 316, 'n_words': 48, 'path': 'LectureV/Joris_LectureV_PCA_with_mnist_digits.ipynb', 'repo_name': 'Paijmans/ML_for_physicists', 'size': '815'}