Rで何かをしたり、読書をするブログ

政府統計の総合窓口のデータや、OECDやUCIやのデータを使って、Rの練習をしています。ときどき、読書記録も載せています。

UCI Machine Learning Repository の Obesity データの分析3 - 探索的データ分析: EDA (Exploratory Data Analysis) の実績その2

www.crosshyou.info

の続きです。

今回も前回に続き、探索的データ分析 (Exploratory Data Analysis) をします。

obesity と FHWO(Family History With Overweight) です。家族に肥満の人がいるかどうかです。

obesity の人、overweight の人はほとんど家族に肥満の人がいますね。食生活の習慣や遺伝の影響でしょうね。

 

次は obesity と FAVC です。FAVC は Do you eat high caloric food frequently? という質問です。高カロリーの食品を頻繁にに食べますか?という質問です。

obesity の人はほとんど yes です。

 

obesity と FCVC をみてみます。FCVC は Do you usually eat vegetables in your meals? です。野菜を普段食べますか? という質問です。

obesity type III と type I では対照的な結果ですね。type III はほとんどが 3.0 で、type I は1.0 ~ 1.5  の人がいます。

 

次は obecity と NCP です。NCP は How many main meals do you have daily? です。

毎日、メインの食事を何回摂りますか?という質問です。

基本は3回ですが、少ない人、4回食べてる人もいますね。normal weight の人と obesity type III の人はほとんど 3回です。

 

次は obesity と CAEC です。これは、Do you eat any food between meals? です。主食の間に間食、おやつを取りますか?という質問です。

ちょっと意外なのは、insufficient weight の人と normal weight の人が frequently が多いということです。

 

次は obesity と SMOKE です。タバコを吸うかどうかです。

ほとんどの人が非喫煙者ですね。

今回は以上です。

はじめから読むには、

 

www.crosshyou.info

です。

今回のコードは以下になります。

#
# obesity と FHWO(Family History With Overweight)
df |> 
  ggplot(aes(x = obesity, fill = FHWO)) +
  geom_bar() +
  theme_minimal()
#
# obesity と FAVC
df |> 
  ggplot(aes(x = obesity, fill = FAVC)) +
  geom_bar() +
  theme_minimal()
#
# obesity と FCVC
df |> 
  mutate(obesity = reorder(obesity, FCVC)) |> 
  ggplot(aes(x = FCVC, y = obesity, group = obesity)) +
  geom_boxplot(aes(fill = obesity)) +
  theme_minimal() +
  theme(legend.position = "none")
#
# obesity と NCP
df |> 
  mutate(obesity = reorder(obesity, NCP)) |> 
  ggplot(aes(x = NCP, y = obesity, group = obesity)) +
  geom_boxplot(aes(fill = obesity)) +
  theme_minimal() +
  theme(legend.position = "none")
#
# obesity と CAEC
df |> 
  ggplot(aes(x = obesity, fill = CAEC)) +
  geom_bar() +
  theme_minimal()
#
# obesity と SMOKE
df |> 
  ggplot(aes(x = obesity, fill = SMOKE)) +
  geom_bar() +
  theme_minimal()
#

(冒頭の画像は、Bing Image Creator で生成しました。プロンプトは Sea breezing natural landscape, many many orange Lilium maculatum flowers and one close up flower, Photo です。)