————— ——-
cycler 0.10.0
joblib 0.13.2
kiwisolver 1.1.0
matplotlib 3.0.3
numpy 1.17.1
pandas 0.25.1
pip 19.2.3
pyparsing 2.4.2
python-dateutil 2.8.0
pytz 2019.2
scikit-learn 0.21.3
scipy 1.3.1
setuptools 20.10.1
six 1.12.0
from sklearn import svm xor_data = [ [0,0,0], [0,1,0], [1,0,1], [1,1,0] ] data = [] label = [] for row in xor_data: p = row[0] q = row[1] r = row[2] data.append([p,q]) label.append(r) clf = svm.SVC(gamma="auto") 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)
[vagrant@localhost python]$ python myapp.py
予想結果: [0 0 0 0]
正解率: 3 / 4 = 0.75
OK、取り敢えず環境は整ってきた