This repository has been archived on 2020-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
ml/knn/SklearnExample.py
2020-02-23 22:14:06 +08:00

18 lines
296 B
Python
Executable File

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from sklearn import neighbors
from sklearn import datasets
knn = neighbors.KNeighborsClassifier()
iris = datasets.load_iris()
print iris
knn.fit(iris.data, iris.target)
predictedLabel = knn.predict([[0.1, 0.2, 0.3, 0.4]])
print predictedLabel