質問編集履歴
2
CSVファイルとソースの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
|
21
|
+
ソース
|
22
22
|
|
23
23
|
|
24
24
|
|
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
|
76
76
|
|
77
|
-
CSV
|
77
|
+
CSVファイル
|
78
78
|
|
79
79
|
```ここに言語を入力
|
80
80
|
|
1
ソースとCSVデータの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,3 +13,109 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
エラー文の意味がわかる方がいましたら教えてください。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
プログラム
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
```python
|
26
|
+
|
27
|
+
import pandas as pd
|
28
|
+
|
29
|
+
from sklearn.model_selection import train_test_split
|
30
|
+
|
31
|
+
from sklearn.svm import SVC
|
32
|
+
|
33
|
+
from sklearn.metrics import accuracy_score
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# データの読み込み --- (*1)
|
38
|
+
|
39
|
+
analysisresults_data = pd.read_csv("analysis_resultstableZZZ.csv",encoding="utf-8")
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
# データをラベルと入力データに分離する --- (*2)
|
44
|
+
|
45
|
+
y = analysisresults_data.loc[:,"analysis_result"]
|
46
|
+
|
47
|
+
x = analysisresults_data.loc[:,["id","signatures_id","hit_count"]]
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
# 学習用とテスト用に分離する --- (*3)
|
52
|
+
|
53
|
+
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.2, train_size = 0.8, shuffle = True, random_state=0)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
# 学習する --- (*4)
|
58
|
+
|
59
|
+
clf = SVC()
|
60
|
+
|
61
|
+
clf.fit(x_train, y_train)
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
# 評価する --- (*5)
|
66
|
+
|
67
|
+
y_pred = clf.predict(x_test)
|
68
|
+
|
69
|
+
print("正解率 = " , accuracy_score(y_test, y_pred))
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
CSVデータ
|
78
|
+
|
79
|
+
```ここに言語を入力
|
80
|
+
|
81
|
+
id,signatures_id,hit_count,analysis_result
|
82
|
+
|
83
|
+
4,12,4,0
|
84
|
+
|
85
|
+
5,12,3,0
|
86
|
+
|
87
|
+
6,12,3,0
|
88
|
+
|
89
|
+
7,12,3,0
|
90
|
+
|
91
|
+
8,12,3,0
|
92
|
+
|
93
|
+
11,10,2,0
|
94
|
+
|
95
|
+
21,10,8,0
|
96
|
+
|
97
|
+
22,12,2,0
|
98
|
+
|
99
|
+
23,10,2,0
|
100
|
+
|
101
|
+
24,10,4,0
|
102
|
+
|
103
|
+
25,10,2,0
|
104
|
+
|
105
|
+
26,10,4,0
|
106
|
+
|
107
|
+
27,10,2,0
|
108
|
+
|
109
|
+
28,10,4,0
|
110
|
+
|
111
|
+
33,10,2,0
|
112
|
+
|
113
|
+
34,12,4,0
|
114
|
+
|
115
|
+
35,10,4,0
|
116
|
+
|
117
|
+
36,10,8,0
|
118
|
+
|
119
|
+
37,10,4,0
|
120
|
+
|
121
|
+
```
|