[머신러닝] k-NN Classification
2020. 7. 26. 15:29ㆍ머신러닝
from sklearn.datasets import load_iris
iris=load_iris()
from sklearn.model_selection import train_test_split
X=iris.data
y=iris.target
X_train, X_test, y_train, y_test=train_test_split(X, y, test_size=0.4, random_state=42)
from sklearn.neighbors import KNeighborsClassifier
from sklearn import metrics
knn=KNeighborsClassifier(n_neighbors=5)
knn.fit(X_train, y_train)
y_pred=knn.predict(X_test)
scores=metrics.accuracy_score(y_test, y_pred)
k-NN Classification 결과
'머신러닝' 카테고리의 다른 글
[머신러닝] Classification2 - Clustering (0) | 2020.09.20 |
---|---|
[머신러닝] Classification1 - Mixture Model & Clustering (0) | 2020.08.25 |
[머신러닝] Logistic Regression (0) | 2020.07.18 |
[머신러닝] Linear Regression (0) | 2020.07.12 |
[머신러닝] Python 선형대수학 numpy 사용 (0) | 2020.07.04 |