Skip to content

Commit

Permalink
实现识别程序
Browse files Browse the repository at this point in the history
  • Loading branch information
plter committed Mar 15, 2018
1 parent c562a11 commit 673d43e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ReadPhotoData/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import json

import numpy as np
from sklearn import tree
from sklearn import neighbors

fp = open("train_data.json", 'r')
train_data = np.array(json.load(fp))
fp.close()

fp = open("train_target.json", 'r')
train_target = np.array(json.load(fp))
fp.close()

# print(train_data)
# print(train_target)

test_index = [32]

preview_data = train_data[test_index]
preview_target = train_target[test_index]
train_data = np.delete(train_data, test_index, axis=0)
train_target = np.delete(train_target, test_index)

clf = neighbors.KNeighborsClassifier()
clf.fit(train_data, train_target)

print(clf.predict(preview_data))
1 change: 1 addition & 0 deletions ReadPhotoData/train_data.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ReadPhotoData/train_target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9]
Binary file modified 机器学习之手写识别.pptx
Binary file not shown.

0 comments on commit 673d43e

Please sign in to comment.