<jupyter_start><jupyter_text>Implementação de machine learning para classificação do Iris Dataset utilizando o KNN (k-nearest neighbors) <NAME> - 31/08/2021[Github](https://github.com/andersonpereiradossantos) • [Linkedin](https://www.linkedin.com/in/andersonpereirasantos)  Importando bibliotecas<jupyter_code>import pandas as pd
import numpy as np
import matplotlib as plt
from sklearn.neighbors import KNeighborsClassifier<jupyter_output><empty_output><jupyter_text>Importando dados das flores de arquivo Excel<jupyter_code>flores = pd.read_excel("IrisDataset.xls")
flores.dropna()<jupyter_output><empty_output><jupyter_text>Plotando os relacionamentos de pares no conjunto de dados.<jupyter_code>sb.pairplot(flores,hue='variety')<jupyter_output><empty_output><jupyter_text>Definindo as features<jupyter_code>X = np.array(flores.drop('variety', 1))
Y = np.array(flores['variety'])<jupyter_output><empty_output><jupyter_text>Instanciando o classificador KNN para 5 vizinhos<jupyter_code>knn = KNeighborsClassifier(n_neighbors=5)<jupyter_output><empty_output><jupyter_text>Fazendo o treinamento<jupyter_code>knn.fit(X,Y)<jupyter_output><empty_output><jupyter_text>Executando o predict para classificar as flores<jupyter_code>print(knn.predict([[6.8,3.2,5.9,2.3]])[0])
print(knn.predict([[4.4,0.3,1.3,0.2]])[0])
print(knn.predict([[6, 2.7,3.9,1.2]])[0])<jupyter_output>Versicolor
{'fraction_non_alphanumeric': 0.13270485859318346, 'fraction_numerical': 0.026831036983321246, 'mean_word_length': 10.596638655462185, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '20063', 'license': 'MIT', 'n_tokens_mistral': 576, 'n_tokens_neox': 557, 'n_words': 75, 'path': 'KNN_Iris_Dataset.ipynb', 'repo_name': 'andersonpereiradossantos/machine_leaning', 'size': '1400'}