Skip to content

Instantly share code, notes, and snippets.

@leandrocl2005
Last active November 30, 2018 15:36
Show Gist options
  • Save leandrocl2005/af6e80efb07a60b0627896897af6e42d to your computer and use it in GitHub Desktop.
Save leandrocl2005/af6e80efb07a60b0627896897af6e42d to your computer and use it in GitHub Desktop.
# bibliotecas
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import classification_report
# remove warnings
import warnings
warnings.filterwarnings("ignore")
# dataset
iris = load_iris()
# features e target
X = iris.data
y = iris.target
# treino e teste
X_train, X_test, y_train, y_test = train_test_split(X,y)
# treinando o modelo
model = KNeighborsClassifier()
model.fit(X_train,y_train)
# predizendo o teste
y_pred = model.predict(X_test)
# comparando predição com o real
print(classification_report(y_test, y_pred))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment