SlideShare a Scribd company logo
1 of 9
レポート 機械学習
線形回帰
線形回帰というのは、ある入力データから直線または曲線で連続的な出力を得るためのモ
デルである。説明変数から目的変数を予測する必要があることから教師あり学習の一つで
ある。式としては、y
̂
=∑ 𝑤𝑗𝑥𝑗 +
𝑚
𝑗=1 𝑥0のようにあらわされる。
パラメータ w を求めるためには学習データの平均二乗誤差(MSE)を最小にする最小二乗
法を用いる。MSE を最小とするようなパラメータ w が求めるものである。
scikit-learn のボストンデータを用いて、実装を行った。
この実装では scikit-learn の LinearRegression を用いて予測を行った。手計算だと大変だっ
たが実装自体は簡単であったため、背景を知らずに実装だけ学んでも自分の知識的には意
味がないと感じた。
非線形回帰
第 1 章の様に単純に線形であらわされるものだけではないため、その場合こちらのモデル
を使用する。パラメータを最小二乗法などで求めることは線形回帰と似ているが、1 次の説
明変数ではなく基底関数を用いるところが異なる。基底関数としては多項式型とガウス型
がある。
線形回帰はデータのばらつきを誤差として無視する要素があるが、
非線形回帰では
複雑なモデルにはなるもののばらつきを表現することが出来る。
ただしこれにより、
一定の
誤差は表現できるものの、
無視すべき誤差まで拾いすぎて過学習を起こす可能性がある。
そ
のため、
不要な基底関数の削除や正則化
(モデルが複雑になればなるほど大きくなるパラメ
ータを用意する)を用いる。正則化には L2 ノルム(2 乗の和)も用いた Ridge 推定量、L1
ノルム(1 次の和)を用いた Lasso 推定量が存在する。正則化を用いればモデルが複雑にな
ったとしても、パラメータが一定の水準に収まるため過学習が起こりにくい。
また、
過学習が起こりにくい訓練方法として、
学習データを一部分割して残し学習させて残
りで検証するホールドアウト法がある。分割方法を変えてホールドアウトを複数実施して
最適なモデルを選ぶクロスバリデーション法がある。
実装する中で Ridge を使った時のαを大きくすると滑らかで凸凹が少ない曲線に、小さく
するとよりデータにフィットするような複雑な曲線になった。これにより正則項が大きい
ほどパラメータを大きくすることを防ぐためであることを実感できた。
ロジスティック回帰
ロジスティック回帰とは、
これまでの回帰とは異なり、
あるデータを分類するための手法で
ある。ロジスティック線形回帰モデルとは分類問題を解くための教師ありの機械学習モデ
ルであり、入力データを線形結合のした後シグモイド関数で 0~1 の確率へ変換する。
シグモイド関数の形は、𝜎(𝑥) =
1
1+exp⁡
(−𝑎𝑥)
となる。シグモイド関数の特徴は、微分をすると
元のシグモイド関数であらわせることである。
ロジスティック回帰において、適切なパラメータを求めるためには最尤推定法を用いる。
尤度関数は求めた確率の積であらわせることができ、その尤度関数を最大化するパラメー
タが求めるものである。
ただし解析的に求めることはできないため、
勾配降下法でパラメー
タを更新していく手法を用いる。
タイタニック号のデータを用いて実装の練習を行った。
最後に seaborn を使った実装のグラフを参考に 4 つの特徴量で予測をした結果、実装の練
習の数値よりも高いスコアで得られた。
主成分分析
主成分分析とは多変量データをデータの持つ情報量をなるべく減らさずに少数の指標に圧
縮する手法である。
圧縮後のデータの分散が最大になるようなパラメータを求める。
ただし、
制約を設けないと解が無限にできてしまうので、ノルムが1となる制約を入れて計算する
と圧縮後の分散行列の固有値と固有ベクトルが解となる。
主成分分析で実装を行い、
すべての特徴量でロジスティック回帰をした場合と、
主成分2つ
で回帰をした場合の決定係数を比較すると、
多少精度は低くなったものの、
それなりの数値
となったため、2つにしても十分な予測精度が見込まれることが分かった。
K-means 法
K-means 法は教師なし学習で与えられたデータをk個のクラスタに分類する手法である。
アルゴリズムとしては各クラスタの中心の初期値を設定し、各データ点に最も中心が近い
クラスタを割り当て平均ベクトルを計算し新たな中心として設定する。おれを何度も繰り
返し中心を更新していく。
実装ではモデルが sklearn に入っている KMeans を使うと簡単にできた。
ただし、正しいラベル通りに分類は完全にはできないことが分かった。
SVM
サポートベクトルマシンとは 2 クラス分類問題の手法の一つである。考え方としては、デ
ータを二つに分ける境界線を引くのだが、境界線に一番近い点との距離(マージン)を最大
化することである。ただし、直線で分けられないような2次元のケースで、3次元へ拡張す
るようなカーネルトリックを用いることで分類が可能となる工夫がある。
実装について
ラグランジュ乗数法と最急降下法により指定の回数 a を更新して a を求めた。大半の要素
が 0 となっていることが分かった。
自身の理解のために、
xx0,xx1,y_project の中身と contour の使い方の理解のための実装をお
おなってみた。
求める y は xx0,xx1 が増加する方向に傾いた平面上になっていることが分か
った。
Contour で level を-1,0,1 で指定して等高線を引いてみると境界が 0、1,-1 が境界に一番近
い点に沿って線が引かれていることが分かった。
境界線の予測のために、実装では RBF カーネルを使用した。
先の実装では xx0,xx1 ではなく rbf で変換した値で y を予測することにより、もう一つの次
元に拡張した平面で点を切るような分け方となっている。
またデータが重なりありの場合も、
重なりがない場合と同様の手順で求められるため、
実装
自体は難しいものではなかった。

More Related Content

Recently uploaded

POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
Cherry
 
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Cherry
 
Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.
Cherry
 
LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.
Cherry
 
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cherry
 
Pteris : features, anatomy, morphology and lifecycle
Pteris : features, anatomy, morphology and lifecyclePteris : features, anatomy, morphology and lifecycle
Pteris : features, anatomy, morphology and lifecycle
Cherry
 
GENETICALLY MODIFIED ORGANISM'S PRESENTATION.ppt
GENETICALLY MODIFIED ORGANISM'S PRESENTATION.pptGENETICALLY MODIFIED ORGANISM'S PRESENTATION.ppt
GENETICALLY MODIFIED ORGANISM'S PRESENTATION.ppt
SyedArifMalki
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
NazaninKarimi6
 
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
US Environmental Protection Agency (EPA), Center for Computational Toxicology and Exposure
 

Recently uploaded (20)

Adaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte CarloAdaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte Carlo
 
GBSN - Biochemistry (Unit 3) Metabolism
GBSN - Biochemistry (Unit 3) MetabolismGBSN - Biochemistry (Unit 3) Metabolism
GBSN - Biochemistry (Unit 3) Metabolism
 
Genome Projects : Human, Rice,Wheat,E coli and Arabidopsis.
Genome Projects : Human, Rice,Wheat,E coli and Arabidopsis.Genome Projects : Human, Rice,Wheat,E coli and Arabidopsis.
Genome Projects : Human, Rice,Wheat,E coli and Arabidopsis.
 
Efficient spin-up of Earth System Models usingsequence acceleration
Efficient spin-up of Earth System Models usingsequence accelerationEfficient spin-up of Earth System Models usingsequence acceleration
Efficient spin-up of Earth System Models usingsequence acceleration
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
 
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
 
Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.
 
Understanding Partial Differential Equations: Types and Solution Methods
Understanding Partial Differential Equations: Types and Solution MethodsUnderstanding Partial Differential Equations: Types and Solution Methods
Understanding Partial Differential Equations: Types and Solution Methods
 
FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.
 
LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.
 
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
 
Pteris : features, anatomy, morphology and lifecycle
Pteris : features, anatomy, morphology and lifecyclePteris : features, anatomy, morphology and lifecycle
Pteris : features, anatomy, morphology and lifecycle
 
GBSN - Microbiology (Unit 4) Concept of Asepsis
GBSN - Microbiology (Unit 4) Concept of AsepsisGBSN - Microbiology (Unit 4) Concept of Asepsis
GBSN - Microbiology (Unit 4) Concept of Asepsis
 
GENETICALLY MODIFIED ORGANISM'S PRESENTATION.ppt
GENETICALLY MODIFIED ORGANISM'S PRESENTATION.pptGENETICALLY MODIFIED ORGANISM'S PRESENTATION.ppt
GENETICALLY MODIFIED ORGANISM'S PRESENTATION.ppt
 
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsTransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
 
Method of Quantifying interactions and its types
Method of Quantifying interactions and its typesMethod of Quantifying interactions and its types
Method of Quantifying interactions and its types
 
Terpineol and it's characterization pptx
Terpineol and it's characterization pptxTerpineol and it's characterization pptx
Terpineol and it's characterization pptx
 
Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.
 
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
 

Featured

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)

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

レポート機械学習