質問編集履歴

1

追記

2021/03/30 09:05

投稿

Kokku
Kokku

スコア39

test CHANGED
File without changes
test CHANGED
@@ -46,7 +46,47 @@
46
46
 
47
47
  # 説明変数を'data'に入れる
48
48
 
49
+ facemotion['data'] = df.loc[:, ['GDP per capita',
50
+
51
+ 'Social support', 'Healthy life expectancy',
52
+
53
+ 'Freedom to make life choices', 'Generosity',
54
+
49
- facemotion['data'] =
55
+ 'Perceptions of corruption']]
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ # 特徴量の名前も入れておくと、グラフの凡例等に使えます(無くても可)
64
+
65
+ facemotion['feature_names'] = ['GDP per capita',
66
+
67
+ 'Social support', 'Healthy life expectancy',
68
+
69
+ 'Freedom to make life choices', 'Generosity',
70
+
71
+ 'Perceptions of corruption']
72
+
73
+
74
+
75
+ # 訓練セットとテストセットに分割
76
+
77
+ from sklearn.model_selection import train_test_split
78
+
79
+ X_train, X_test, y_train, y_test = train_test_split(
80
+
81
+ worldhappiness['data'], worldhappiness['target'], random_state=0)
82
+
83
+
84
+
85
+ print("X_train shape:", X_train.shape)
86
+
87
+ print("X_test shape:", X_test.shape)
88
+
89
+
50
90
 
51
91
  ```
52
92
 
@@ -65,3 +105,17 @@
65
105
 
66
106
 
67
107
  よろしくお願いいたします。
108
+
109
+
110
+
111
+
112
+
113
+ エラー内容
114
+
115
+
116
+
117
+ ```ここに言語を入力
118
+
119
+ KeyError: "None of [Index(['特徴量名を入れる'], dtype='object')] are in the [columns]"
120
+
121
+ ```