small typos
This commit is contained in:
@@ -427,7 +427,7 @@ doconce format html exercisesweek37.do.txt -->
|
||||
<p>We start with a very simple function</p>
|
||||
<div class="math notranslate nohighlight">
|
||||
\[
|
||||
\f(x)= 2-x+5x^2,
|
||||
f(x)= 2-x+5x^2,
|
||||
\]</div>
|
||||
<p>defined for <span class="math notranslate nohighlight">\(x\in [-2,2]\)</span>. You can add noise if you wish.</p>
|
||||
<p>We are going to fit this function with a polynomial ansatz. The easiest thing is to set up a second-order polynomial and see if you can fit the above function.
|
||||
@@ -496,10 +496,10 @@ print("Closed-form OLS coefficients:", theta_closed_form)
|
||||
</div>
|
||||
</div>
|
||||
<p>This computes the Ridge and OLS regression coefficients directly. The identity
|
||||
matrix <span class="math notranslate nohighlight">\(I\)</span> has the same size as <span class="math notranslate nohighlight">\(X^T X\)</span>. It adds <span class="math notranslate nohighlight">\(\lambda\)</span> to the diagonal of <span class="math notranslate nohighlight">\(X^T X for Ridge regression. We
|
||||
then invert this matrix and multiply by \)</span>X^T y<span class="math notranslate nohighlight">\(. The result
|
||||
for \)</span>\boldsymbol{\theta}<span class="math notranslate nohighlight">\( is a NumPy array of shape (n\)</span>_<span class="math notranslate nohighlight">\(features,) containing the
|
||||
fitted parameters \)</span>\boldsymbol{\theta}$..</p>
|
||||
matrix <span class="math notranslate nohighlight">\(I\)</span> has the same size as <span class="math notranslate nohighlight">\(X^T X\)</span>. It adds <span class="math notranslate nohighlight">\(\lambda\)</span> to the diagonal of <span class="math notranslate nohighlight">\(X^T X\)</span> for Ridge regression. We
|
||||
then invert this matrix and multiply by <span class="math notranslate nohighlight">\(X^T y\)</span>. The result
|
||||
for <span class="math notranslate nohighlight">\(\boldsymbol{\theta}\)</span> is a NumPy array of shape (n<span class="math notranslate nohighlight">\(\_\)</span>features,) containing the
|
||||
fitted parameters <span class="math notranslate nohighlight">\(\boldsymbol{\theta}\)</span>.</p>
|
||||
<section id="id1">
|
||||
<h3>3a)<a class="headerlink" href="#id1" title="Link to this heading">#</a></h3>
|
||||
<p>Finalize, in the above code, the OLS and Ridge regression determination of the optimal parameters <span class="math notranslate nohighlight">\(\boldsymbol{\theta}\)</span>.</p>
|
||||
|
||||
Reference in New Issue
Block a user