質問編集履歴
1
追記
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -22,7 +22,27 @@
|
|
|
22
22
|
facemotion['target'] = df['Score']
|
|
23
23
|
|
|
24
24
|
# 説明変数を'data'に入れる
|
|
25
|
+
facemotion['data'] = df.loc[:, ['GDP per capita',
|
|
26
|
+
'Social support', 'Healthy life expectancy',
|
|
27
|
+
'Freedom to make life choices', 'Generosity',
|
|
25
|
-
|
|
28
|
+
'Perceptions of corruption']]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# 特徴量の名前も入れておくと、グラフの凡例等に使えます(無くても可)
|
|
33
|
+
facemotion['feature_names'] = ['GDP per capita',
|
|
34
|
+
'Social support', 'Healthy life expectancy',
|
|
35
|
+
'Freedom to make life choices', 'Generosity',
|
|
36
|
+
'Perceptions of corruption']
|
|
37
|
+
|
|
38
|
+
# 訓練セットとテストセットに分割
|
|
39
|
+
from sklearn.model_selection import train_test_split
|
|
40
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
41
|
+
worldhappiness['data'], worldhappiness['target'], random_state=0)
|
|
42
|
+
|
|
43
|
+
print("X_train shape:", X_train.shape)
|
|
44
|
+
print("X_test shape:", X_test.shape)
|
|
45
|
+
|
|
26
46
|
```
|
|
27
47
|
このコードを実行したところ
|
|
28
48
|
```ここに言語を入力
|
|
@@ -31,4 +51,11 @@
|
|
|
31
51
|
```
|
|
32
52
|
と出力されたのですが説明変数としてはface_rectangle、landmarkだけ取得したいのですがどのように指定すればこの情報だけ取得できるでしょうか。
|
|
33
53
|
|
|
34
|
-
よろしくお願いいたします。
|
|
54
|
+
よろしくお願いいたします。
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
エラー内容
|
|
58
|
+
|
|
59
|
+
```ここに言語を入力
|
|
60
|
+
KeyError: "None of [Index(['特徴量名を入れる'], dtype='object')] are in the [columns]"
|
|
61
|
+
```
|