teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

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

2018/09/24 10:58

投稿

opyon
opyon

スコア1009

answer CHANGED
@@ -1,3 +1,54 @@
1
+ 追記
2
+ [計算が終わらない](https://gyazo.com/5f06b866bab856a7a8014afb0a0b8f8c)
3
+ デバッグするなどして1行づつ実行出来るところまで試してみてください。
4
+ (私には何の計算をしてるのかどう改善すればいいかなどは分かりません。あしからず。)
5
+
6
+ 以下Python3.6.6で試しました。
7
+ print(5)の行までの計算結果は出ましたが、
8
+ ```Python3
9
+ import numpy as np
10
+ from sklearn.svm import SVR
11
+ from matplotlib import pyplot as plt
12
+ from sklearn.datasets import load_boston
13
+ boston = load_boston()
14
+ import pandas as pd
15
+ pd.DataFrame(boston.data, columns=boston.feature_names)
16
+ print(1)
17
+
18
+ #簡易的にトレーニングデータとテストデータを分けた
19
+ X = boston.data[:354, :]
20
+ y = boston.target[:354]
21
+
22
+ print(X)
23
+ print(y)
24
+ print(2)
25
+
26
+ svr_rbf = SVR(kernel='rbf', C=1e3, gamma=0.1)
27
+ svr_lin = SVR(kernel='linear', C=1e3)
28
+ svr_poly = SVR(kernel='poly', C=1e3, degree=3)
29
+
30
+ print(svr_rbf)
31
+ print(svr_lin)
32
+ print(svr_poly)
33
+ print(3)
34
+
35
+ y_rbf = svr_rbf.fit(X, y).predict(X)
36
+ print(y_rbf)
37
+ print(4)
38
+ y_lin = svr_lin.fit(X, y).predict(X)
39
+ print(y_rbf)
40
+ print(5)
41
+ ```
42
+
43
+ これ以降は処理中のまま結果が出ない
44
+ ```Python3
45
+ y_poly = svr_poly.fit(X, y).predict(X)
46
+ print(y_rbf)
47
+ print(6)
48
+
49
+ ```
50
+
51
+ 以下初回回答
1
52
  参考URLコピペして、最後の`print`を`print()`に変えるだけで出力されました。
2
53
 
3
54
  Python3.7.0