SlideShare a Scribd company logo
1 of 8
R の壁

第 3 回 Japan.R (2012/12/1)
     統計数理研究所
      @zgmfx20a
R 修得のハードル
• R が難しいとされる点
 – R そのもののプログラム言語的側面 / 背景
 – 統計的な知識
• 調べる力があれば乗り越えられる ( と思う
  が)
 – 研究者なら少しのサポートで乗り越えられて
   いる
 – どうもそうとは限らないケースもある
• とある ( 博士課程を有する ) 大学院での出
  来事
 – 論文作成には調べる力が要求されると思うが
動かないので助けてください …
• 某大学院の先生から助けを乞われる
• 対象のデータを Excel で渡される
• ざっと眺めて … 原因は一瞬で特定!
 – セルが空もしくは数字以外
 – 一瞬で判別可能な程度の行数と列数の規模
• こういう照会が一度だけなら …
 – ( 残念ながら ) 何度も同じことの繰り返し
 – きちんと検算してればこんな事にはならない
   筈
  • 実験科学者としての姿勢に疑問
そもそも
• 実験   > library(randomForest)
       > iris1 <- iris
       > iris1[1,1] <- NA
       > iris1.rf <- randomForest(iris1[,-5])
        以下にエラー randomForest.default(iris1[, -5]) :
        NA not permitted in predictors

• 中学生の英語力で NA は許可されない … と判る
• では次に「 NA 」が何かを調べるべき
 – 大抵の R 教科書の目次に必ずあるはず
 – せめて「 NA ってなんですか?」ならまだ救いが …
• 調べる技術以前に調べようとする意識がないと
  しか
コミュニケーションが成立して
      ない
• 研究室の学生さんのメールが iPhone に着信
 – 添付のように RF の重要度出力が変なのは何故
• 図が見れない
 – 拡張子から Windows のメタファイルと推定
• 先生に (jpeg とか ) 読める形式での再送を要求
• 先生から同じ内容が再送される
 – Windows をやっとこさ起動して読むも図だけで詳細
   不明
 – ざっと見て … これは追試しないと判らん …
• 「データがないと何とも言えません」と回答
• 先生からは「必要ならデータを送るので宜し
  く」と
交叉検証
• 2 週間後再度データ送付依頼
  – データを見て絶句
  – 正例 1 負例 5 からなるデータセット
    • これじゃ交叉検証が成立しないのでは?
         – 正例をテストセットに選択した時点で …

• 実験 1
         >   irisbad <- iris[c(1,51:55),]
         >   irisbad.crf <- randomForest(irisbad[,-5],
         +   as.factor(as.character(irisbad[,5])), imp=T)
         >   varImpPlot(irisbad.crf)
• 実験 2
  – 負例の1つを正例に変更
    • 重要度出力 (MDA) に強弱がついた
                 MDA MeanDecreasedAccuracy
そもそも
• この時点で学習に失敗しているのは明らか
 > irisbad.crf
 Confusion matrix:
            setosa versicolor class.error
 setosa          0          0         NaN
 versicolor      0          5           0
• あり得ない手順
 – 分類表で判別精度を確認してから変数の重要度を
   云々
• 「交叉検証の問題だと思います」と先生に回答
 – 交叉検証について調べて自己解決を促したが甘かっ
   た
• 「今後のためにやり方をご教示ください」と
 – 回答不可能 ( 私のしたことは「捏造」で教えられませ
   ん)
まとめ
• 初心者は R を使うなという事ではありま
  せん
 – みなさん最初はそうです
• R に限らず調べるという姿勢は必要です
 – 調べることを放棄した人には利用は困難です
 – 動かないのを R のせいにしてはいけません!
  • 今回のケースはどう考えても R 以前の問題
• R は正しく使い合理的な解釈を導く道具
  です
 – ウソをつくためのものではありません
• ご清聴ありがとうございました

More Related Content

Featured

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
ThinkNow
 
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
Kurio // The Social Media Age(ncy)
 

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...
 

Rの壁

  • 1. R の壁 第 3 回 Japan.R (2012/12/1) 統計数理研究所 @zgmfx20a
  • 2. R 修得のハードル • R が難しいとされる点 – R そのもののプログラム言語的側面 / 背景 – 統計的な知識 • 調べる力があれば乗り越えられる ( と思う が) – 研究者なら少しのサポートで乗り越えられて いる – どうもそうとは限らないケースもある • とある ( 博士課程を有する ) 大学院での出 来事 – 論文作成には調べる力が要求されると思うが
  • 3. 動かないので助けてください … • 某大学院の先生から助けを乞われる • 対象のデータを Excel で渡される • ざっと眺めて … 原因は一瞬で特定! – セルが空もしくは数字以外 – 一瞬で判別可能な程度の行数と列数の規模 • こういう照会が一度だけなら … – ( 残念ながら ) 何度も同じことの繰り返し – きちんと検算してればこんな事にはならない 筈 • 実験科学者としての姿勢に疑問
  • 4. そもそも • 実験 > library(randomForest) > iris1 <- iris > iris1[1,1] <- NA > iris1.rf <- randomForest(iris1[,-5]) 以下にエラー randomForest.default(iris1[, -5]) : NA not permitted in predictors • 中学生の英語力で NA は許可されない … と判る • では次に「 NA 」が何かを調べるべき – 大抵の R 教科書の目次に必ずあるはず – せめて「 NA ってなんですか?」ならまだ救いが … • 調べる技術以前に調べようとする意識がないと しか
  • 5. コミュニケーションが成立して ない • 研究室の学生さんのメールが iPhone に着信 – 添付のように RF の重要度出力が変なのは何故 • 図が見れない – 拡張子から Windows のメタファイルと推定 • 先生に (jpeg とか ) 読める形式での再送を要求 • 先生から同じ内容が再送される – Windows をやっとこさ起動して読むも図だけで詳細 不明 – ざっと見て … これは追試しないと判らん … • 「データがないと何とも言えません」と回答 • 先生からは「必要ならデータを送るので宜し く」と
  • 6. 交叉検証 • 2 週間後再度データ送付依頼 – データを見て絶句 – 正例 1 負例 5 からなるデータセット • これじゃ交叉検証が成立しないのでは? – 正例をテストセットに選択した時点で … • 実験 1 > irisbad <- iris[c(1,51:55),] > irisbad.crf <- randomForest(irisbad[,-5], + as.factor(as.character(irisbad[,5])), imp=T) > varImpPlot(irisbad.crf) • 実験 2 – 負例の1つを正例に変更 • 重要度出力 (MDA) に強弱がついた MDA MeanDecreasedAccuracy
  • 7. そもそも • この時点で学習に失敗しているのは明らか > irisbad.crf Confusion matrix: setosa versicolor class.error setosa 0 0 NaN versicolor 0 5 0 • あり得ない手順 – 分類表で判別精度を確認してから変数の重要度を 云々 • 「交叉検証の問題だと思います」と先生に回答 – 交叉検証について調べて自己解決を促したが甘かっ た • 「今後のためにやり方をご教示ください」と – 回答不可能 ( 私のしたことは「捏造」で教えられませ ん)
  • 8. まとめ • 初心者は R を使うなという事ではありま せん – みなさん最初はそうです • R に限らず調べるという姿勢は必要です – 調べることを放棄した人には利用は困難です – 動かないのを R のせいにしてはいけません! • 今回のケースはどう考えても R 以前の問題 • R は正しく使い合理的な解釈を導く道具 です – ウソをつくためのものではありません • ご清聴ありがとうございました