Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
パーマーステーションのペンギンたち#3 探索的データ分析(EDA)編
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
bob3bob3
September 02, 2023
Programming
890
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
パーマーステーションのペンギンたち#3 探索的データ分析(EDA)編
パーマーステーションのペンギンたち#3
探索的データ分析(EDA)編
Tokyo.R #108 (2023/09/02)
#TokyoR
#R言語
#rstatsj
bob3bob3
September 02, 2023
More Decks by bob3bob3
See All by bob3bob3
RとLLMで自然言語処理
bob3bob3
3
1.1k
RでPSM分析
bob3bob3
1
490
Rでコンジョイント分析 2024年版
bob3bob3
0
2.8k
『改訂新版前処理大全』の話と Apache Parquet の話 #TokyoR
bob3bob3
0
1.5k
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
670
『データ可視化学入門』をPythonからRに翻訳した話(増強版)
bob3bob3
0
620
『データ可視化学入門』を PythonからRに翻訳した話
bob3bob3
1
690
qeMLパッケージの紹介
bob3bob3
0
3k
「国と音楽」 ~spotifyrを用いて~ #muana
bob3bob3
2
690
Other Decks in Programming
See All in Programming
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.2k
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
220
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
580
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
300
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
510
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.3k
AHC070解法紹介
eijirou
0
140
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
170
Are APIs Still Relevant in the AI Era?
soyuka
0
310
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
230
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
8.6k
スマート反転とウェブアクセシビリティ
camiha
0
210
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
540
The SEO identity crisis: Don't let AI make you average
varn
0
560
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
920
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
How STYLIGHT went responsive
nonsquared
100
6.3k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
580
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
550
Building Applications with DynamoDB
mza
96
7.2k
Transcript
パーマーステーションの ペンギンたち #3 探索的データ分析(EDA)編 Tokyo.R #108 (2023/09/02) @bob3bob3 Artwork by
@allison_horst
このセッションの位置づけ 中級者セッションのつもりでやっているシリーズです。 1. データセットの紹介(前々回) 2. データクリーニング(前回) 3. 探索的データ分析(EDA)(今回) 4. 分析例
◦ シンプソンのパラドクス ◦ 次元縮約 ◦ クラスタリング ◦ 判別モデル ◦ などなど
探索的データ分析とは? • Exploratory Data Analysis、EDA。 • 分析対象であるデータに対する理解を 深めるプロセスのことを指す。 • 個々の変数の特性や変数間の関係を
把握することが目的で、その手段として 要約統計量や可視化が用いられる。 • 分析するデータが手に入ったらまずは EDA! • John Tukey さん(1915 – 2000)が提唱し ました。箱ひげ図を提唱したことでも有 名。コンピューター用語の bit を作ったこ とでも知られる。 引用元
パーマーステーションのペンギンたち 過去2回に続き、palmerpenguinsパッ ケージのデータセットを使います。 初回の資料も参考にしてください。 とりあえず、いますぐ install.packages("palmerpenguins") しましょう! Artwork by @allison_horst
どんなデータ? • 南極に生息するペンギンの生態調査。2007年、08年、09年の3回の調査。 • 南極のビスコー諸島、ドリーム島、トージャーセン島の3か所。 • アデリーペンギン、ヒゲペンギン、ジェンツーペンギンの3種のペンギン。 • 嘴の長さ、高さ、翼の長さ、体重、性別などが含まれる。 アデリー(Adelie)
ジェンツー(Gentoo) ヒゲ(Chinstrap) Stan Shebs (CC BY-SA 3.0) Andrew Shiva(CC BY-SA 4.0) Stan Shebs (CC BY-SA 3.0)
2つのデータセット penguins_raw 生のデータ • 17変数 • studyName: 研究名(越冬隊ごと?) •
Sample Number: 標本番号(連番) • Species: ペンギンの種(学名付き) • Region: 調査した地域 • Island: 調査した島 • Stage: 発育段階 • Individual ID: 個体ID • Clutch Completion: 巣の完成度 • Date Egg: 巣に1個以上の卵が確認された日? • Culmen Length (mm): くちばしの長さ • Culmen Depth (mm): くちばしの高さ • Flipper Length (mm): 翼の長さ • Body Mass (g): 体重 • Sex: 性別 • Delta 15 N (o/oo): 窒素同位体比(δ15N) • Delta 13 C (o/oo): 炭素同位体比(δ13C) • Comments: コメント penguins 使いやすく加工されたデータ • 8変数 • species: ペンギンの種 • island: 調査した島 • bill_length_mm: くちばしの長さ • bill_depth_mm: くちばしの高さ • flipper_length_mm: 翼の長さ • body_mass_g: 体重 • sex: 性別 • year: 調査した年 Artwork by @allison_horst
2つのデータセット penguins_raw 生のデータ • 17変数 • studyName: 研究名(越冬隊ごと?) •
Sample Number: 標本番号(連番) • Species: ペンギンの種(学名付き) • Region: 調査した地域 • Island: 調査した島 • Stage: 発育段階 • Individual ID: 個体ID • Clutch Completion: 巣の完成度 • Date Egg: 巣に1個以上の卵が確認された日? • Culmen Length (mm): くちばしの長さ • Culmen Depth (mm): くちばしの高さ • Flipper Length (mm): 翼の長さ • Body Mass (g): 体重 • Sex: 性別 • Delta 15 N (o/oo): 窒素同位体比(δ15N) • Delta 13 C (o/oo): 炭素同位体比(δ13C) • Comments: コメント penguins 使いやすく加工されたデータ • 8変数 • species: ペンギンの種 • island: 調査した島 • bill_length_mm: くちばしの長さ • bill_depth_mm: くちばしの高さ • flipper_length_mm: 翼の長さ • body_mass_g: 体重 • sex: 性別 • year: 調査した年 Artwork by @allison_horst 今日使うのは こっち。
やること 1. データセットの全体像を確認 2. 1変量の分析 3. 2変量の分析
今回使用する主なパッケージ • サンプルデータ ◦ palmerpenguins • 要約 ◦ tidyverse ◦
summarytools • 可視化 ◦ ggplot2 ◦ GGally ◦ MASS
データセットの全体像を確認 library(palmerpenguins) #データセット penguins #tibble形式 palmerpenguinsパッケージ。 今回使うデータセットpenguinsを含 む。
全体確認 library(palmerpenguins) #データセット penguins penguins |> str() #オブジェクトの構造を表示。structure
全体確認 library(palmerpenguins) #データセット penguins penguins |> str() #オブジェクトの構造を表示。structure penguins |>
dplyr::glimpse() #「チラ見する」ぐらいの意味
全体確認 penguins |> summary() #とりあえずsummary()
まずはデータを確認 # summary()の超強力版 library(summarytools) penguins |> dfSummary() |> view() summarytoolsパッケージ。
データの概要を確認するのに非常に便 利。 分布の形、欠損値の有無、名義尺度や 順序尺度のカテゴリ数数などを確認して おきたい。
1変数の分析 • 気になる変数を個別に確認する • 名義尺度、順序尺度は棒グラフで、比率尺度、比例尺度はヒストグラムで確認する のがいいでしょう。
1変数の分析 • 気になる変数を個別に確認する • 名義尺度、順序尺度は棒グラフで、比率尺度、連続変数はヒストグラムで確認する のがいいでしょう。 ヒストグラムは MASS::truehist()が おすすめ。
2変数の分析 • まずは、GGallyパッケージのggpairs()関数 でどの組み合わせが気になるか確認。 • ただし、変数が多いと組み合わせ爆発で描 画に時間がかかります。 penguins |> GGally::ggpairs(aes(colour=species))
2変数の分析(連続変数×連続変数) • 連続変数同士の組み合わせは 散布 図で表す。 penguins |> ggplot(aes(x = bill_length_mm,
y = bill_depth_mm, color = species)) + geom_point()
2変量の分析(名義尺度×名義尺度) • クロス集計表の可視化。 • モザイクプロット penguins |> mosaicplot(~ species +
island, data = _, color = TRUE)
2変量の分析(名義尺度×連続変数) • 箱ひげ図、バイオリンプロット、ジッタ ―プロッ トの重ね書き ◦ raincloud plot がいいけれど、ちょっと手間な ので簡易版として。
penguins |> ggplot(aes(x = species, y = body_mass_g)) + geom_violin(aes(fill=species)) + geom_boxplot(width=0.1) + geom_jitter(width=0.2, height=0, alpha=0.3)
ggploylyで対話的に分析 • ggplot2のオブジェクトをggplotly()に与えるだ けで対話的なグラフができる! library(plotly) p1 <- penguins
|> ggplot(aes( x = bill_length_mm, y = bill_depth_mm, color = species )) + geom_point() p1 |> ggplotly()
to be continued... 今後の予定: 1. データセットの紹介(前々回) 2. データクリーニング(前回) 3. 探索的データ分析(EDA)(今回)
4. 分析例 ◦ シンプソンのパラドクス ◦ 次元縮約 ◦ クラスタリング ◦ 判別モデル ◦ などなど 次回はついに分析例だよ! いつになる ことやら…… お楽しみに!