質問編集履歴

1

プログラムとエラー内容の追記

2019/09/22 10:24

投稿

Rondon7251
test CHANGED
File without changes
test CHANGED
@@ -11,93 +11,3 @@
11
11
 
12
12
 
13
13
  意見を聞かせて下さい。
14
-
15
-
16
-
17
-
18
-
19
- 以下SVNのプログラム
20
-
21
- ```ここに言語を入力
22
-
23
- import pandas as pd
24
-
25
- from sklearn.model_selection import train_test_split
26
-
27
- from sklearn.svm import SVC
28
-
29
- from sklearn.metrics import accuracy_score
30
-
31
-
32
-
33
- # 読み込み --- (*1)
34
-
35
- analysisresults_data = pd.read_csv("analysis_resultsA.csv", encoding="utf-8")
36
-
37
-
38
-
39
- # ラベルと入力データに分離する --- (*2)
40
-
41
- y = analysisresults_data.loc[:,"Result"]
42
-
43
- x = analysisresults_data.loc[:,["Url"]]
44
-
45
-
46
-
47
- # 学習用とテスト用に分離する --- (*3)
48
-
49
- x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.3, train_size = 0.7, shuffle = True)
50
-
51
-
52
-
53
- # 学習する --- (*4)
54
-
55
- clf = SVC()
56
-
57
- clf.fit(x_train, y_train)
58
-
59
-
60
-
61
- # 評価する --- (*5)
62
-
63
- y_pred = clf.predict(x_test)
64
-
65
- print("正解率 = " , accuracy_score(y_test, y_pred))
66
-
67
-
68
-
69
- ```
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- 以下エラー内容
80
-
81
- Traceback (most recent call last):
82
-
83
- File "analysis_results.py", line 18, in <module>
84
-
85
- clf.fit(x_train, y_train)
86
-
87
- File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/sklearn/svm/base.py", line 146, in fit
88
-
89
- accept_large_sparse=False)
90
-
91
- File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/sklearn/utils/validation.py", line 719, in check_X_y
92
-
93
- estimator=estimator)
94
-
95
- File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/sklearn/utils/validation.py", line 496, in check_array
96
-
97
- array = np.asarray(array, dtype=dtype, order=order)
98
-
99
- File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/numpy/core/numeric.py", line 538, in asarray
100
-
101
- return array(a, dtype, copy=False, order=order)
102
-
103
- ValueError: could not convert string to float: 'https://youtu.be/-XgdtHewGR0'