質問編集履歴
2
記載の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,15 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
|
7
|
+
```
|
8
|
+
|
9
|
+
from sklearn.ensemble import RandomForestClassifier
|
10
|
+
|
11
|
+
from sklearn.model_selection import GridSearchCV
|
12
|
+
|
13
|
+
from sklearn.feature_selection import RFECV
|
14
|
+
|
15
|
+
|
8
16
|
|
9
17
|
param_grid = {'estimator__n_estimators': [10, 20, 50, 100, 200],
|
10
18
|
|
@@ -18,15 +26,17 @@
|
|
18
26
|
|
19
27
|
estimator = RandomForestClassifier()
|
20
28
|
|
29
|
+
selector = RFECV(estimator, scoring = 'f1_macro', cv = 5, step=1)
|
21
30
|
|
31
|
+
clf = GridSearchCV(selector, param_grid, scoring = 'f1_macro', cv = 5)
|
22
32
|
|
23
|
-
|
33
|
+
clf.fit(X, y)
|
24
34
|
|
25
35
|
|
26
36
|
|
27
|
-
|
37
|
+
コード
|
28
38
|
|
29
|
-
|
39
|
+
```
|
30
40
|
|
31
41
|
|
32
42
|
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
|
7
|
+
コード:
|
8
8
|
|
9
9
|
param_grid = {'estimator__n_estimators': [10, 20, 50, 100, 200],
|
10
10
|
|
@@ -14,19 +14,15 @@
|
|
14
14
|
|
15
15
|
'estimator__max_samples' : [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]}
|
16
16
|
|
17
|
-
|
17
|
+
|
18
18
|
|
19
19
|
estimator = RandomForestClassifier()
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
#RFECV
|
24
|
-
|
25
23
|
selector = RFECV(estimator, scoring = 'f1_macro', cv = index_cv, step=1)
|
26
24
|
|
27
25
|
|
28
|
-
|
29
|
-
#gridsearch
|
30
26
|
|
31
27
|
clf = GridSearchCV(selector, param_grid, scoring = 'f1_macro', cv = index_cv)
|
32
28
|
|
@@ -34,7 +30,7 @@
|
|
34
30
|
|
35
31
|
|
36
32
|
|
37
|
-
|
33
|
+
エラー:
|
38
34
|
|
39
35
|
FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details:
|
40
36
|
|