質問編集履歴

2

ソースの追記

2019/06/16 05:25

投稿

Rondon7251
Rondon7251

スコア89

test CHANGED
File without changes
test CHANGED
@@ -21,6 +21,8 @@
21
21
 
22
22
 
23
23
  and.pyのソース
24
+
25
+ ``` python
24
26
 
25
27
  # ライブラリのインポート --- (*1)
26
28
 
@@ -67,3 +69,5 @@
67
69
  print(test_data , "の予測結果:" , test_label)
68
70
 
69
71
  print("正解率 = " , accuracy_score([0, 0, 0, 1], test_label))
72
+
73
+ ```

1

ソースに追記

2019/06/16 05:25

投稿

Rondon7251
Rondon7251

スコア89

test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,53 @@
17
17
  from sklearn.svm import LinearSVC
18
18
 
19
19
  ImportError: No module named 'sklearn'
20
+
21
+
22
+
23
+ and.pyのソース
24
+
25
+ # ライブラリのインポート --- (*1)
26
+
27
+ from sklearn.svm import LinearSVC
28
+
29
+ from sklearn.metrics import accuracy_score
30
+
31
+
32
+
33
+ # 学習用のデータと結果の準備 --- (*2)
34
+
35
+ # X , Y
36
+
37
+ learn_data = [[0,0], [1,0], [0,1], [1,1]]
38
+
39
+ # X and Y
40
+
41
+ learn_label = [0, 0, 0, 1]
42
+
43
+
44
+
45
+ # アルゴリズムの指定(LinierSVC) --- (*3)
46
+
47
+ clf = LinearSVC()
48
+
49
+
50
+
51
+ # 学習用データと結果の学習 --- (*4)
52
+
53
+ clf.fit(learn_data, learn_label)
54
+
55
+
56
+
57
+ # テストデータによる予測 --- (*5)
58
+
59
+ test_data = [[0,0], [1,0], [0,1], [1,1]]
60
+
61
+ test_label = clf.predict(test_data)
62
+
63
+
64
+
65
+ # 予測結果の評価 --- (*6)
66
+
67
+ print(test_data , "の予測結果:" , test_label)
68
+
69
+ print("正解率 = " , accuracy_score([0, 0, 0, 1], test_label))