SlideShare a Scribd company logo
1 of 9
Download to read offline
0
Aipy輪読会 第1回
1
輪読会の中での疑問点を整理
 ハイパーパラメータ
 機械学習におけるデータの取り扱い方
 ダミー変数
 正則化
 混同行列
Aipy輪読会 第1回
2
ハイパーパラメータ
 ハイパーパラメータ
機械学習における学習過では決められない、人が調整しなければならないパラメータのこと。
※モデルは多くのパラメーターを持っており、そのパラメータはモデルごとに異なる
 チューニング
ハイパーパラメーターを調整すること。直接、値をモデルに入力したり、あるいは、ハイパーパラメーターの
値の範囲を指定することで最適な値を探してもらう方法がある。
scikit-learnではモデルの構築時にパラメーターに値を入力することでパラメーターのチューニングが可能。
パラメーターを入力しなかった場合、モデルごとに定められているパラメーターの初期値がそのまま値として
指定される。
Aipy輪読会 第1回
3
機械学習におけるデータの取り扱い方
 基本的な考え方
Aipy輪読会 第1回
データセット
学習データ 評価データ
構築データ 検証用
①未知のデータへの評価のために学習データと
評価データに分ける
②パラメータをチューニングするために学習
データをさらに分割し、モデル構築用デー
タとモデル検証用データをつくる
③分割したデータを使ってよさそうなパラ
メータをみつける
データは基本的に「学習データ」と「評価データ」にわける
ハイパーパラメータの
✓ チューニングが必要なければ、「学習データ」「評価データ」でよい
✓ チューニングが必要な時は、「学習データ」を「構築データ」と「検証用」に分ける
4
機械学習におけるデータの取り扱い方
 どうやってよいパラメータを見つけるか?
Aipy輪読会 第1回
データセット
学習データ 評価データ
構築データ 検証用
構築データでの
精度
検証データでの
精度
両方の精度の乖離が小さく、
検証データの精度がよいパラ
メータを選ぶ
構築
データ
検証
データ
モデルの複雑さ
精
度
データの分割方法には、
①ホールドアウト法
②クロスバリデーション
などがある
5
ダミー変数
カテゴリ変数を表現する方法として、よく用いられる手法。ワンホットエンコーディングともいう。
カテゴリ変数を1つ以上の0と1の値を持つ新しい特徴量で置き換える。
↑日本語の説明よりも↓の具体例が分かりやすいと思います。
Aipy輪読会 第1回
動物名
らくだ
ぞう
ねこ
うさぎ
いぬ
らくだ
ねこ
いのしし
らくだ ぞう ねこ うさぎ いぬ いのしし
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
1 0 0 0 0 0
0 0 1 0 0 0
0 0 0 0 0 1
6
正則化
過学習を防ぐために取られるアプローチが汎化である。線形回帰では、汎化手法として正則化が用い
られる。
正則化とは、回帰分析を行うモデルに対し、モデルが推定したデータ同士の関係性の複雑さに対し
てペナルティを加えることによってモデルが推定するデータ同士の関係性を一般化しようとするアプ
ローチ。正則化にはL1正則化とL2正則化の2つがある。
✓ L1正則化
「予測したいデータに対する寄与が薄いデータ」や「他の予測に用いられるデータとの関係性が強
いデータ」の正則化に向いている。これらを回帰分析の際に結果に対する寄与が小さくなるように
係数を小さくする方法。
✓ L2正則化
予測に用いるデータの範囲を算出し、データの範囲を揃えるようにデータに対する係数を小さくすることに
よって回帰分析のモデルの一般化を図ろうとする方法。 データの範囲とは、データが取りうる数値の範囲
のことで、揃える場合は大抵は0から1の範囲になるように調整される。データの範囲を揃えることによっ
て同じ尺度で全てのデータの予測に対する寄与が比較可能になり、 滑らかなモデルを得やすい(汎化しや
すい) という特徴がある。
Aipy輪読会 第1回
7
混同行列
混同行列とは各テストデータに対するモデルの予測結果を、真陽性(True Positive)、真陰性(True Negative)、
偽陽性(False Positive)、偽陰性(False Negative)の4つの観点で分類 をし、それぞれに当てはまる予測結果の個
数をまとめた表です。
用語がややこしいので、図にしてみると、↓
Aipy輪読会 第1回
予想
現
実
〇と予想 ×と予想
〇
×
① ②
③ ④
は予想が的中してるもの
このとき、次のように定義します。
 正解率 :全体の中のあっている割合
= (①+②)/ (① + ② + ③ + ④)
 適合率:〇と予想した中で、実際に〇の割合
= ① / (① + ③)
 再現率:〇のデータの中で、〇と予想できた割合
= ① / (① + ②)
8
混同行列:正解率だけだとまずい
がん検診の結果、患者10,000人の診断結果の混合行列を考える。
この場合、正解率は (60+9760) / (60+140+40+9760) = 98.2% と高い正解率になるが、
✓ 100人の癌の方のうち40%は「癌ではないだろう」と誤診 ※再現率は60/(60+40)=40%
✓ 癌と予想した方が実際に癌である確率は、30%程度 ※適合率は60/(60+140)=30%
という問題がある。これは、 患者のほとんどが癌ではない ことによるもので、データに偏りがある状
態で「正解率」という指標を使うのは非常に危険である。
Aipy輪読会 第1回
癌:予想 癌ではない:予想
癌:実際 60 40
癌ではない:実際 140 9760
正解率だけではなく、再現率、適合率も確認しないと
正しい判断はできないね、という話

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

Featured (20)

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

Topics in aipy the first