SlideShare a Scribd company logo
1 of 34
Download to read offline
ミニミニデータ分析入門@Sassor
Rで学ぶ
ミニミニ ビッグデータ分析
入門
第1回
2013年4月18日
しらとりなるひこ
ミニミニデータ分析入門@Sassor
しらとりなるひこ
2
ミニミニデータ分析入門@Sassor
しらとりなるひこ
•  専門
–  確率を用いたユーザモデ
ルの構築
–  初年次教育を通した学生
モデルの構築
–  人工知能を用いた人間-
社会システムのデザイン
–  ユーザベースのメディア
デザイン
3
ミニミニデータ分析入門@Sassor
やってきたこと、やりたいこと
•  主観的な経験を蓄積するBayesian  
Networks  Layer:確率率率モデルを構築する
ことで、⾼高度度技能スキルの⺠民主化を⾏行行う
プロにしかできないことが、
誰にでも出来たらいいなプロジェクト
4
ミニミニデータ分析入門@Sassor
今までのプロジェクト 1
麻酔ナビゲーションシステム
•  麻酔科医の事故を事
前に教えて、事故無
く手術を終了するこ
とができるシステム
5
ミニミニデータ分析入門@Sassor
今までのプロジェクト 2
写真推薦システム
•  ユーザの年齢やこれまでの写
真履歴、見る場所によって、
今見たい写真を推薦する。後
ろのエンジン作りました
6
ミニミニデータ分析入門@Sassor
今までのプロジェクト 3
これなーに
•  原宿での行列を携帯
電話で撮影すると、
その行列が何の行列
かを推測してくれる
7
ミニミニデータ分析入門@Sassor
今までのプロジェクト 4
Lifeプロジェクト
•  家の中にあるコンテ
ンツを利用した経験
が蓄積されて、自分
の経験が反映された
コンテンツ経験がで
きるサーバー
8
ミニミニデータ分析入門@Sassor
この勉強会の目的
•  データに対する恐怖感を拭い去ること
–  データを扱う皆様と会話できるようになること
•  データを用いて変化やアイデアを語れるよう
になること
•  Rさんが出してくれる喜びを知ること
–  計算を少ししながら「Rって便利だな」と納得す
ること
9
ミニミニデータ分析入門@Sassor
グラフを作れたりします
10
グラフの特徴はなんでしょう?
ミニミニデータ分析入門@Sassor
全体アジェンダ
1.  1つのデータ群を比べる方法
2.  2つ以上のデータ群の関連性を見る
3.  3つ以上のデータ:多変量解析
4.  ベイズ統計
5.  ベイズモデルの応用:時系列解析
6.  ベイジアンネットワークの活用
11
ミニミニデータ分析入門@Sassor
第1回アジェンダ
•  RStudioインストールの確認
•  1つのデータ群を比べる方法(統計の基
礎知識を得る)
–  代表値
–  基準化
数字を使って、1つのデータ群の特徴を
説明できること
12
ミニミニデータ分析入門@Sassor
RStudioのインストールの確認
http://www.rstudio.com/ide/download/
13
ミニミニデータ分析入門@Sassor
RStudioって何?
R
統計解析用のプログラミング言語
RStudio
 RをベースにしたIDE
つまり、RStudioを使ったほうが便利です
14
ミニミニデータ分析入門@Sassor
データの種類
•  測れるデータ
–  数量データ
•  測れないデータ
–  カテゴリーデータ
•  分類の方法
–  目盛りと隣の目盛りの間隔が等しい時は数量データ
•  身長、体重等は数量データ
•  とてもおもしろかった-とてもつまらなかった、英検1級な
どといったものはカテゴリーデータ
–  実務では数量データとみなす場合もある
15
ミニミニデータ分析入門@Sassor
表を比較する
0 1 2 3 4 5 6 7
北千住 0 0 0 0 0 0 0 0
池袋 0 0 0 0 0 0 17 31
8 9 10 11 12 13 14 15 16
北千住 392 333 985 573 745 244 256 246 6
池袋 0 109 979 237 389 867 295 377 75
17 18 19 20 21 22 23
北千住 81 3 311 107 14 41 0
池袋 588 371 246 604 39 33 0
2011年10月6日:0時∼23時のIHコンロの電力データ
深夜から朝
朝から夕方
夜から深夜
16
ミニミニデータ分析入門@Sassor
グラフを比較する
黒:北千住店
赤:池袋店
17
ミニミニデータ分析入門@Sassor
グラフを比較する
黒:北千住店
赤:池袋店
•  池袋店のほうがぶれ幅が大きい
•  北千住店は夜の上がり幅が少ない
•  ランチタイムは同じくらいだ
•  ・・・
気付き
18
ミニミニデータ分析入門@Sassor
代表値
数量データを分かりやすくする方法、デー
タの分布を1つの数字で代表させた値
=数値要約するとか言う
•  平均値(arithmetic mean)
•  最大値
•  最小値
•  中央値
•  分散(variance)
•  標準偏差:standard deviation
19
ミニミニデータ分析入門@Sassor
平均値を求める
•  相加平均:すべてを足して、その個数で
割る
•  (0+0+…+14+41)/24
20
ミニミニデータ分析入門@Sassor
平均値を求める(R)
•  最初にベクトルを作成する c(x,y,z)
–  ikebukuro <- c(0,0,0,0,0,17,31,0,109,979, 237, 389,
867, 295, 377, 75, 588, 371, 246,604, 39, 33, 0)
–  kitasenju <- …
•  平均値を求める
–  > mean(kitasenju)
–  [1] 180.7083
–  > mean(ikebukuro)
–  [1] 219.0417
21
ミニミニデータ分析入門@Sassor
最大値、最小値を求める
•  最大値:一番大きい
数値
–  > max(kitasenju)
–  [1] 985
–  > max(ikebukuro)
–  [1] 979
•  最小値:一番小さい
数値
–  > min(kitasenju)
–  [1] 0
–  > min(ikebukuro)
–  [1] 0
22
ミニミニデータ分析入門@Sassor
中央値を求める
•  中央値:真ん中の値
– 偶数個なら中央値に近い2つの数の平均
– 12番目と13番めの値を出して2で割る
– > median(kitasenju)
– [1] 27.5
– > median(ikebukuro)
– [1] 57
23
ミニミニデータ分析入門@Sassor
一気にもとめる
–  > summary(kitasenju)
–  Min. 1st Qu. Median Mean 3rd Qu. Max.
–  0.0 0.0 27.5 180.7 269.8 985.0
–  > summary(ikebukuro)
–  Min. 1st Qu. Median Mean 3rd Qu. Max.
–  0.0 0.0 57.0 219.0 372.5 979.0
–  1stQu. :第1四分位数(下から数えて4分の1)
–  3rdQu.:第3四分位数(下から数えて4分の3)
24
ミニミニデータ分析入門@Sassor
ばらつきを求める
•  分散(標本分散)
– 平均からの偏差(データと平均の差)を2乗
して、それを足して、個数で割る
– 不偏分散は個数-1で割る
•  標準偏差
– 平均からの偏差(データと平均の差)を2乗
して、それを足して、個数で割り、それの平
方根をとる
25
ミニミニデータ分析入門@Sassor
分散を求める
•  北千住:平均181
– ( (0-181)^2+(0-181)^2+…
+(14-181)^2+(41-181)^2 )/24
•  池袋:平均219
26
ミニミニデータ分析入門@Sassor
標本分散を求める
•  平均からの偏差を2乗して、個数で割る
–  北千住の標本分散:68193
•  > sum((kitasenju-mean(kitasenju))^2)/24
•  [1] 68193.37
•  > sum((kitasenju-mean(kitasenju))^2)/length(kitasenju)
•  [1] 68193.37
–  池袋の標本分散:80223.12
•  > sum((ikebukuro-mean(ikebukuro))^2)/
length(ikebukuro)
•  [1] 80223.12
27
ミニミニデータ分析入門@Sassor
2種類の分散
•  分散には標本分散と不偏分散がある
– nで割る標本分散、n-1で割る不偏分散
– varは不偏分散を求める
•  > var(kitasenju)
•  [1] 71158.3
•  > var(ikebukuro)
•  [1] 83711.09
28
ミニミニデータ分析入門@Sassor
標準偏差
•  標準偏差:standard deviation
–  分散の平方根をとったもの
–  標準偏差にも標本標準偏差と不偏標準偏差がある
•  > sqrt(sum((kitasenju-mean(kitasenju))^2)/
length(kitasenju))
•  [1] 261.1386
•  これでもOK
–  > sqrt(mean((kitasenju-mean(kitasenju))^2))
–  [1] 261.1386
•  > sqrt(sum((ikebukuro-mean(ikebukuro))^2)/
length(ikebukuro))
•  [1] 283.2369
29
ミニミニデータ分析入門@Sassor
標準偏差
•  標準偏差:
–  標準偏差にも標本標準偏差と不偏標準偏差がある
•  > sd(kitasenju)
•  [1] 266.7551
•  > sd(ikebukuro)
•  [1] 289.3287
•  不偏標準偏差から標本標準偏差への移行
–  > sqrt(sd(kitasenju)^2*(length(kitasenju)-1)/
length(kitasenju))
–  [1] 261.1386
30
ミニミニデータ分析入門@Sassor
基準化
(標準化:standardization)
•  基準値(z得点):個々のデータ- 平均 /
標準偏差
– 基準値の平均は0、標準偏差は1
•  基準値の特徴
– 最大値、最小値がばらばらであっても比較で
きる
– 単位の違うモノも比較できる
– 標準正規分布を用いた推定や検定ができる
31
ミニミニデータ分析入門@Sassor
基準化を行う
•  > kitasenju.Zscore <- (kitasenju-mean(kitasenju))/sqrt(mean((kitasenju-
mean(kitasenju))^2))
•  > kitasenju.Zscore
•  [1] -0.6920016 -0.6920016 -0.6920016 -0.6920016 -0.6920016 -0.6920016
-0.6920016 -0.6920016 0.8091169
•  [10] 0.5831833 3.0799416 1.5022354 2.1608895 0.2423681 0.2883207
0.2500269 -0.6690253 -0.3818215
•  [19] -0.6805134 0.4989368 -0.2822575 -0.6383902 -0.5349968 -0.6920016
•  > mean(kitasenju.Zscore)
•  [1] -5.088974e-17
•  > mean((kitasenju.Zscore-mean(kitasenju.Zscore))^2)
•  [1] 1
32
ミニミニデータ分析入門@Sassor
もう一度グラフで比較する
黒:北千住店
赤:池袋店
•  池袋のほうが北千住より分散○○だけが大きい
•  北千住は夜間の最大値が○○だけ少ない
•  ランチタイムはの平均値は○○なので同じくらいだ
•  ・・・
1変数の変化を、数を用いて思いつきや考えを説明できたらOK
33
ミニミニデータ分析入門@Sassor
次回予告
•  次回はひとつの変数への注目から、
2変数の関連性にスポットを当て
る
34

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Rで学ぶミニミニビッグデータ分析入門-第1回