質問編集履歴
1
コードを再度掲載いたしました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,13 +1,4 @@
|
|
1
|
-
Pythonではじめる機械学習で勉強しています。
|
2
|
-
ランダムフォレストのところでエラーがでて先に進みません。どうすれば良いのでしょうか?Runtimeエラーでoutput shape not correctと出ています。教えていただければ幸いです。
|
3
|
-
|
4
|
-
|
1
|
+
```
|
5
|
-
Mac
|
6
|
-
Anaconda
|
7
|
-
Jupyter notebook 6.0.1
|
8
|
-
|
9
|
-
mglearnはインポート済みです。
|
10
|
-
|
11
2
|
from sklearn.ensemble import RandomForestClassifier
|
12
3
|
from sklearn.datasets import make_moons
|
13
4
|
|
@@ -17,17 +8,28 @@
|
|
17
8
|
forest = RandomForestClassifier(n_estimators=5, random_state=2)
|
18
9
|
forest.fit(X_train, y_train)
|
19
10
|
|
20
|
-
|
21
11
|
fig, axes = plt.subplots(2, 3, figsize=(20, 10))
|
22
12
|
for i, (ax, tree) in enumerate(zip(axes.ravel(), forest.estimators_)):
|
23
13
|
ax.set_title("Tree {}".format(i))
|
24
14
|
mglearn.plots.plot_tree_partition(X_train, y_train, tree, ax=ax)
|
25
15
|
|
26
|
-
|
16
|
+
mglearn.plots.plot_2d_separator(forest, X_train, fill=True, ax=axes[-1, -1], alpha=.4)
|
27
|
-
|
17
|
+
|
28
18
|
axes[-1, -1].set_title("Random Forest")
|
29
|
-
mglearn.discrete_scatter(X_train[:, 0], X_train[:, 1], y_train)
|
19
|
+
mglearn.discrete_scatter(X_train[:, 0], X_train[:, 1], y_train)```
|
30
20
|
|
21
|
+
Pythonではじめる機械学習で勉強しています。
|
22
|
+
ランダムフォレストのところでエラーがでて先に進みません。どうすれば良いのでしょうか?Runtimeエラーでoutput shape not correctと出ています。教えていただければ幸いです。
|
23
|
+
|
24
|
+
環境は
|
25
|
+
Mac
|
26
|
+
Anaconda
|
27
|
+
Jupyter notebook 6.0.1
|
28
|
+
|
29
|
+
mglearnはインポート済みです。
|
30
|
+
|
31
|
+
|
32
|
+
|
31
33
|
---------------------------------------------------------------------------
|
32
34
|
RuntimeError Traceback (most recent call last)
|
33
35
|
<ipython-input-108-a394de2652b3> in <module>
|