<jupyter_start><jupyter_text>Revisiting the Iris Dataset Using pandas, seaborn and scilearn we will now reexamine the Iris Dataset we saw last year. - Notes and demos from lectures on October 26th 2018.<jupyter_code>import pandas as pd
import numpy as np
import matplotlib as plt
import seaborn as sns
import sklearn.neighbors as nei

df = pd.read_csv('iris-data.csv', header = None, 
                 names = ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal width', 'Species'])
df
sns.pairplot(df, hue="Species");<jupyter_output><empty_output><jupyter_text>What is classification? When I was naming the headings in my DataFrame. I referred to the differing species, but let's call the species, three different classes. From the information <NAME> collected, could I classify a random flower as been either Setosa, Virginica and Versicolor, given only its sepal and petal measurements??This is our classification problem. Can I predict the class based on other variables?I'll change my DataFrame heading from species to class, to better reflect the problem I'm now looking at.<jupyter_code>df = pd.read_csv('iris-data.csv', header = None, 
                 names = ['sepal length', 'sepal width', 'petal length', 'petal width', 'class'])<jupyter_output><empty_output><jupyter_text>**What I know about the type of data I have:**- Length will be a positive float- Continuous Numerical DataWhereas the class can only take three values; Setosa, Virginica and Versicolor. This data is categorical nominal.  K Nearest Neighbours Algorithm If I was to measure petal length and sepal width of a Iris flower I have found. If I was to plot this on the plot of Petal Length vs Sepal Width I already have from Fisher's data. K nearest neighbors will measure the distance of this point from the 150 other data points. If k is 5, the algorithm will pick the 5 closest points in terms of distance. The class of the majority of points in my nearest neighbors will be the classification of my new point.<jupyter_code>#Plotting Petal Length vs Sepal Width for visualiation
petal_length = np.array(df.iloc[:, 2])
sepal_width = np.array(df.iloc[:, 1])
species = (df.iloc[:, 4])

data = {'Petal Length': petal_length, 'Sepal Width': sepal_width, 'Class': species}
dataf = pd.DataFrame(data)
sns.pairplot(dataf, hue='Class');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07909362975630611, 'fraction_numerical': 0.005985463873450192, 'mean_word_length': 4.909090909090909, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '261414', 'license': 'Apache-2.0', 'n_tokens_mistral': 701, 'n_tokens_neox': 662, 'n_words': 314, 'path': 'lecture_notes/7revisiting-iris/revisiting-iris.ipynb', 'repo_name': 'MarionMcG/fundamentals_data_analysis', 'size': '2346'}