cleaned up svm

This commit is contained in:
mhjensen
2019-11-26 23:17:59 +01:00
parent 754e0e684c
commit 2289180c2e
35 changed files with 56 additions and 288 deletions
+3 -5
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -174,7 +172,7 @@ MathJax.Hub.Config({
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
<br>
<p>
<center><h4>Nov 25, 2019</h4></center> <!-- date -->
<center><h4>Nov 26, 2019</h4></center> <!-- date -->
<br>
<p>
@@ -198,7 +196,7 @@ MathJax.Hub.Config({
<li><a href="._svm-bs008.html">9</a></li>
<li><a href="._svm-bs009.html">10</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs001.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -202,7 +200,7 @@ unlikely that we can separate classes easily by say straight lines.
<li><a href="._svm-bs009.html">10</a></li>
<li><a href="._svm-bs010.html">11</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs002.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -257,7 +255,7 @@ plt<span style="color: #666666">.</span>show()
<li><a href="._svm-bs010.html">11</a></li>
<li><a href="._svm-bs011.html">12</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs003.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -202,7 +200,7 @@ $$
<li><a href="._svm-bs011.html">12</a></li>
<li><a href="._svm-bs012.html">13</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs004.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -214,7 +212,7 @@ When we try to separate hyperplanes, if it exists, we can use it to construct a
<li><a href="._svm-bs012.html">13</a></li>
<li><a href="._svm-bs013.html">14</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs005.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -200,7 +198,7 @@ for our data sample.
<li><a href="._svm-bs013.html">14</a></li>
<li><a href="._svm-bs014.html">15</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs006.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -196,7 +194,7 @@ $$
<li><a href="._svm-bs014.html">15</a></li>
<li><a href="._svm-bs015.html">16</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs007.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -200,7 +198,7 @@ $$
<li><a href="._svm-bs015.html">16</a></li>
<li><a href="._svm-bs016.html">17</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs008.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -194,7 +192,7 @@ where \( \eta \) is our by now well-known learning rate.
<li><a href="._svm-bs016.html">17</a></li>
<li><a href="._svm-bs017.html">18</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs009.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -191,7 +189,7 @@ regression). We are going to set up a simple case with two classes only and we w
<li><a href="._svm-bs017.html">18</a></li>
<li><a href="._svm-bs018.html">19</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs010.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -194,7 +192,7 @@ at all.
<li><a href="._svm-bs018.html">19</a></li>
<li><a href="._svm-bs019.html">20</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs011.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -220,7 +218,7 @@ about Lagrangian multipliers.
<li><a href="._svm-bs019.html">20</a></li>
<li><a href="._svm-bs020.html">21</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs012.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -228,7 +226,7 @@ Then \( dz \) is no longer arbitrary.
<li><a href="._svm-bs020.html">21</a></li>
<li><a href="._svm-bs021.html">22</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs013.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -221,7 +219,7 @@ $$
<li><a href="._svm-bs021.html">22</a></li>
<li><a href="._svm-bs022.html">23</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs014.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -219,7 +217,7 @@ When \( \lambda_i > 0 \), the vectors \( \boldsymbol{x}_i \) are called support
<li><a href="._svm-bs022.html">23</a></li>
<li><a href="._svm-bs023.html">24</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs015.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -202,7 +200,7 @@ subject to \( \boldsymbol{y}^T\boldsymbol{\lambda}=0 \). Here we defined the vec
<li><a href="._svm-bs023.html">24</a></li>
<li><a href="._svm-bs024.html">25</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs016.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -212,7 +210,7 @@ Below we discuss how to find the optimal values of \( \lambda_i \). Before we pr
<li><a href="._svm-bs024.html">25</a></li>
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs017.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+2 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -213,7 +211,7 @@ misclassifications.
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs018.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -5
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -231,8 +229,6 @@ $$
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs019.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -249,7 +247,6 @@ plt<span style="color: #666666">.</span>show()
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs020.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -220,7 +218,6 @@ the trouble of performing the transformation
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs021.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -210,7 +208,6 @@ Given a kernel \( K \) and the targets \( y_i \) this matrix is easy to set up.
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs022.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -211,7 +209,6 @@ in practice.
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs023.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -368,7 +366,6 @@ plt<span style="color: #666666">.</span>show()
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs024.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -196,7 +194,6 @@ Convex optimization problems play a central role in applied mathematics and we r
<li><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs025.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -196,7 +194,6 @@ This will make our life much easier. You don't need t write your own optimizer.
<li class="active"><a href="._svm-bs025.html">26</a></li>
<li><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs026.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -4
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -237,7 +235,6 @@ sol[primal objective]
<li><a href="._svm-bs025.html">26</a></li>
<li class="active"><a href="._svm-bs026.html">27</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+3 -5
View File
@@ -73,8 +73,7 @@ Automatically generated HTML file from DocOnce source
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -139,7 +138,6 @@ MathJax.Hub.Config({
<!-- navigation toc: --> <li><a href="._svm-bs025.html#___sec24" style="font-size: 80%;">How do we solve these problems?</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs026.html#___sec25" style="font-size: 80%;">A simple example</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs027.html#___sec26" style="font-size: 80%;">Back to the more realistic cases</a></li>
<!-- navigation toc: --> <li><a href="._svm-bs028.html#___sec27" style="font-size: 80%;">Code Example</a></li>
</ul>
</li>
@@ -174,7 +172,7 @@ MathJax.Hub.Config({
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
<br>
<p>
<center><h4>Nov 25, 2019</h4></center> <!-- date -->
<center><h4>Nov 26, 2019</h4></center> <!-- date -->
<br>
<p>
@@ -198,7 +196,7 @@ MathJax.Hub.Config({
<li><a href="._svm-bs008.html">9</a></li>
<li><a href="._svm-bs009.html">10</a></li>
<li><a href="">...</a></li>
<li><a href="._svm-bs028.html">29</a></li>
<li><a href="._svm-bs027.html">28</a></li>
<li><a href="._svm-bs001.html">&raquo;</a></li>
</ul>
<!-- ------------------- end of main content --------------- -->
+1 -34
View File
@@ -148,7 +148,7 @@ MathJax.Hub.Config({
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
<br>
<p>&nbsp;<br>
<center><h4>Nov 25, 2019</h4></center> <!-- date -->
<center><h4>Nov 26, 2019</h4></center> <!-- date -->
<br>
<p>
@@ -1473,39 +1473,6 @@ With the slack constants this leads to the additional constraint \( 0\leq \lamb
</section>
<section>
<h2 id="___sec27">Code Example </h2>
<p>
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">scipy.optimize</span> <span style="color: #8B008B; font-weight: bold">import</span> minimize
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">rosen</span>(x):
<span style="color: #8B008B; font-weight: bold">return</span> <span style="color: #658b00">sum</span>(<span style="color: #B452CD">100.0</span>*(x[<span style="color: #B452CD">1</span>:]-x[:-<span style="color: #B452CD">1</span>]**<span style="color: #B452CD">2.0</span>)**<span style="color: #B452CD">2.0</span> + (<span style="color: #B452CD">1</span>-x[:-<span style="color: #B452CD">1</span>])**<span style="color: #B452CD">2.0</span>)
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">rosen_der</span>(x):
xm = x[<span style="color: #B452CD">1</span>:-<span style="color: #B452CD">1</span>]
xm_m1 = x[:-<span style="color: #B452CD">2</span>]
xm_p1 = x[<span style="color: #B452CD">2</span>:]
der = np.zeros_like(x)
der[<span style="color: #B452CD">1</span>:-<span style="color: #B452CD">1</span>] = <span style="color: #B452CD">200</span>*(xm-xm_m1**<span style="color: #B452CD">2</span>) - <span style="color: #B452CD">400</span>*(xm_p1 - xm**<span style="color: #B452CD">2</span>)*xm - <span style="color: #B452CD">2</span>*(<span style="color: #B452CD">1</span>-xm)
der[<span style="color: #B452CD">0</span>] = -<span style="color: #B452CD">400</span>*x[<span style="color: #B452CD">0</span>]*(x[<span style="color: #B452CD">1</span>]-x[<span style="color: #B452CD">0</span>]**<span style="color: #B452CD">2</span>) - <span style="color: #B452CD">2</span>*(<span style="color: #B452CD">1</span>-x[<span style="color: #B452CD">0</span>])
der[-<span style="color: #B452CD">1</span>] = <span style="color: #B452CD">200</span>*(x[-<span style="color: #B452CD">1</span>]-x[-<span style="color: #B452CD">2</span>]**<span style="color: #B452CD">2</span>)
<span style="color: #8B008B; font-weight: bold">return</span> der
x0 = np.array([<span style="color: #B452CD">1.2</span>, <span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>, <span style="color: #B452CD">1.9</span>, <span style="color: #B452CD">1.2</span>])
<span style="color: #8B008B; font-weight: bold">print</span>(x0)
res = minimize(rosen, x0, method=<span style="color: #CD5555">&#39;nelder-mead&#39;</span>,options={<span style="color: #CD5555">&#39;xtol&#39;</span>: <span style="color: #B452CD">1e-8</span>, <span style="color: #CD5555">&#39;disp&#39;</span>: <span style="color: #658b00">True</span>})
<span style="color: #8B008B; font-weight: bold">print</span>(x0)
res2 = minimize(rosen, x0, method=<span style="color: #CD5555">&#39;BFGS&#39;</span>, jac=rosen_der, options={<span style="color: #CD5555">&#39;disp&#39;</span>: <span style="color: #658b00">True</span>})
<span style="color: #8B008B; font-weight: bold">print</span>(x0)
</pre></div>
</section>
</div> <!-- class="slides" -->
</div> <!-- class="reveal" -->
+2 -35
View File
@@ -67,8 +67,7 @@ div { text-align: justify; text-justify: inter-word; }
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -110,7 +109,7 @@ MathJax.Hub.Config({
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
<br>
<p>
<center><h4>Nov 25, 2019</h4></center> <!-- date -->
<center><h4>Nov 26, 2019</h4></center> <!-- date -->
<br>
<p>
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
@@ -1280,38 +1279,6 @@ With the slack constants this leads to the additional constraint \( 0\leq \lamb
<p>
<b>code will be added</b>
<p>
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
<h2 id="___sec27">Code Example </h2>
<p>
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">scipy.optimize</span> <span style="color: #8B008B; font-weight: bold">import</span> minimize
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">rosen</span>(x):
<span style="color: #8B008B; font-weight: bold">return</span> <span style="color: #658b00">sum</span>(<span style="color: #B452CD">100.0</span>*(x[<span style="color: #B452CD">1</span>:]-x[:-<span style="color: #B452CD">1</span>]**<span style="color: #B452CD">2.0</span>)**<span style="color: #B452CD">2.0</span> + (<span style="color: #B452CD">1</span>-x[:-<span style="color: #B452CD">1</span>])**<span style="color: #B452CD">2.0</span>)
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">rosen_der</span>(x):
xm = x[<span style="color: #B452CD">1</span>:-<span style="color: #B452CD">1</span>]
xm_m1 = x[:-<span style="color: #B452CD">2</span>]
xm_p1 = x[<span style="color: #B452CD">2</span>:]
der = np.zeros_like(x)
der[<span style="color: #B452CD">1</span>:-<span style="color: #B452CD">1</span>] = <span style="color: #B452CD">200</span>*(xm-xm_m1**<span style="color: #B452CD">2</span>) - <span style="color: #B452CD">400</span>*(xm_p1 - xm**<span style="color: #B452CD">2</span>)*xm - <span style="color: #B452CD">2</span>*(<span style="color: #B452CD">1</span>-xm)
der[<span style="color: #B452CD">0</span>] = -<span style="color: #B452CD">400</span>*x[<span style="color: #B452CD">0</span>]*(x[<span style="color: #B452CD">1</span>]-x[<span style="color: #B452CD">0</span>]**<span style="color: #B452CD">2</span>) - <span style="color: #B452CD">2</span>*(<span style="color: #B452CD">1</span>-x[<span style="color: #B452CD">0</span>])
der[-<span style="color: #B452CD">1</span>] = <span style="color: #B452CD">200</span>*(x[-<span style="color: #B452CD">1</span>]-x[-<span style="color: #B452CD">2</span>]**<span style="color: #B452CD">2</span>)
<span style="color: #8B008B; font-weight: bold">return</span> der
x0 = np.array([<span style="color: #B452CD">1.2</span>, <span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>, <span style="color: #B452CD">1.9</span>, <span style="color: #B452CD">1.2</span>])
<span style="color: #8B008B; font-weight: bold">print</span>(x0)
res = minimize(rosen, x0, method=<span style="color: #CD5555">&#39;nelder-mead&#39;</span>,options={<span style="color: #CD5555">&#39;xtol&#39;</span>: <span style="color: #B452CD">1e-8</span>, <span style="color: #CD5555">&#39;disp&#39;</span>: <span style="color: #658b00">True</span>})
<span style="color: #8B008B; font-weight: bold">print</span>(x0)
res2 = minimize(rosen, x0, method=<span style="color: #CD5555">&#39;BFGS&#39;</span>, jac=rosen_der, options={<span style="color: #CD5555">&#39;disp&#39;</span>: <span style="color: #658b00">True</span>})
<span style="color: #8B008B; font-weight: bold">print</span>(x0)
</pre></div>
<p>
<!-- ------------------- end of main content --------------- -->
+2 -35
View File
@@ -72,8 +72,7 @@ div { text-align: justify; text-justify: inter-word; }
'___sec23'),
('How do we solve these problems?', 2, None, '___sec24'),
('A simple example', 2, None, '___sec25'),
('Back to the more realistic cases', 2, None, '___sec26'),
('Code Example', 2, None, '___sec27')]}
('Back to the more realistic cases', 2, None, '___sec26')]}
end of tocinfo -->
<body>
@@ -115,7 +114,7 @@ MathJax.Hub.Config({
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
<br>
<p>
<center><h4>Nov 25, 2019</h4></center> <!-- date -->
<center><h4>Nov 26, 2019</h4></center> <!-- date -->
<br>
<p>
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
@@ -1285,38 +1284,6 @@ With the slack constants this leads to the additional constraint \( 0\leq \lamb
<p>
<b>code will be added</b>
<p>
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
<h2 id="___sec27">Code Example </h2>
<p>
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">scipy.optimize</span> <span style="color: #008000; font-weight: bold">import</span> minimize
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">rosen</span>(x):
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">sum</span>(<span style="color: #666666">100.0*</span>(x[<span style="color: #666666">1</span>:]<span style="color: #666666">-</span>x[:<span style="color: #666666">-1</span>]<span style="color: #666666">**2.0</span>)<span style="color: #666666">**2.0</span> <span style="color: #666666">+</span> (<span style="color: #666666">1-</span>x[:<span style="color: #666666">-1</span>])<span style="color: #666666">**2.0</span>)
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">rosen_der</span>(x):
xm <span style="color: #666666">=</span> x[<span style="color: #666666">1</span>:<span style="color: #666666">-1</span>]
xm_m1 <span style="color: #666666">=</span> x[:<span style="color: #666666">-2</span>]
xm_p1 <span style="color: #666666">=</span> x[<span style="color: #666666">2</span>:]
der <span style="color: #666666">=</span> np<span style="color: #666666">.</span>zeros_like(x)
der[<span style="color: #666666">1</span>:<span style="color: #666666">-1</span>] <span style="color: #666666">=</span> <span style="color: #666666">200*</span>(xm<span style="color: #666666">-</span>xm_m1<span style="color: #666666">**2</span>) <span style="color: #666666">-</span> <span style="color: #666666">400*</span>(xm_p1 <span style="color: #666666">-</span> xm<span style="color: #666666">**2</span>)<span style="color: #666666">*</span>xm <span style="color: #666666">-</span> <span style="color: #666666">2*</span>(<span style="color: #666666">1-</span>xm)
der[<span style="color: #666666">0</span>] <span style="color: #666666">=</span> <span style="color: #666666">-400*</span>x[<span style="color: #666666">0</span>]<span style="color: #666666">*</span>(x[<span style="color: #666666">1</span>]<span style="color: #666666">-</span>x[<span style="color: #666666">0</span>]<span style="color: #666666">**2</span>) <span style="color: #666666">-</span> <span style="color: #666666">2*</span>(<span style="color: #666666">1-</span>x[<span style="color: #666666">0</span>])
der[<span style="color: #666666">-1</span>] <span style="color: #666666">=</span> <span style="color: #666666">200*</span>(x[<span style="color: #666666">-1</span>]<span style="color: #666666">-</span>x[<span style="color: #666666">-2</span>]<span style="color: #666666">**2</span>)
<span style="color: #008000; font-weight: bold">return</span> der
x0 <span style="color: #666666">=</span> np<span style="color: #666666">.</span>array([<span style="color: #666666">1.2</span>, <span style="color: #666666">0.1</span>, <span style="color: #666666">0.8</span>, <span style="color: #666666">1.9</span>, <span style="color: #666666">1.2</span>])
<span style="color: #008000; font-weight: bold">print</span>(x0)
res <span style="color: #666666">=</span> minimize(rosen, x0, method<span style="color: #666666">=</span><span style="color: #BA2121">&#39;nelder-mead&#39;</span>,options<span style="color: #666666">=</span>{<span style="color: #BA2121">&#39;xtol&#39;</span>: <span style="color: #666666">1e-8</span>, <span style="color: #BA2121">&#39;disp&#39;</span>: <span style="color: #008000">True</span>})
<span style="color: #008000; font-weight: bold">print</span>(x0)
res2 <span style="color: #666666">=</span> minimize(rosen, x0, method<span style="color: #666666">=</span><span style="color: #BA2121">&#39;BFGS&#39;</span>, jac<span style="color: #666666">=</span>rosen_der, options<span style="color: #666666">=</span>{<span style="color: #BA2121">&#39;disp&#39;</span>: <span style="color: #008000">True</span>})
<span style="color: #008000; font-weight: bold">print</span>(x0)
</pre></div>
<p>
<!-- ------------------- end of main content --------------- -->
Binary file not shown.
+2 -39
View File
@@ -10,7 +10,7 @@
"<!-- Author: --> \n",
"**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n",
"\n",
"Date: **Nov 25, 2019**\n",
"Date: **Nov 26, 2019**\n",
"\n",
"Copyright 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n",
"\n",
@@ -1884,44 +1884,7 @@
"$\\boldsymbol{y}=[y_1,y_2,\\dots,y_n]$. \n",
"With the slack constants this leads to the additional constraint $0\\leq \\lambda_i \\leq C$.\n",
"\n",
"**code will be added**\n",
"\n",
"\n",
"## Code Example"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"from scipy.optimize import minimize\n",
"def rosen(x):\n",
" return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0)\n",
"def rosen_der(x):\n",
" xm = x[1:-1]\n",
" xm_m1 = x[:-2]\n",
" xm_p1 = x[2:]\n",
" der = np.zeros_like(x)\n",
" der[1:-1] = 200*(xm-xm_m1**2) - 400*(xm_p1 - xm**2)*xm - 2*(1-xm)\n",
" der[0] = -400*x[0]*(x[1]-x[0]**2) - 2*(1-x[0])\n",
" der[-1] = 200*(x[-1]-x[-2]**2)\n",
" return der\n",
"\n",
"\n",
"\n",
"x0 = np.array([1.2, 0.1, 0.8, 1.9, 1.2])\n",
"print(x0)\n",
"res = minimize(rosen, x0, method='nelder-mead',options={'xtol': 1e-8, 'disp': True})\n",
"print(x0)\n",
"\n",
"\n",
"res2 = minimize(rosen, x0, method='BFGS', jac=rosen_der, options={'disp': True})\n",
"print(x0)"
"**code will be added**"
]
}
],
Binary file not shown.
-30
View File
@@ -1141,33 +1141,3 @@ With the slack constants this leads to the additional constraint $0\leq \lambda
_code will be added_
!split
===== Code Example =====
!bc pycod
import numpy as np
from scipy.optimize import minimize
def rosen(x):
return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0)
def rosen_der(x):
xm = x[1:-1]
xm_m1 = x[:-2]
xm_p1 = x[2:]
der = np.zeros_like(x)
der[1:-1] = 200*(xm-xm_m1**2) - 400*(xm_p1 - xm**2)*xm - 2*(1-xm)
der[0] = -400*x[0]*(x[1]-x[0]**2) - 2*(1-x[0])
der[-1] = 200*(x[-1]-x[-2]**2)
return der
x0 = np.array([1.2, 0.1, 0.8, 1.9, 1.2])
print(x0)
res = minimize(rosen, x0, method='nelder-mead',options={'xtol': 1e-8, 'disp': True})
print(x0)
res2 = minimize(rosen, x0, method='BFGS', jac=rosen_der, options={'disp': True})
print(x0)
!ec