回答編集履歴

1

どこまで実行出来るかを追記

2018/09/24 10:58

投稿

opyon
opyon

スコア1009

test CHANGED
@@ -1,3 +1,105 @@
1
+ 追記
2
+
3
+ [計算が終わらない](https://gyazo.com/5f06b866bab856a7a8014afb0a0b8f8c)
4
+
5
+ デバッグするなどして1行づつ実行出来るところまで試してみてください。
6
+
7
+ (私には何の計算をしてるのかどう改善すればいいかなどは分かりません。あしからず。)
8
+
9
+
10
+
11
+ 以下Python3.6.6で試しました。
12
+
13
+ print(5)の行までの計算結果は出ましたが、
14
+
15
+ ```Python3
16
+
17
+ import numpy as np
18
+
19
+ from sklearn.svm import SVR
20
+
21
+ from matplotlib import pyplot as plt
22
+
23
+ from sklearn.datasets import load_boston
24
+
25
+ boston = load_boston()
26
+
27
+ import pandas as pd
28
+
29
+ pd.DataFrame(boston.data, columns=boston.feature_names)
30
+
31
+ print(1)
32
+
33
+
34
+
35
+ #簡易的にトレーニングデータとテストデータを分けた
36
+
37
+ X = boston.data[:354, :]
38
+
39
+ y = boston.target[:354]
40
+
41
+
42
+
43
+ print(X)
44
+
45
+ print(y)
46
+
47
+ print(2)
48
+
49
+
50
+
51
+ svr_rbf = SVR(kernel='rbf', C=1e3, gamma=0.1)
52
+
53
+ svr_lin = SVR(kernel='linear', C=1e3)
54
+
55
+ svr_poly = SVR(kernel='poly', C=1e3, degree=3)
56
+
57
+
58
+
59
+ print(svr_rbf)
60
+
61
+ print(svr_lin)
62
+
63
+ print(svr_poly)
64
+
65
+ print(3)
66
+
67
+
68
+
69
+ y_rbf = svr_rbf.fit(X, y).predict(X)
70
+
71
+ print(y_rbf)
72
+
73
+ print(4)
74
+
75
+ y_lin = svr_lin.fit(X, y).predict(X)
76
+
77
+ print(y_rbf)
78
+
79
+ print(5)
80
+
81
+ ```
82
+
83
+
84
+
85
+ これ以降は処理中のまま結果が出ない
86
+
87
+ ```Python3
88
+
89
+ y_poly = svr_poly.fit(X, y).predict(X)
90
+
91
+ print(y_rbf)
92
+
93
+ print(6)
94
+
95
+
96
+
97
+ ```
98
+
99
+
100
+
101
+ 以下初回回答
102
+
1
103
  参考URLコピペして、最後の`print`を`print()`に変えるだけで出力されました。
2
104
 
3
105