Skip to content

Commit fa53a57

Browse files
author
Mofan Zhou
committed
create sk4
1 parent 09a9ad9 commit fa53a57

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

sklearnTUT/sk4_learning_pattern.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# View more python learning tutorial on my Youtube and Youku channel!!!
2+
3+
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
4+
# Youku video tutorial: http://i.youku.com/pythontutorial
5+
6+
from sklearn import datasets
7+
from sklearn.cross_validation import train_test_split
8+
from sklearn.neighbors import KNeighborsClassifier
9+
10+
iris = datasets.load_iris()
11+
iris_X = iris.data
12+
iris_y = iris.target
13+
14+
##print(iris_X[:2, :])
15+
##print(iris_y)
16+
17+
X_train, X_test, y_train, y_test = train_test_split(
18+
iris_X, iris_y, test_size=0.3)
19+
20+
##print(y_train)
21+
22+
knn = KNeighborsClassifier()
23+
knn.fit(X_train, y_train)
24+
print(knn.predict(X_test))
25+
print(y_test)
26+
27+

0 commit comments

Comments
 (0)