This commit is contained in:
Morten Hjorth-Jensen
2021-09-12 21:41:47 +02:00
parent 61f5aed38a
commit c11ddddf61
7 changed files with 61 additions and 53 deletions
+10 -9
View File
@@ -397,15 +397,7 @@ python file.
<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">from</span> <span style="color: #0000FF; font-weight: bold">l1regls</span> <span style="color: #008000; font-weight: bold">import</span> l1regls
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> matrix, normal
<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>
X <span style="color: #666666">=</span> matrix( [ [ <span style="color: #666666">2</span>, <span style="color: #666666">0</span>, <span style="color: #666666">1</span>], [<span style="color: #666666">0</span>, <span style="color: #666666">1</span>, <span style="color: #666666">3</span>]])
y <span style="color: #666666">=</span> matrix( [<span style="color: #666666">4</span>, <span style="color: #666666">2</span>, <span style="color: #666666">3</span>])
x <span style="color: #666666">=</span> l1regls(X,y)
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> matrix, spdiag, mul, div, sqrt, normal, setseed
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> matrix, spdiag, mul, div, sqrt, normal, setseed
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> blas, lapack, solvers, sparse, spmatrix
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">math</span>
@@ -662,6 +654,15 @@ x <span style="color: #666666">=</span> l1regls(X,y)
<span style="color: #008000; font-weight: bold">return</span> g
<span style="color: #008000; font-weight: bold">return</span> solvers<span style="color: #666666">.</span>coneqp(P, q, G, h, kktsolver <span style="color: #666666">=</span> Fkkt)[<span style="color: #BA2121">&#39;x&#39;</span>][:n]
<span style="color: #408080; font-style: italic">#from l1regls import l1regls</span>
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> matrix, normal
X <span style="color: #666666">=</span> matrix( [ [ <span style="color: #666666">2</span>, <span style="color: #666666">0</span>, <span style="color: #666666">1</span>], [<span style="color: #666666">0</span>, <span style="color: #666666">1</span>, <span style="color: #666666">3</span>]])
y <span style="color: #666666">=</span> matrix( [<span style="color: #666666">4</span>, <span style="color: #666666">2</span>, <span style="color: #666666">3</span>])
x <span style="color: #666666">=</span> l1regls(X,y)
</pre></div>
<p>
<p>
+10 -9
View File
@@ -1203,15 +1203,7 @@ python file.
<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">from</span> <span style="color: #008b45; text-decoration: underline">l1regls</span> <span style="color: #8B008B; font-weight: bold">import</span> l1regls
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> matrix, normal
<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>
X = matrix( [ [ <span style="color: #B452CD">2</span>, <span style="color: #B452CD">0</span>, <span style="color: #B452CD">1</span>], [<span style="color: #B452CD">0</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">3</span>]])
y = matrix( [<span style="color: #B452CD">4</span>, <span style="color: #B452CD">2</span>, <span style="color: #B452CD">3</span>])
x = l1regls(X,y)
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> matrix, spdiag, mul, div, sqrt, normal, setseed
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%;"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> matrix, spdiag, mul, div, sqrt, normal, setseed
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> blas, lapack, solvers, sparse, spmatrix
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">math</span>
@@ -1468,6 +1460,15 @@ x = l1regls(X,y)
<span style="color: #8B008B; font-weight: bold">return</span> g
<span style="color: #8B008B; font-weight: bold">return</span> solvers.coneqp(P, q, G, h, kktsolver = Fkkt)[<span style="color: #CD5555">&#39;x&#39;</span>][:n]
<span style="color: #228B22">#from l1regls import l1regls</span>
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> matrix, normal
X = matrix( [ [ <span style="color: #B452CD">2</span>, <span style="color: #B452CD">0</span>, <span style="color: #B452CD">1</span>], [<span style="color: #B452CD">0</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">3</span>]])
y = matrix( [<span style="color: #B452CD">4</span>, <span style="color: #B452CD">2</span>, <span style="color: #B452CD">3</span>])
x = l1regls(X,y)
</pre></div>
</section>
+10 -9
View File
@@ -1245,15 +1245,7 @@ python file.
<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">from</span> <span style="color: #008b45; text-decoration: underline">l1regls</span> <span style="color: #8B008B; font-weight: bold">import</span> l1regls
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> matrix, normal
<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>
X = matrix( [ [ <span style="color: #B452CD">2</span>, <span style="color: #B452CD">0</span>, <span style="color: #B452CD">1</span>], [<span style="color: #B452CD">0</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">3</span>]])
y = matrix( [<span style="color: #B452CD">4</span>, <span style="color: #B452CD">2</span>, <span style="color: #B452CD">3</span>])
x = l1regls(X,y)
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> matrix, spdiag, mul, div, sqrt, normal, setseed
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%;"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> matrix, spdiag, mul, div, sqrt, normal, setseed
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> blas, lapack, solvers, sparse, spmatrix
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">math</span>
@@ -1510,6 +1502,15 @@ x = l1regls(X,y)
<span style="color: #8B008B; font-weight: bold">return</span> g
<span style="color: #8B008B; font-weight: bold">return</span> solvers.coneqp(P, q, G, h, kktsolver = Fkkt)[<span style="color: #CD5555">&#39;x&#39;</span>][:n]
<span style="color: #228B22">#from l1regls import l1regls</span>
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">cvxopt</span> <span style="color: #8B008B; font-weight: bold">import</span> matrix, normal
X = matrix( [ [ <span style="color: #B452CD">2</span>, <span style="color: #B452CD">0</span>, <span style="color: #B452CD">1</span>], [<span style="color: #B452CD">0</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">3</span>]])
y = matrix( [<span style="color: #B452CD">4</span>, <span style="color: #B452CD">2</span>, <span style="color: #B452CD">3</span>])
x = l1regls(X,y)
</pre></div>
<p>
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
+10 -9
View File
@@ -1250,15 +1250,7 @@ python file.
<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">from</span> <span style="color: #0000FF; font-weight: bold">l1regls</span> <span style="color: #008000; font-weight: bold">import</span> l1regls
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> matrix, normal
<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>
X <span style="color: #666666">=</span> matrix( [ [ <span style="color: #666666">2</span>, <span style="color: #666666">0</span>, <span style="color: #666666">1</span>], [<span style="color: #666666">0</span>, <span style="color: #666666">1</span>, <span style="color: #666666">3</span>]])
y <span style="color: #666666">=</span> matrix( [<span style="color: #666666">4</span>, <span style="color: #666666">2</span>, <span style="color: #666666">3</span>])
x <span style="color: #666666">=</span> l1regls(X,y)
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> matrix, spdiag, mul, div, sqrt, normal, setseed
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> matrix, spdiag, mul, div, sqrt, normal, setseed
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> blas, lapack, solvers, sparse, spmatrix
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">math</span>
@@ -1515,6 +1507,15 @@ x <span style="color: #666666">=</span> l1regls(X,y)
<span style="color: #008000; font-weight: bold">return</span> g
<span style="color: #008000; font-weight: bold">return</span> solvers<span style="color: #666666">.</span>coneqp(P, q, G, h, kktsolver <span style="color: #666666">=</span> Fkkt)[<span style="color: #BA2121">&#39;x&#39;</span>][:n]
<span style="color: #408080; font-style: italic">#from l1regls import l1regls</span>
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">cvxopt</span> <span style="color: #008000; font-weight: bold">import</span> matrix, normal
X <span style="color: #666666">=</span> matrix( [ [ <span style="color: #666666">2</span>, <span style="color: #666666">0</span>, <span style="color: #666666">1</span>], [<span style="color: #666666">0</span>, <span style="color: #666666">1</span>, <span style="color: #666666">3</span>]])
y <span style="color: #666666">=</span> matrix( [<span style="color: #666666">4</span>, <span style="color: #666666">2</span>, <span style="color: #666666">3</span>])
x <span style="color: #666666">=</span> l1regls(X,y)
</pre></div>
<p>
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
Binary file not shown.
+10 -9
View File
@@ -1501,14 +1501,6 @@
},
"outputs": [],
"source": [
"from l1regls import l1regls\n",
"from cvxopt import matrix, normal\n",
"import numpy as np\n",
"\n",
"X = matrix( [ [ 2, 0, 1], [0, 1, 3]])\n",
"y = matrix( [4, 2, 3])\n",
"x = l1regls(X,y)\n",
"\n",
"from cvxopt import matrix, spdiag, mul, div, sqrt, normal, setseed\n",
"from cvxopt import blas, lapack, solvers, sparse, spmatrix\n",
"import math\n",
@@ -1765,7 +1757,16 @@
"\n",
" return g\n",
"\n",
" return solvers.coneqp(P, q, G, h, kktsolver = Fkkt)['x'][:n]"
" return solvers.coneqp(P, q, G, h, kktsolver = Fkkt)['x'][:n]\n",
"\n",
"\n",
"\n",
"#from l1regls import l1regls\n",
"from cvxopt import matrix, normal\n",
"\n",
"X = matrix( [ [ 2, 0, 1], [0, 1, 3]])\n",
"y = matrix( [4, 2, 3])\n",
"x = l1regls(X,y)"
]
},
{
+11 -8
View File
@@ -910,14 +910,6 @@ simpler problem we discussed above, where we have added the latter
python file.
!bc pycod
from l1regls import l1regls
from cvxopt import matrix, normal
import numpy as np
X = matrix( [ [ 2, 0, 1], [0, 1, 3]])
y = matrix( [4, 2, 3])
x = l1regls(X,y)
from cvxopt import matrix, spdiag, mul, div, sqrt, normal, setseed
from cvxopt import blas, lapack, solvers, sparse, spmatrix
import math
@@ -1176,6 +1168,17 @@ def l1regls(A, b):
return solvers.coneqp(P, q, G, h, kktsolver = Fkkt)['x'][:n]
#from l1regls import l1regls
from cvxopt import matrix, normal
X = matrix( [ [ 2, 0, 1], [0, 1, 3]])
y = matrix( [4, 2, 3])
x = l1regls(X,y)
!ec
!split