<jupyter_start><jupyter_text>EDA (Exploratory Data Analysis)<jupyter_code>type(iris)
iris.keys()
iris.data.shape
iris.target_names
X = iris.data
y = iris.target
df = pd.DataFrame(X, columns=iris.feature_names)
df.head()
plot_1 = pd.plotting.scatter_matrix(df, c = y, figsize = [8, 8], s=150, marker ='D')<jupyter_output><empty_output><jupyter_text>k-Nearest Neighbors (kNN)<jupyter_code>knn = KNeighborsClassifier(n_neighbors=6)
knn.fit(iris['data'], iris['target'])
X_new = np.array([[5.6, 2.8, 3.9, 1.1], 
                 [5.7, 2.6, 3.8, 1.3],
                 [4.7, 3.2, 1.3, 0.2]])
prediction = knn.predict(X_new)
prediction<jupyter_output><empty_output><jupyter_text>kNN with Train/test split and score<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=21, stratify=y)
knn.fit(X_train, y_train)
y_pred = knn.predict(X_test)
print(f"Test set predictions:\n {y_pred}")
knn.score(X_test, y_test)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1647901740020471, 'fraction_numerical': 0.03582395087001024, 'mean_word_length': 5.608108108108108, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '74570', 'license': 'MIT', 'n_tokens_mistral': 454, 'n_tokens_neox': 434, 'n_words': 69, 'path': 'IrisDataset.ipynb', 'repo_name': 'JuanjoFernandez/MachineLearningAcademic', 'size': '977'}