<jupyter_start><jupyter_text>Lab 8 Assignment:  Please type your name here: Do not forget to change the filename with your name appendedIn this lab please fill the indicated cells with your code and explainations, ***run*** everything (select `cell` in the menu, and click `Run all`), save the notebook with your name appended to the filename (for example, `Lab-09-assignment-caos.ipynb`), and upload it to Canvas.This lab assignment contains one problem about PCA/SVD. The second one is optional.Read each problem carefully and answer them the best you can. You may copy the code from the kNN Lecture's notebook.For how to use a function, instead of asking others (TA, friend, your neighbor), you can put the cursor inside an empty parenthesis, press `Shift + Tab` (hold the shift key, press tab) to read the help in the pop up window.<jupyter_code># you might find the following useful
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Problem 1: PCA on the Iris dataset* Load the Iris dataset using `scikit-learn`'s dataset package.* Let `X` be the data, and `y` be the target in the data you have loaded.* Apply PCA on `X`, transform `X` to `X_reduced` using two eigenvectors corresponding to the two largest singular value to reduce its dimension.* Split the data `X_reduced` and `y` into 60% training and 40% testing datasets.* Apply $k$NN with $k=5$ on this reduced test dataset to classify the Iris flowers and print the accuracy.After you have done so, please run the following cell to visualized the reduced data (expected output plotted).<jupyter_code>import seaborn as sns
sns.set()
sns.scatterplot(x= X_reduced[:,0], y = X_reduced[:,1], hue=y)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07556818181818181, 'fraction_numerical': 0.00625, 'mean_word_length': 5.222614840989399, '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': '559899', 'license': 'Apache-2.0', 'n_tokens_mistral': 510, 'n_tokens_neox': 482, 'n_words': 258, 'path': 'matematica-para-datascience/Labs/Lab-08-assignment.ipynb', 'repo_name': 'ddiestra/OpenSource-RoadMap-DataScience', 'size': '1760'}