Skip to content

Instantly share code, notes, and snippets.

@Inazuma110
Created September 23, 2018 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Inazuma110/7883d82d42f65a2d3eebf113765621a4 to your computer and use it in GitHub Desktop.
Save Inazuma110/7883d82d42f65a2d3eebf113765621a4 to your computer and use it in GitHub Desktop.
XOR 演算
from sklearn import svm
xor_date = [
[0, 0, 0],
[0, 1, 1],
[1, 0, 1],
[1, 1, 0]]
data = []
label = []
for row in xor_date:
p = row[0]
q = row[1]
r = row[2]
data.append([p, q])
label.append(r)
clf = svm.SVC()
clf.fit(data, label)
pre = clf.predict(data)
print(pre)
ok = 0; total = 0;
for idx, answer in enumerate(label):
p = pre[idx]
if p == answer: ok += 1
total += 1
print(ok, " : ", total, " : ", ok/total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment