You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#and-a-corresponding-example-using-scikit-learn">And a corresponding example using <strong>scikit-learn</strong></a></li>
423
422
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#gradient-descent-and-ridge">Gradient descent and Ridge</a></li>
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#program-example-for-gradient-descent-with-ridge-regression">Program example for gradient descent with Ridge Regression</a></li>
@@ -631,7 +630,7 @@ <h2>Fixing the singularity<a class="headerlink" href="#fixing-the-singularity" t
631
630
\]</div>
632
631
<p>has linearly dependent column vectors, we will not be able to compute the inverse
633
632
of <spanclass="math notranslate nohighlight">\(\boldsymbol{X}^T\boldsymbol{X}\)</span> and we cannot find the parameters (estimators) <spanclass="math notranslate nohighlight">\(\theta_i\)</span>.
634
-
The estimators are only well-defined if <spanclass="math notranslate nohighlight">\((\boldsymbol{X}^{T}\boldsymbol{X})^{-1}\)</span>exits.
633
+
The estimators are only well-defined if <spanclass="math notranslate nohighlight">\((\boldsymbol{X}^{T}\boldsymbol{X})^{-1}\)</span>exists.
635
634
This is more likely to happen when the matrix <spanclass="math notranslate nohighlight">\(\boldsymbol{X}\)</span> is high-dimensional. In this case it is likely to encounter a situation where
636
635
the regression parameters <spanclass="math notranslate nohighlight">\(\theta_i\)</span> cannot be estimated.</p>
637
636
<p>A cheap <em>ad hoc</em> approach is simply to add a small diagonal component to the matrix to invert, that is we change</p>
<p>We can redefine <spanclass="math notranslate nohighlight">\(\lambda\)</span> to absorb the constant <spanclass="math notranslate nohighlight">\(n/2\)</span> and we rewrite the last equation as</p>
<p>This equation does not lead to a nice analytical equation as in either Ridge regression or ordinary least squares. This equation can however be solved by using standard convex optimization algorithms.We will discuss how to code the above methods using gradient descent methods.</p>
<h2>And a corresponding example using <strong>scikit-learn</strong><aclass="headerlink" href="#and-a-corresponding-example-using-scikit-learn" title="Link to this heading">#</a></h2>
1648
-
<divclass="cell docutils container">
1649
-
<divclass="cell_input docutils container">
1650
-
<divclass="highlight-none notranslate"><divclass="highlight"><pre><span></span># Importing various packages
<h2>Gradient descent and Ridge<aclass="headerlink" href="#gradient-descent-and-ridge" title="Link to this heading">#</a></h2>
1673
1647
<p>We have also discussed Ridge regression where the loss function contains a regularized term given by the <spanclass="math notranslate nohighlight">\(L_2\)</span> norm of <spanclass="math notranslate nohighlight">\(\theta\)</span>,</p>
@@ -2488,7 +2462,6 @@ <h2>Another Example, now with a polynomial fit<a class="headerlink" href="#anoth
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#and-a-corresponding-example-using-scikit-learn">And a corresponding example using <strong>scikit-learn</strong></a></li>
2492
2465
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#gradient-descent-and-ridge">Gradient descent and Ridge</a></li>
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#program-example-for-gradient-descent-with-ridge-regression">Program example for gradient descent with Ridge Regression</a></li>
0 commit comments