Last active
November 30, 2018 15:36
-
-
Save leandrocl2005/af6e80efb07a60b0627896897af6e42d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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