SlideShare a Scribd company logo
1 of 6
機械学習1
線形回帰モデル
・線形に回帰させる機械学習モデル
・教師あり学習である
・入力とn次元パラメータの線形結合を出力するモデル
言い換えると「n次元の入力パラメータの一次式に回帰させる」モデル
・線形結合
𝑦 = 𝑤⊤
𝑥 + 𝑤0 = 𝑗=1
𝑚
𝑤𝑗𝑥𝑗 + 𝑤0
𝑤 = 𝑤1, 𝑤2, … , wm
⊤
∊ ℝ𝑚
・モデル
誤差項を含む線形結合で表現、複数の入力データ
𝑦𝑛 = 𝑤0 + 𝑤1𝑥𝑛1 + 𝑤2𝑥𝑛2 + ⋯ + 𝑤𝑛𝑥𝑛𝑚 + ε𝑛
行列表現は以下のとおり
𝑦 = 𝑋𝑤 + ε
・学習の目的
入力データに近くなる𝑤を求める
・求め方
最小二乗法により、データとモデル出力(回帰直線)の
平均二乗誤差(MSE:MeanSquaredError)を最小とする𝑤を求める
(平均二乗誤差の微分=0となる𝑤を求める)
回帰係数
𝑤 = 𝑋 𝑡𝑟𝑎𝑖𝑛 ⊤
𝑋 𝑡𝑟𝑎𝑖𝑛 −1
𝑋 𝑡𝑟𝑎𝑖𝑛 ⊤
𝑦(𝑡𝑟𝑎𝑖𝑛)
予測値
𝑦 = 𝑋 𝑋 𝑡𝑟𝑎𝑖𝑛 ⊤
𝑋 𝑡𝑟𝑎𝑖𝑛 −1
𝑋 𝑡𝑟𝑎𝑖𝑛 ⊤
𝑦(𝑡𝑟𝑎𝑖𝑛)
ボストンの住宅データセットを元に単回帰、重回帰を実施
(実装演習課題を参考にまとめた)
機械学習2
非線形回帰モデル
・非線形に回帰させる機械学習モデル
・教師あり学習である
・基底関数(非線形関数)とパラメータベクトルの線形結合
・求め方は最小二乗法や最尤法により推定
・基底関数
・多項式
・ガウス関数
・スプライン関数
・モデル
基底関数をφと記述したとき、線形回帰と同じように記述できる
𝑦𝑛 = 𝑤0 + 𝑤1𝜑𝑛1 + 𝑤2𝜑𝑛2 + ⋯ + 𝑤𝑛𝜑𝑛𝑚 + ε𝑛
・基底関数を複数から選択できる、パラメータの数が多い、といった
ことから未学習、過学習となることがあり、適切な表現力のモデルと
するために工夫が必要となる。
・不要な基底関数の削除
・正則化法
・交差検証法
学習データ 線形回帰による結果
カーネルリッジ回帰による結果
対応コード「skl_nonlinear regression.ipynb」であるが、
カーネルリッジ回帰
放射基底関数カーネル(Radial basis function kernel)を
使用したものと思われる。
𝑘 𝑥, 𝑦 = exp(−𝛾 𝑥 − 𝑦
2
)
Γ=50のRidge推定
機械学習3
ロジスティック回帰モデル
・分類問題に対応する機械学習モデル
・教師あり機械学習
・分類内容は「ある事象に該当するか否か」である。
・出力は出力1となるか否かの確率である
・モデル
𝑃 𝑌 = 1 𝑥 = σ 𝑤0 + 𝑤1𝑥1 + ⋯ + 𝑤𝑚𝑥𝑚
σはシグモイド関数
σ 𝑥 =
1
1+exp −𝑎𝑥
・シグモイド関数の性質
・0付近を境界に曲線の勾配が増加、値が0→1に変化
・aを大きくすると、ステップ関数に近づく
・微分を自分自身で表現可能
𝜕σ(𝑥)
𝜕𝑥
=
𝜕
𝜕𝑥
1
1 + exp −𝑎𝑥
= 𝑎σ(𝑥)(1 − σ 𝑥 )
・尤度関数(もっともらしさ)
𝑦1, 𝑦2, … , 𝑦𝑛 𝑤0, 𝑤1, … , 𝑤𝑚 =
𝑖=1
𝑛
𝑝𝑖
𝑦𝑖
1 − 𝑝𝑖
1−𝑦𝑖 = 𝐿(𝑤)
𝐸 𝑤0, 𝑤1, … , 𝑤𝑚 = −log𝐿 𝑤0, 𝑤1, … , 𝑤𝑚
= −
𝑖=1
𝑛
{𝑦𝑖log𝑝𝑖 + 1 − 𝑦𝑖 log 1 − 𝑝𝑖 }
最尤推定…尤度関数を最大化するようなパラメータを選ぶ推定方法
・勾配降下法
解析的にパラメータ導出が困難なので、反復学習により
パラメータを逐次的に更新する
・確率的勾配降下法
計算量が膨大になる場合の効率化手法
データをランダムに選んでパラメータを更新する
実装演習結果
シグモイド関数で運賃と生存率(生存=1)を予測
機械学習4
主成分分析
実装演習
乳がん検査データを利用し、次元圧縮後のロジスティック
回帰モデルを評価する。
・他変量データの少ない変量データに圧縮する
・2次、3次元の場合は可視化が実現可能
・線形変換後の変数の分散が最大となる射影軸を探索する
・線形変換後の分散
𝑉𝑎𝑟 𝑠𝑗 = 𝑎𝑗
⊤
𝑉𝑎𝑟 𝑋 𝑎𝑗
・最適化問題の解法
制約条件として、𝑎𝑗
⊤
𝑎𝑗 = 1とする
ラグランジュの未定乗数法を利用して
𝐸 𝑎𝑗 = 𝑎𝑗
⊤
𝑉𝑎𝑟 𝑋 𝑎𝑗 − λ(𝑎𝑗
⊤
𝑎𝑗 − 1)
𝜕σ(𝑥)
𝜕𝑥
= 2𝑉𝑎𝑟 𝑋 𝑎𝑗 − 2λ𝑎𝑗 = 0
𝑉𝑎𝑟 𝑋 𝑎𝑗 = λ𝑎𝑗
→共分散行列の固有値と固有ベクトルが解となる
・寄与率
第𝑘主成分の分散の全文さんに対する割合
𝑘が小さい時点で累積寄与率が十分高ければ、次元の圧縮に成功
そのまま実行すると
イテレーション回数の上限に抵触
引数にて適当に大きな数を指定する
97%で分類可能
累積寄与率63%
機械学習5
アルゴリズム
・k近傍法(kNN)
・分類問題のための機械学習アルゴリズム
・教師あり学習
・分類内容は「あるデータがどのクラスに識別されるか」である
・最近傍のデータk個を取り、最頻値(クラス)を出力する
・性格上、kは奇数
・kが大きくなると、決定境界はなめらかになる傾向
・k平均法(k-means)
・データをk個のクラスタに分類するクラスタリング手法
・教師なし学習
・アルゴリズムは以下のとおり
①クラスタ中心の初期値を設定する(適当に決める)
②各データに対し、中心が最も近いクラスタを割り当てる
③②で分類したクラスタの中心を計算し、クラスタ中心を更新する
④収束するまで②、③を繰り返す
・中心の初期値が近いとうまくクラスタリングできない
k近傍法実装演習「np_knn.ipynb」
近傍数が増えるほど、境界面は、なだらかになる
k=3 k=5 k=9
k平均法「np_kmeans.ipynb」
演算方法は同じであるがランダムに設定したクラスタ中心の初期値が
近い場合はクラスタリングに失敗する
機械学習6
サポートベクターマシーン
・2クラス分類のための機械学習手法
・線形モデルの「正負」で2値分類
・訓練サンプルから、各データ点との距離(マージン)が
最大となる線形判別関数を求める
<用語の整理>
境界線(超平面)… クラスを分ける線
マージン … 線形判別関数と最も近いデータ点との距離
サポートベクトル… 境界近傍に位置する点
→SVMはサポートベクトルの距離が最大になるように
境界線(超平面)を設定している。
→超平面の学習にサポートベクトル以外のデータは不要
(学習に影響しない)
・ソフトマージンSVM
サンプルを線形分離できない場合は誤差(データがマージン内に入る)
を許容する考え方。ただし、誤差が過大にならないよう、
誤差に対してペナルティを与える
・カーネルトリック
非線形な関係を変換し、線形変換に落とし込むことで計算を容易にする
・多項式カーネル
・ガウシアンカーネル
・SVM(ハードマージン)
容易に分類できる場合
・ソフトマージンSVM
マージン内の誤差を許す場合

More Related Content

What's hot

Generate and test random numbers
Generate and test random numbersGenerate and test random numbers
Generate and test random numbers
Mshari Alabdulkarim
 
February 24, 2015
February 24, 2015February 24, 2015
February 24, 2015
khyps13
 

What's hot (13)

Богдан Павлишенко (Bohdan Pavlyshenko) - "Linear, Machine Learning and Probab...
Богдан Павлишенко (Bohdan Pavlyshenko) - "Linear, Machine Learning and Probab...Богдан Павлишенко (Bohdan Pavlyshenko) - "Linear, Machine Learning and Probab...
Богдан Павлишенко (Bohdan Pavlyshenko) - "Linear, Machine Learning and Probab...
 
Lar calc10 ch05_sec5
Lar calc10 ch05_sec5Lar calc10 ch05_sec5
Lar calc10 ch05_sec5
 
Roots of equations
Roots of equations Roots of equations
Roots of equations
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
 
Matlab lecture 5 bisection method@taj
Matlab lecture 5  bisection method@tajMatlab lecture 5  bisection method@taj
Matlab lecture 5 bisection method@taj
 
Linear Regression (Machine Learning)
Linear Regression (Machine Learning)Linear Regression (Machine Learning)
Linear Regression (Machine Learning)
 
Generate and test random numbers
Generate and test random numbersGenerate and test random numbers
Generate and test random numbers
 
Linear regression
Linear regression Linear regression
Linear regression
 
February 24, 2015
February 24, 2015February 24, 2015
February 24, 2015
 
Machine Learning - Simple Linear Regression
Machine Learning - Simple Linear RegressionMachine Learning - Simple Linear Regression
Machine Learning - Simple Linear Regression
 
Use Of Calculus In Programming
Use Of Calculus In ProgrammingUse Of Calculus In Programming
Use Of Calculus In Programming
 
Function in Mathematics
Function in MathematicsFunction in Mathematics
Function in Mathematics
 

Similar to 2

Linear Regression
Linear RegressionLinear Regression
Linear Regression
Abdullah al Mamun
 
Simple lin regress_inference
Simple lin regress_inferenceSimple lin regress_inference
Simple lin regress_inference
Kemal İnciroğlu
 

Similar to 2 (20)

Curve Fitting
Curve FittingCurve Fitting
Curve Fitting
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
 
Computational Intelligence Assisted Engineering Design Optimization (using MA...
Computational Intelligence Assisted Engineering Design Optimization (using MA...Computational Intelligence Assisted Engineering Design Optimization (using MA...
Computational Intelligence Assisted Engineering Design Optimization (using MA...
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
 
Curvefitting
CurvefittingCurvefitting
Curvefitting
 
Machine learning session4(linear regression)
Machine learning   session4(linear regression)Machine learning   session4(linear regression)
Machine learning session4(linear regression)
 
Machine learning
Machine learningMachine learning
Machine learning
 
MIXTURES OF TRAINED REGRESSION CURVESMODELS FOR HANDRITTEN ARABIC CHARACTER R...
MIXTURES OF TRAINED REGRESSION CURVESMODELS FOR HANDRITTEN ARABIC CHARACTER R...MIXTURES OF TRAINED REGRESSION CURVESMODELS FOR HANDRITTEN ARABIC CHARACTER R...
MIXTURES OF TRAINED REGRESSION CURVESMODELS FOR HANDRITTEN ARABIC CHARACTER R...
 
I need some help implementing this in java using net beans. can anyone help ...
I need some help implementing this in java using net beans. can anyone help  ...I need some help implementing this in java using net beans. can anyone help  ...
I need some help implementing this in java using net beans. can anyone help ...
 
Mathematical modeling
Mathematical modelingMathematical modeling
Mathematical modeling
 
A comparison of three learning methods to predict N20 fluxes and N leaching
A comparison of three learning methods to predict N20 fluxes and N leachingA comparison of three learning methods to predict N20 fluxes and N leaching
A comparison of three learning methods to predict N20 fluxes and N leaching
 
Simple lin regress_inference
Simple lin regress_inferenceSimple lin regress_inference
Simple lin regress_inference
 
Conditional mixture model for modeling attributed dyadic data
Conditional mixture model for modeling attributed dyadic dataConditional mixture model for modeling attributed dyadic data
Conditional mixture model for modeling attributed dyadic data
 
ラビットチャレンジ 機械学習レポート
ラビットチャレンジ 機械学習レポートラビットチャレンジ 機械学習レポート
ラビットチャレンジ 機械学習レポート
 
Dmitrii Tihonkih - The Iterative Closest Points Algorithm and Affine Transfo...
Dmitrii Tihonkih - The Iterative Closest Points Algorithm and  Affine Transfo...Dmitrii Tihonkih - The Iterative Closest Points Algorithm and  Affine Transfo...
Dmitrii Tihonkih - The Iterative Closest Points Algorithm and Affine Transfo...
 
EPE821_Lecture3.pptx
EPE821_Lecture3.pptxEPE821_Lecture3.pptx
EPE821_Lecture3.pptx
 
Deep Learning: Introduction & Chapter 5 Machine Learning Basics
Deep Learning: Introduction & Chapter 5 Machine Learning BasicsDeep Learning: Introduction & Chapter 5 Machine Learning Basics
Deep Learning: Introduction & Chapter 5 Machine Learning Basics
 
Unit III_Ch 17_Probablistic Methods.pptx
Unit III_Ch 17_Probablistic Methods.pptxUnit III_Ch 17_Probablistic Methods.pptx
Unit III_Ch 17_Probablistic Methods.pptx
 
Understanding Blackbox Prediction via Influence Functions
Understanding Blackbox Prediction via Influence FunctionsUnderstanding Blackbox Prediction via Influence Functions
Understanding Blackbox Prediction via Influence Functions
 
The Magic of Auto Differentiation
The Magic of Auto DifferentiationThe Magic of Auto Differentiation
The Magic of Auto Differentiation
 

Recently uploaded

Recently uploaded (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

2