Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
分位点回帰 / quantile regression
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
jeey
May 29, 2020
Science
840
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
分位点回帰 / quantile regression
jeey
May 29, 2020
More Decks by jeey
See All by jeey
uplift modeling
jeyjeyjeey
0
2.9k
対数変換ってしてもいいの? / Is it really okey to do Log Transformation
jeyjeyjeey
0
86
目的関数と評価指標 / Objective Function and Evaluation Metrics
jeyjeyjeey
0
200
ビッグデータの哲学 / Philosophy of Big Data
jeyjeyjeey
0
69
Webマーケティング業務のデータサイエンス ざっくり編 / data science in web marketing business (Big Picture)
jeyjeyjeey
0
130
Other Decks in Science
See All in Science
東北地方における過去20年間の降水量の変化
naokimuroki
1
250
データベース08: 実体関連モデルとは?
trycycle
PRO
0
1.2k
生成AI・プレプリント時代における 研究成果公開の再設計 ― トップカンファレンス文化はどこへ向かうのか / Redesigning the Dissemination of Research Outputs in the Age of Generative AI and Preprints — Where Is the Top-Conference Culture Heading?
ykiyota
0
27k
白金鉱業Vol.21【初学者向け発表枠】身近な例から学ぶ数理最適化の基礎 / Learning the Basics of Mathematical Optimization Through Everyday Examples
brainpadpr
1
750
検索と推論タスクに関する論文の紹介
ynakano
1
230
AI(人工知能)の過去・現在・未来 ~AIは人類を越えるのか~
tagtag
PRO
0
100
Understanding CVP Waveforms: Interpretation and Clinical Implications in Anesthesiology
taka88
0
580
知能とはなにか -ヒトとAIのあいだ-
tagtag
PRO
1
100
MATSUO Makiko
genomethica
0
150
データベース09: 実体関連モデル上の一貫性制約
trycycle
PRO
0
1.2k
Amusing Abliteration
ianozsvald
1
200
因果推論と機械学習
sshimizu2006
1
1.2k
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
310
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
We Have a Design System, Now What?
morganepeng
55
8.2k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
What's in a price? How to price your products and services
michaelherold
247
13k
Scaling GitHub
holman
464
140k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
840
Transcript
Q u a n t i l e R e
g r e s s i o n Q u a n t i l e R e g r e s s i o n Q u a n t i l e R e g r e s s i o n Q u a n t i l e R e g r e s s i o n Q u a n t i l e R e g r e s s i o n Q u a n t i l e R e g r e s s i o n Q u a n t i l e R e g r e s s i o n Ґ ճؼ
1. ༧ଌͷ৴པੑͱ 2. ༧ଌͷ৴པੑͷϞσϦϯά 3. ϐϯϘʔϧଛࣦؔ 4. ଛࣦؔʹΑΔҐͷਪఆ 5. ར༻ՄೳͳϥΠϒϥϦ
1. ༧ଌͷ৴པੑͱ
Ͳͬͪͷ༧ଌಉ͘͡Β͍৴པͰ͖Δ͔ͳʁ
ੳ՝ʹ͓͍ͯɺ͋Δ༧ଌͷ֬ΛҙࢥܾఆͷҰॿͱ͍ͨ͠ ߹͕͋Δ ·ͨɺ࣮ଌΑΓ্ৼΕɾԼৼΕͨ͠Λࢀߟʹҙࢥܾఆͨ͠ ΄͏͕ɺ҆શଆͷஅͱͳΔ߹͕͋Δ ༧ଌͷ৴པੑ
༧ଌͷ෯͕ ͱͳΔ߹ ྫʣࢿஅ ࠷େརӹͱͳΔ༧ଌ͕ਪఆ͞Εͨͱͯ͠ɺͦ Ε͕ಉ࣌ʹ࠷རӹͱͳΔՄೳੑ͋Δ͘Β͍ෆ ֬ఆͳ༧ଌͰ͋Δ߹ɺͦΕΑΓརӹ ͍͕ݻ͍༧ଌͰࢿஅΛߦ͍͍ͨɺͱ͍͏ Α͏ͳϦεΫධՁಉ࣌ʹߦ͍͍ͨ߹͕͋Δ ʢϘϥςΟϦςΟͷ༧ଌʣ ͜ΜͳઢΛҾ͍ͯɺϦεΫͱϦλʔϯͷόϥϯε
Λͱͬͯҙࢥܾఆ͍ͨ͠
༧ଌͷ্ৼΕ͕ ͱͳΔ߹ ྫʣ৯খചۀऀ Ұൠʹ95%Ҏ্ͷඇৗʹߴ͍αʔϏεϨϕϧΛ ٻ͢Δʢͭ·ΓɺࡏݿΕඇৗʹكʣ ͜ͷ߹ɺଈ࣌ൢചͷࡏݿ͕ͳ͍ΑΓɺ༨ࡏݿ Λ๊͑Δ΄͏͕ྑ͍ͱஅ͞ΕΔ ্ৼΕͷઢΛҾ͍ͯɺ͜ͷ༧ଌͰҙࢥܾఆΛ͍ͨ͠
༧ଌͷԼৼΕ͕ ͱͳΔ߹ ྫʣࣗಈंϝʔΧʔ ৗʹੜ࢈ίετΛݮ͢ΔΑ͏ࢦ͓ͯ͠Γɺࡏ ݿθϩઓུΛબ͢ΔϝʔΧʔ͋Δʢं͕ߪೖ ͞Ε͔ͯΒɺͦͷޙੜ࢈͢Δʣ ͜ͷ߹ɺ༨ࡏݿΛ๊͑ΔΑΓɺଈ࣌ൢചͷࡏ ݿ͕ͳ͍΄͏͕ྑ͍ͱஅ͞ΕΔ ԼৼΕͷઢΛҾ͍ͯɺ͜ͷ༧ଌͰҙࢥܾఆΛ͍ͨ͠
Ҏ্ͷΑ͏ͳ߹ɺ͜ͷ༧ଌ۠ؒʢ্ৼΕɾԼৼΕʣ͕Θ͔ΔΑ͏ʹ ϞσϧΛ࡞ͨ͠΄͏͕ɺϏδωε՝ʹد༩Ͱ͖Δ߹͕͋Δ ༧ଌ۠ؒ
2. ༧ଌͷ৴པੑͷϞσϦϯά
ਪఆͰͳ͘ɺ্ৼΕɾԼৼΕΛਪఆ ͢ΔͨΊʹɺ༧ଌ۠ؒͷਪఆΛߦ ͍͍ͨ ࠓճɺҐͷਪఆΛߦ͏ࣄʹΑΓɺ ༧ଌ۠ؒͷਪఆΛߦ͏ख๏Λհ͢Δ ༧ଌ͕۠ؒΘ͔Δ΄͔ʹɺͦͷҐʹ ͓͚ΔภճؼͷมಈΘ͔Δ ࣌ܥྻϞσϧʹԠ༻Ͱ͖Δ ҐճؼʢΫΦϯλΠϧճؼʣ
3. ϐϯϘʔϧଛࣦؔ
ྫ͑ઢܗճؼͰతؔʹೋޡࠩؔΛ༻͍Δ ͕ɺҐճؼͰΘΓʹϐϯϘʔϧଛࣦؔʢඇ ରশઈରޡࠩؔʣΛ༻͍Δ ԼهͷΑ͏ʹॏΈ͚Λߦ͏ ࣮ଌͱ༧ଌͱͷࠩʢeʣ͕ਖ਼ͷͱ͖Н ࣮ଌͱ༧ଌͱͷࠩʢeʣ͕ෛͷͱ͖Н−̍ ϐϯϘʔϧଛࣦؔ ඍՄೳͳͷͰɺతؔͱͯ͠ධՁࢦඪͱͯ͠ ༻͍Δ͜ͱ͕Ͱ͖Δ τΛ0.5ͱ͢ΔͱதԝͱͳΔ
ϐϯϘʔϧଛࣦؔ ϐϯϘʔϧͷϘʔϧͷيಓʹɹ ࣅ͍ͯΔ͔ΒΒ͍͠ ࣮ͷϐϯϘʔϧ τΛΫΦϯλΠϧͱͯ͠ఆٛʢ95%ͳΒ0.95ʣ͠ɺ Нͷൣғଛࣦ͕ޡ͕ࠩ͘ධՁ͞Εɺൣғ֎Ͱ ޡ͕ࠩେ͖͘ධՁ͞ΕΔΠϝʔδ
4.ଛࣦؔʹΑΔ Ґͷਪఆ
͜ͷଛࣦؔͷ࠷খԽΛߦ͏͜ͱͱɺҐͷਪఆΛߦ͏͜ͱ͕ಉٛ Ͱ͋Δ͜ͱɺֶతʹಋ͘͜ͱ͕Ͱ͖Δ https://en.wikipedia.org/wiki/Quantile_regression ϐϯϘʔϧଛࣦؔͷܭࢉɺ ͋Δ֬ʹै͏֬ม:ʢ࣮ଌʣͱ ҐVͱͷࠩͷظͱݴ͍͑ͯྑ͍ ߹͚ʹैͬͯղ͢Δʢࢄͷ߹ʣ ࠷খԽͷͨΊɺVʹ͍ͭͯඍ ਪఆҐV R@aUBV
ʹ͓͚Δ:ͷྦྷੵີ͕Нͱ͘͠ͳΔ
5. ར༻ՄೳͳϥΠϒϥϦ
import statsmodels.formula.api as smf q = .975 mod = smf.quantreg('y
~ x', data) upper_mod = mod.fit(q=q) lower_mod = mod.fit(q=1-q) import lightgbm as lgb q = .975 clf_upper = lgb.LGBMRegressor(objective='quantile', alpha=q).fit(x, y) clf_lower = lgb.LGBMRegressor(objective='quantile', alpha=1-q).fit(x, y) # lossʹԼهͷΑ͏ͳϐϯϘʔϧଛࣦؔΛఆٛͯ͠ࢦఆ͢Δ class QuantileLoss(nn.Module): def __init__(self, quantiles): super().__init__() self.quantiles = quantiles def forward(self, preds, target): assert not target.requires_grad assert preds.size(0) == target.size(0) losses = [] for i, q in enumerate(self.quantiles): errors = target - preds[:, i] losses.append( torch.max( (q-1) * errors, q * errors ).unsqueeze(1)) loss = torch.mean( torch.sum(torch.cat(losses, dim=1), dim=1)) return loss ઢܗϞσϧʢPython: statsmodelsʣ ޯϒʔεςΟϯάܾఆʢPython: Lightgbmʣ Deep LearningʢPython: Pytorchʣ ઢܗϞσϧʢR: quantreg R͍ͬͺ͍͋Δʣ library(quantreg) rq(y~x, data=data, tau=seq(0,1,0.25))
※KaggleͰ༧ଌ۠ؒਪఆͷίϯϖ͕։࠵த
• R Koenker, Kf Hallock, Quantile Regression, Journal Of Economic
Perspectives, 2001 • Wikipedia, Quantile Regression • Https://En.Wikipedia.Org/Wiki/Quantile_Regression • Lokad • Https://Www.Lokad.Com/Jp/Ґ༧ଌ-ٕज़ • Https://Www.Lokad.Com/Jp/ΫΥϯλΠϧ-ճؼ-ʢ࣌-ܥྻʣ-ఆٛ • Https://Www.Lokad.Com/Jp/ϐϯϘʔϧϩεػೳ-ఆٛ • ҐճؼΛͬͯɺʮͦͷճؼ༧ଌͲΕ͙Β͍֎ΕΔͷʁʯΛઆ໌͢Δ • Https://Devblog.Thebase.In/Entry/2018/12/06/110655 • Qrnn χϡʔϥϧωοτΛ༻͍ͨҐճؼ • Https://Aotamasaki.Hatenablog.Com/Entry/2019/01/29/191604 • ฏۉ͔ΒҐɿҐճؼ • Https://Www.N-Insight.Co.Jp/Niblog/20150903-1087/ • Quantile Regression — Part 2 • Https://Medium.Com/The-Artificial-Impostor/Quantile-Regression-Part-2-6Fdbc26B2629 ࢀߟ