SlideShare a Scribd company logo
1 of 45
ランダムフォレスト
goodbaton
内容
ランダムフォレストについて
Kaggleで実践
ランダムフォレストとは
複数の決定木を生成して多数決により決める方法
決定木に使用するデータをランダムに選択するこ
とで相関の低い木を作成できる
多クラスの識別を自然にできる
サイズを大きくしても過学習が生じない
誤り率を求めやすい
ランダムフォレストとは
複数の決定木を生成して多数決により決める方法
決定木に使用するデータをランダムに選択するこ
とで相関の低い木を作成できる
多クラスの識別を自然にできる
サイズを大きくしても過学習が生じない
誤り率を求めやすい
決定木
特徴で領域の分割をする
x
y
決定木
特徴で領域の分割をする
x
y
決定木
特徴で領域の分割をする
x
y
決定木
特徴で領域の分割をする
a
x
y
決定木
特徴で領域の分割をする
b
a
x
y
決定木
特徴で領域の分割をする
c
b
a
x
y
決定木
特徴で領域の分割をする
c
b
a
d
x
y
決定木
領域の分割で木の分岐をする
R1,R2,R3,R4,R5,R6,Y1,Y2,Y3,Y4,Y5,Y6
x
y
決定木
領域の分割で木の分岐をする
R1,R2,R3,R4,R5,R6,Y1,Y2,Y3,Y4,Y5,Y6
R1,R2,R3,R4,R5,Y1,Y2,Y3 R6,Y4,Y5,Y6
a
x<a a≦x
x
y
決定木
領域の分割で木の分岐をする
R1,R2,R3,R4,R5,R6,Y1,Y2,Y3,Y4,Y5,Y6
R1,R2,R3,R4,R5,Y1,Y2,Y3 R6,Y4,Y5,Y6
R4,R5,Y1,Y2,Y3R1,R2,R3
a
b
x<a a≦x
y<b b≦y
x
y
決定木
領域の分割で木の分岐をする
R1,R2,R3,R4,R5,R6,Y1,Y2,Y3,Y4,Y5,Y6
R1,R2,R3,R4,R5,Y1,Y2,Y3 R6,Y4,Y5,Y6
R4,R5,Y1,Y2,Y3R1,R2,R3
Y1,Y2,Y3 R4,R5
a
b
c
x<a a≦x
y<b
x<c c≦x
b≦y
x
y
決定木
領域の分割で木の分岐をする
R1,R2,R3,R4,R5,R6,Y1,Y2,Y3,Y4,Y5,Y6
R1,R2,R3,R4,R5,Y1,Y2,Y3 R6,Y4,Y5,Y6
Y4,Y5,Y6R6R4,R5,Y1,Y2,Y3R1,R2,R3
a
b
c
d
Y1,Y2,Y3 R4,R5
x<a a≦x
y<b b≦y
x<c c≦x
y<d d≦y
x
y
決定木
境界値の決定方法
ジニ係数を利用し不純度を求め、不純度の減少が最大になる分割を行う
ジニ係数
不純度の差
…ノードtでi番目のクラスのデータが選ばれる確率
…左,右のノードに入る要素数の割合
ランダムフォレスト
以下をM回繰り返す(Mは50-200程度)
N個の学習用データからN回の復元抽出を行う
できた集合を用いて決定木を作る
M個の決定木にテストデータ与える
M個の結果から最多の結果を識別結果とする
ランダムフォレスト
#1 #2 #3 #4 #5 #6 #7 #8 ・・・ #N-1 #N
N回復元抽出
N個
ランダムフォレスト
#1 #2 #3 #4 #5 #6 #7 #8 ・・・ #N-1 #N
#6
N回復元抽出
N個
ランダムフォレスト
#1 #2 #3 #4 #5 #6 #7 #8 ・・・ #N-1 #N
#6 #3
N回復元抽出
N個
ランダムフォレスト
#1 #2 #3 #4 #5 #6 #7 #8 ・・・ #N-1 #N
#6 #3 #8
N回復元抽出
N個
ランダムフォレスト
#1 #2 #3 #4 #5 #6 #7 #8 ・・・ #N-1 #N
#6 #3 #8 #6
N回復元抽出
N個
ランダムフォレスト
#1 #2 #3 #4 #5 #6 #7 #8 ・・・ #N-1 #N
#6 #3 #8 #6 #N-1
N回復元抽出
N個
ランダムフォレスト
#1 #2 #3 #4 #5 #6 #7 #8 ・・・ #N-1 #N
#6 #3 #8 #6 #N-1 #2 #5 #7 ・・・ #N-2 #2
N回復元抽出
N個
ランダムフォレスト
#6 #3 #8 #6 #N-1 #2 #5 #7 ・・・ #N-2 #2
1回目
ランダムフォレスト
#6 #3 #8 #6 #N-1 #2 #5 #7 ・・・ #N-2 #2
1回目
ランダムフォレスト
#6 #4 #9 #1 #9 #1 #5 #9 ・・・ #N #8
2回目
ランダムフォレスト
#3 #7 #1 #1 #6 #1 #2 #5 ・・・ #N-1 #7
3回目
ランダムフォレスト
#8 #3 #2 #1 #8 #7 #3 #1 ・・・ #9 #2
M回目
・・・
ランダムフォレスト
・・・
ランダムフォレスト
・・・
3
ランダムフォレスト
・・・
3 8
ランダムフォレスト
・・・
3 8 3
ランダムフォレスト
・・・
3 8 3 3
ランダムフォレスト
・・・
3
ランダムフォレストとは
複数の決定木を生成して多数決により決める方法
決定木に使用するデータをランダムに選択するこ
とで相関の低い木を作成できる
多クラスの識別を自然にできる
サイズを大きくしても過学習が生じない
誤り率を求めやすい
実践!
KaggleのDigit Recognizer
手書きの数字の認識
28*28の256段階の白黒画像
42000個の学習用データ(76.8MB)
28000個のテスト用データ(51.1MB)
工夫1
元 28*28個
1個
+
⇒
特徴数…785個
黒の数…109個
2値化
工夫2
傾けたものも学習
誤認識が増える!!
工夫3
画像の圧縮
2*2
4*4
8*8
14*14
20*20
28*28
高速化!! 誤認識の増加!!
30%!!
実行
木の数 150-400
木のノード数 約50000個
実行時間 約15分!! 3sec/木の数
使用メモリ 約400MB
木の保存テキストデータ 約100MB
提出結果
まとめ
実装はそこまで辛くない
実行に多くの時間と多くのメモリが必要
工夫はあまりできず
楽をしたい人はR言語にライブラリがあるらしい
参考 R言語での実装
https://www.kaggle.com/benhamner/digit-recognizer/random-forest-benchmark
22行!!

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
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
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
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...
 

RandomForest

Editor's Notes

  1. パターン認識の定義は知らん 昨日のスライド
  2. パターン認識の手法 1.決定木の説明は次から 2.バギングを改良したもの 3.SVMやアダブーストでは、1対他の組み合わせ 4.上限はある
  3. 1.決定木の説明は次から 2.バギングを改良したもの 3.SVMやアダブーストでは、1対他の組み合わせ 4.上限はある
  4. x,y座標平面上
  5. x,y座標平面上
  6. x,y座標平面上
  7. 2.バギングを改良したもの 3.SVMやアダブーストでは、1対他の組み合わせ
  8. 0 4 5 2
  9. 昨日のプレゼン
  10. 高速化 -> 今回の趣旨ではない
  11. 木の数400の時 550MB 400以上は変わらない
  12. 改善する