update week 46
This commit is contained in:
@@ -37,6 +37,14 @@ doconce format html week46.do.txt --html_style=bootstrap --pygments_html_style=d
|
||||
<!-- tocinfo
|
||||
{'highest level': 2,
|
||||
'sections': [('Overview of week 46', 2, None, 'overview-of-week-46'),
|
||||
('Eventual mini-workshop on project 3, Friday November 18',
|
||||
2,
|
||||
None,
|
||||
'eventual-mini-workshop-on-project-3-friday-november-18'),
|
||||
('Workshop topics 2021 (partly online)',
|
||||
2,
|
||||
None,
|
||||
'workshop-topics-2021-partly-online'),
|
||||
('Support Vector Machines, overarching aims',
|
||||
2,
|
||||
None,
|
||||
@@ -129,33 +137,35 @@ MathJax.Hub.Config({
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contents <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs001.html#overview-of-week-46" style="font-size: 80%;">Overview of week 46</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs002.html#support-vector-machines-overarching-aims" style="font-size: 80%;">Support Vector Machines, overarching aims</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs003.html#hyperplanes-and-all-that" style="font-size: 80%;">Hyperplanes and all that</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs004.html#what-is-a-hyperplane" style="font-size: 80%;">What is a hyperplane?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs005.html#a-p-dimensional-space-of-features" style="font-size: 80%;">A \( p \)-dimensional space of features</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs006.html#the-two-dimensional-case" style="font-size: 80%;">The two-dimensional case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs007.html#getting-into-the-details" style="font-size: 80%;">Getting into the details</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs008.html#first-attempt-at-a-minimization-approach" style="font-size: 80%;">First attempt at a minimization approach</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs009.html#solving-the-equations" style="font-size: 80%;">Solving the equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs010.html#code-example" style="font-size: 80%;">Code Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs011.html#problems-with-the-simpler-approach" style="font-size: 80%;">Problems with the Simpler Approach</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs012.html#a-better-approach" style="font-size: 80%;">A better approach</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs013.html#a-quick-reminder-on-lagrangian-multipliers" style="font-size: 80%;">A quick Reminder on Lagrangian Multipliers</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs014.html#adding-the-multiplier" style="font-size: 80%;">Adding the Multiplier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs015.html#setting-up-the-problem" style="font-size: 80%;">Setting up the Problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs022.html#the-problem-to-solve" style="font-size: 80%;">The problem to solve</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs017.html#the-last-steps" style="font-size: 80%;">The last steps</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs018.html#a-soft-classifier" style="font-size: 80%;">A soft classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#soft-optmization-problem" style="font-size: 80%;">Soft optmization problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs020.html#kernels-and-non-linearity" style="font-size: 80%;">Kernels and non-linearity</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs021.html#the-equations" style="font-size: 80%;">The equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs022.html#the-problem-to-solve" style="font-size: 80%;">The problem to solve</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs023.html#different-kernels-and-mercer-s-theorem" style="font-size: 80%;">Different kernels and Mercer's theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs024.html#the-moons-example" style="font-size: 80%;">The moons example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs025.html#mathematical-optimization-of-convex-functions" style="font-size: 80%;">Mathematical optimization of convex functions</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs026.html#how-do-we-solve-these-problems" style="font-size: 80%;">How do we solve these problems?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs027.html#a-simple-example" style="font-size: 80%;">A simple example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs028.html#back-to-the-more-realistic-cases" style="font-size: 80%;">Back to the more realistic cases</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs002.html#eventual-mini-workshop-on-project-3-friday-november-18" style="font-size: 80%;">Eventual mini-workshop on project 3, Friday November 18</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs003.html#workshop-topics-2021-partly-online" style="font-size: 80%;">Workshop topics 2021 (partly online)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs004.html#support-vector-machines-overarching-aims" style="font-size: 80%;">Support Vector Machines, overarching aims</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs005.html#hyperplanes-and-all-that" style="font-size: 80%;">Hyperplanes and all that</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs006.html#what-is-a-hyperplane" style="font-size: 80%;">What is a hyperplane?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs007.html#a-p-dimensional-space-of-features" style="font-size: 80%;">A \( p \)-dimensional space of features</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs008.html#the-two-dimensional-case" style="font-size: 80%;">The two-dimensional case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs009.html#getting-into-the-details" style="font-size: 80%;">Getting into the details</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs010.html#first-attempt-at-a-minimization-approach" style="font-size: 80%;">First attempt at a minimization approach</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs011.html#solving-the-equations" style="font-size: 80%;">Solving the equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs012.html#code-example" style="font-size: 80%;">Code Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs013.html#problems-with-the-simpler-approach" style="font-size: 80%;">Problems with the Simpler Approach</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs014.html#a-better-approach" style="font-size: 80%;">A better approach</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs015.html#a-quick-reminder-on-lagrangian-multipliers" style="font-size: 80%;">A quick Reminder on Lagrangian Multipliers</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs016.html#adding-the-multiplier" style="font-size: 80%;">Adding the Multiplier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs017.html#setting-up-the-problem" style="font-size: 80%;">Setting up the Problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs024.html#the-problem-to-solve" style="font-size: 80%;">The problem to solve</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#the-last-steps" style="font-size: 80%;">The last steps</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs020.html#a-soft-classifier" style="font-size: 80%;">A soft classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs021.html#soft-optmization-problem" style="font-size: 80%;">Soft optmization problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs022.html#kernels-and-non-linearity" style="font-size: 80%;">Kernels and non-linearity</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs023.html#the-equations" style="font-size: 80%;">The equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs024.html#the-problem-to-solve" style="font-size: 80%;">The problem to solve</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs025.html#different-kernels-and-mercer-s-theorem" style="font-size: 80%;">Different kernels and Mercer's theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs026.html#the-moons-example" style="font-size: 80%;">The moons example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs027.html#mathematical-optimization-of-convex-functions" style="font-size: 80%;">Mathematical optimization of convex functions</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs028.html#how-do-we-solve-these-problems" style="font-size: 80%;">How do we solve these problems?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs029.html#a-simple-example" style="font-size: 80%;">A simple example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week46-bs030.html#back-to-the-more-realistic-cases" style="font-size: 80%;">Back to the more realistic cases</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -167,56 +177,36 @@ MathJax.Hub.Config({
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
<a name="part0019"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="soft-optmization-problem" class="anchor">Soft optmization problem </h2>
|
||||
<h2 id="the-last-steps" class="anchor">The last steps </h2>
|
||||
|
||||
<p>This has in turn the consequences that we change our optmization problem to finding the minimum of </p>
|
||||
$$
|
||||
{\cal L}=\frac{1}{2}\boldsymbol{w}^T\boldsymbol{w}-\sum_{i=1}^n\lambda_i\left[y_i(\boldsymbol{w}^T\boldsymbol{x}_i+b)-(1-\xi_)\right]+C\sum_{i=1}^n\xi_i-\sum_{i=1}^n\gamma_i\xi_i,
|
||||
$$
|
||||
|
||||
<p>subject to </p>
|
||||
$$
|
||||
y_i(\boldsymbol{w}^T\boldsymbol{x}_i+b)=1-\xi_i \hspace{0.1cm}\forall i,
|
||||
$$
|
||||
|
||||
<p>with the requirement \( \xi_i\geq 0 \).</p>
|
||||
|
||||
<p>Taking the derivatives with respect to \( b \) and \( \boldsymbol{w} \) we obtain </p>
|
||||
$$
|
||||
\frac{\partial {\cal L}}{\partial b} = -\sum_{i} \lambda_iy_i=0,
|
||||
$$
|
||||
|
||||
<p>and </p>
|
||||
$$
|
||||
\frac{\partial {\cal L}}{\partial \boldsymbol{w}} = 0 = \boldsymbol{w}-\sum_{i} \lambda_iy_i\boldsymbol{x}_i,
|
||||
$$
|
||||
|
||||
<p>and</p>
|
||||
$$
|
||||
\lambda_i = C-\gamma_i \hspace{0.1cm}\forall i.
|
||||
$$
|
||||
|
||||
<p>Inserting these constraints into the equation for \( {\cal L} \) we obtain the same equation as before</p>
|
||||
$$
|
||||
{\cal L}=\sum_i\lambda_i-\frac{1}{2}\sum_{ij}^n\lambda_i\lambda_jy_iy_j\boldsymbol{x}_i^T\boldsymbol{x}_j,
|
||||
$$
|
||||
|
||||
<p>but now subject to the constraints \( \lambda_i\geq 0 \), \( \sum_i\lambda_iy_i=0 \) and \( 0\leq\lambda_i \leq C \).
|
||||
We must in addition satisfy the Karush-Kuhn-Tucker condition which now reads
|
||||
<p>Solving the above problem, yields the values of \( \lambda_i \).
|
||||
To find the coefficients of your hyperplane we need simply to compute
|
||||
</p>
|
||||
$$
|
||||
\lambda_i\left[y_i(\boldsymbol{w}^T\boldsymbol{x}_i+b) -(1-\xi_)\right]=0 \hspace{0.1cm}\forall i,
|
||||
\boldsymbol{w}=\sum_{i} \lambda_iy_i\boldsymbol{x}_i.
|
||||
$$
|
||||
|
||||
<p>With our vector \( \boldsymbol{w} \) we can in turn find the value of the intercept \( b \) (here in two dimensions) via </p>
|
||||
$$
|
||||
\gamma_i\xi_i = 0,
|
||||
y_i(\boldsymbol{w}^T\boldsymbol{x}_i+b)=1,
|
||||
$$
|
||||
|
||||
<p>and </p>
|
||||
<p>resulting in</p>
|
||||
$$
|
||||
y_i(\boldsymbol{w}^T\boldsymbol{x}_i+b) -(1-\xi_) \geq 0 \hspace{0.1cm}\forall i.
|
||||
b = \frac{1}{y_i}-\boldsymbol{w}^T\boldsymbol{x}_i,
|
||||
$$
|
||||
|
||||
<p>or if we write it out in terms of the support vectors only, with \( N_s \) being their number, we have</p>
|
||||
$$
|
||||
b = \frac{1}{N_s}\sum_{j\in N_s}\left(y_j-\sum_{i=1}^n\lambda_iy_i\boldsymbol{x}_i^T\boldsymbol{x}_j\right).
|
||||
$$
|
||||
|
||||
<p>With our hyperplane coefficients we can use our classifier to assign any observation by simply using </p>
|
||||
$$
|
||||
y_i = \mathrm{sign}(\boldsymbol{w}^T\boldsymbol{x}_i+b).
|
||||
$$
|
||||
|
||||
<p>Below we discuss how to find the optimal values of \( \lambda_i \). Before we proceed however, we discuss now the so-called soft classifier. </p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
@@ -242,6 +232,8 @@ $$
|
||||
<li><a href="._week46-bs026.html">27</a></li>
|
||||
<li><a href="._week46-bs027.html">28</a></li>
|
||||
<li><a href="._week46-bs028.html">29</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week46-bs030.html">31</a></li>
|
||||
<li><a href="._week46-bs020.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
Reference in New Issue
Block a user