SlideShare a Scribd company logo
1 of 21
説明変数の測定不良に対する
回帰モデル
@YTM_circle10
2018/03/11
概要
■ 説明変数に外れ値が乗る場合の回帰モデル
– 外れ値を含む説明変数𝑋は、潜在変数𝑋𝑡𝑟𝑢𝑒にノイズが乗ったものとする
– 応答変数は潜在変数𝑋𝑡𝑟𝑢𝑒から線形回帰
– 外れ値以外は 𝑋𝑡𝑟𝑢𝑒 ≅ 𝑋 であって欲しい[信頼区間、予測区間への影響は避けたい]
■ アヒル本※1の§7.7を参考に,有用なモデルを探索した
– データは上記アヒル本から「data-salary.txt」を一部改変して使用
– 𝑋𝑡𝑟𝑢𝑒に加わるノイズ分布が問題
■ 「UBN分布」※2を改変した「UB-Laplace分布」によるモデルを作成した
※1:松浦健太郎氏の「StanとRでベイズ統計モデリング」
※2:Uniformly Boosted Normal Distribution. 松浦氏が下記のブログ記事で提案した分布。
[http://statmodeling.hatenablog.com/entry/spot-detection-using-markov-field-model-with-UBN-distribution]
問題
業務でしばしば経験すること
■ 観測値から観測困難な変数を推定する
– 入力=説明変数には外れ値が多発(センサのコスト等に因る)
– 応答変数は再入手困難 → 現有データで結論を出す
– メーカー特有の問題かもしれない…
■ 説明変数に外れ値を含む場合の回帰モデルが必要
– 説明変数がノイズだらけなら、素直に” 𝑋 ~ 𝑁𝑜𝑟𝑚𝑎𝑙 𝑋𝑡𝑟𝑢𝑒, 𝜎 𝑋 ”とする
– しかし大抵の場合、外れ値以外の説明変数はそこそこ信頼できる※1
➡︎ 外れ値以外は”𝑋𝑡𝑟𝑢𝑒 ≅ 𝑋”となるモデルを考えた
※1:だからこそ説明変数に選ばれている訳で…
使用データ
■ 説明変数にスイッチ的なノイズ(外れ値)が混入する状況を想定
– 通常は小さな測定ノイズしか乗らない
– 稀に測定系の外から巨大なノイズが乗る
■ アヒル本の「data-salary.txt」に2点外れ値を挿入したものを使用
1.潜在説明変数モデル
アヒル本の§7.7.のモデルを改良したモデルを試行した
当初のモデル案
 応答変数Yの外れ値とみなすことも可能
– 観測ノイズにCauchy分布を仮定すればOK※1
𝑌 ~ 𝐶𝑎𝑢𝑐ℎ𝑦(𝑎 + 𝑏𝑋𝑡𝑟𝑢𝑒, 𝜎 𝑌)
– 予測区間が広がるため、「○○%予測区間は±xx」が欲しい時には
邪魔になる
■ 説明変数Xにノイズを仮定したモデルを使用する
– アヒル本§7.7.のモデルを改変
– 観測された説明変数Xは、潜在変数Xtrueにノイズが混入したとする
𝑋 ~ 𝑁𝑜𝑟𝑚𝑎𝑙 𝑋𝑡𝑟𝑢𝑒, 𝜎 𝑋
– Xに乗るノイズをCauchyにすれば良い?
※1:実際の業務ではこれで片付けることが多い…
モデル#1-1 ‥「潜在説明変数」モデル
■ アヒル本§7.7.のモデルをベースに、説明変数にかかるノイズ分布
を normal から cauchy に変更
𝑋 ~ 𝐶𝑎𝑢𝑐ℎ𝑦 𝑋𝑡𝑟𝑢𝑒, 𝜎 𝑋
𝑌 ~ 𝑁𝑜𝑟𝑚𝑎𝑙(𝑎 + 𝑏𝑋𝑡𝑟𝑢𝑒, 𝜎 𝑌)
■ まずは何の制限もつけずに実行
モデル#1-1:結果
推定結果を右図に示す
●:実データ点, ○:X_true事後平均
■:50%予測区間, ■:90%予測区間
モデル#1-1:問題点
■ 収束がかなり怪しい※1 (特にs_Y)
■ Xtrueに全て内側に寄ってしまう
– 外れ値以外のデータ点についても、Xtrueが回帰直線に接近している
– YのばらつきがXtrueに押し付けられている?
※1:trace_plotを必ず見るべきだが、ここではそれ以前にn_effが論外。
対策案
■ 弱情報事前分布による制限 → モデル#1-2
– 観測ノイズを弱情報事前分布で制限
■ “s_X”(𝜎 𝑋)の事前分布に、自由度4のstudent_t+を使う
– 説明変数側のノイズを制限(同上)
■ 「Xtrueに乗るノイズ」をスパースにする → モデル#2
– XのノイズにLaplace分布を仮定し、L1正則化をかける
– 裾の重さを与えるために、Laplace分布に一様分布を足し込む
(UB-Laplace分布)
モデル#1-2‥s_Xの制限
■ 弱情報事前分布により“s_X”(𝜎 𝑋)の値を制限する
– 自由度4のstudent半t分布を使う
– 近年の動向を踏まえ、逆Gammaは使わない
– 制限幅の概算が困難なため、上述のモデル1-2-1での事後平均
𝜎 𝑋 = 0.93よりは小さくすることを考え、0.5を上限とした
𝜎 𝑋 ~ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡 𝑡+(4, 0, 0.5)
■ Stanスクリプト上では下記の通り
モデル#1-2:結果
結果
■ 50%予測区間内においては、
Xtrueのズレが抑制された
■ やや外寄りの点では、変わら
ず内側に寄っていく…
→ 分散を制限したところで、
根本の解決にはなっていない
●:実データ点, ○:X_true事後平均
■:50%予測区間, ■:90%予測区間
2.UB-Laplaceモデル
「UBN分布」をベースとしたモデルを作成した
モデル#2‥Laplaceモデル
■ 分散の制限では、根本の解決にはならない
■ 説明変数X(ノイズ込み)にLaplace分布を仮定し、L1正則化を行う
– L1正則化により、大半のX_trueはXに一致するはず
■ 「稀に大きく外れる」性質を持たせるため、Laplace分布にゲタ をはか
せる必要がある
– 松浦健太郎氏の「UBN分布」を参考にした
[→http://statmodeling.hatenablog.com/entry/spot-detection-using-markov-
field-model-with-UBN-distribution]
– 同様の考え方をLaplace分布に適用し、「UB-Laplace分布」を作る!
モデル#2‥UB-Laplace分布
■ Laplace(DoubleExponential)分布に一様分布Uniform([a,b])を足す
𝑈𝐵𝐿𝑎𝑝𝑙𝑎𝑐𝑒 𝑋 𝑎, 𝑏, 𝑢, 𝜇, 𝜎 =
1
𝐶
𝑢 +
1
2𝜎
−
𝑥 − 𝜇
𝜎
, 𝑥 ∈ 𝑎, 𝑏 .
■ Stan実装時には対数を取り、
log 𝑈𝐵𝐿𝑎𝑝𝑙𝑎𝑐𝑒 𝑥 𝑎, 𝑏, 𝑢, 𝜇, 𝜎
= log
𝑢
𝐶
+ 𝑙𝑜𝑔1𝑝 _ exp − log 𝑢 + 𝑑𝑜𝑢𝑏𝑙𝑒_𝑒𝑥𝑝𝑜𝑛𝑒𝑛𝑡𝑖𝑎𝑙_𝑙𝑝𝑑𝑓(𝑦|𝜇, 𝜎) ,
■ 正規化定数𝐶は概ね定数とみなし、実装時にはlog
𝑢
𝐶
を省略
– 𝜎がさほど変動しないならOK
モデル#2:Stanコード
■ 以下
モデル#2:Rスクリプト
■ kickしたRコードは以下
– Uの値(0.002)は試行錯誤による仮決め
– 本家UBN分布に倣って、ADVIで推定した
モデル#2:結果
■ 結果(U=0.002)
– 元ネタに倣い、vb(ADVI)
で実行
– Uは試行錯誤で決定した
(要考察)
 外れ値2点のみ右に移動、
他の点はほぼ動かず!
– わかりにくい場合は
次ページの拡大図へ
●:実データ点, ○:X_true事後平均
■:50%予測区間, ■:90%予測区間
モデル#2:拡大図
●:実データ点, ○:X_true事後平均
■:50%予測区間, ■:90%予測区間
モデル#2:U=2e-6の場合
■ UB-Laplaceの裾を軽くしてみた(ほぼLaplace分布)
– 外れ値が動かない
 Uの値は試行錯誤が必要
まとめ
■ UB-Laplace分布の使用により、説明変数にスイッチ的な外れ値が
加わるモデルを作成した
■ このモデルにより、説明変数に外れ値がある場合にも対処できる
■ 他の分野でも、スイッチ的な変動の再現etc.に使えるかも
課題
■ Uの値を試行錯誤で決めている
■ 変数が多いとき(d=10,000とか)は厳しそう

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
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

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...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

[RStan]"UB-Laplace分布"による説明変数の測定不良(外れ値)に対する回帰モデル