Skip to content

Commit

Permalink
note 11 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ishani07 committed Feb 25, 2024
1 parent 218caae commit 149aef2
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 583 deletions.
6 changes: 3 additions & 3 deletions constant_model_loss_transformations/loss_transformations.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,11 @@ In this calculation, we use the fact that the **sum of deviations from the mean
Let's quickly walk through the proof for this:
$$\sum_{i=1}^{n} (y_i - \bar{y}) = \sum_{i=1}^{n} y_i - \sum_{i=1}^{n} \bar{y}$$

$$ = \sum\_{i=1}^{n} y_i - n\bar{y}$$
$$ = \sum_{i=1}^{n} y_i - n\bar{y}$$

$$ = \sum*{i=1}^{n} y_i - n\frac{1}{n}\sum*{i=1}^{n}y$$
$$ = \sum_{i=1}^{n} y_i - n\frac{1}{n}\sum_{i=1}^{n}y$$

$$ = \sum*{i=1}^{n} y_i - \sum*{i=1}^{n}y_i$$
$$ = \sum_{i=1}^{n} y_i - \sum_{i=1}^{n}y_i$$

In our calculations, we'll also be using the definition of the variance as a sample. As a refresher:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,9 @@ <h2 data-number="11.9" class="anchored" data-anchor-id="bonus-calculating-consta
<p>Earlier, we calculated the constant model MSE using calculus. It turns out that there is a much more elegant way of performing this same minimization algebraically, without using calculus at all.</p>
<p>In this calculation, we use the fact that the <strong>sum of deviations from the mean is 0</strong> or that <span class="math inline">\(\sum_{i=1}^{n} (y_i - \bar{y}) = 0\)</span>.</p>
<p>Let’s quickly walk through the proof for this: <span class="math display">\[\sum_{i=1}^{n} (y_i - \bar{y}) = \sum_{i=1}^{n} y_i - \sum_{i=1}^{n} \bar{y}\]</span></p>
<p><span class="math display">\[ = \sum\_{i=1}^{n} y_i - n\bar{y}\]</span></p>
<p><span class="math display">\[ = \sum*{i=1}^{n} y_i - n\frac{1}{n}\sum*{i=1}^{n}y\]</span></p>
<p><span class="math display">\[ = \sum*{i=1}^{n} y_i - \sum*{i=1}^{n}y_i\]</span></p>
<p><span class="math display">\[ = \sum_{i=1}^{n} y_i - n\bar{y}\]</span></p>
<p><span class="math display">\[ = \sum_{i=1}^{n} y_i - n\frac{1}{n}\sum_{i=1}^{n}y\]</span></p>
<p><span class="math display">\[ = \sum_{i=1}^{n} y_i - \sum_{i=1}^{n}y_i\]</span></p>
<p>In our calculations, we’ll also be using the definition of the variance as a sample. As a refresher:</p>
<p><span class="math display">\[\sigma_y^2 = \frac{1}{n}\sum_{i=1}^{n} (y_i - \bar{y})^2\]</span></p>
<p>Getting into our calculation for MSE minimization:</p>
Expand Down Expand Up @@ -2333,11 +2333,11 @@ <h5 data-number="11.9.0.0.1" class="anchored" data-anchor-id="note"><span class=
<span id="cb29-860"><a href="#cb29-860" aria-hidden="true" tabindex="-1"></a>Let's quickly walk through the proof for this:</span>
<span id="cb29-861"><a href="#cb29-861" aria-hidden="true" tabindex="-1"></a>$$\sum_{i=1}^{n} (y_i - \bar{y}) = \sum_{i=1}^{n} y_i - \sum_{i=1}^{n} \bar{y}$$</span>
<span id="cb29-862"><a href="#cb29-862" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb29-863"><a href="#cb29-863" aria-hidden="true" tabindex="-1"></a>$$ = \sum<span class="sc">\_</span>{i=1}^{n} y_i - n\bar{y}$$</span>
<span id="cb29-863"><a href="#cb29-863" aria-hidden="true" tabindex="-1"></a>$$ = \sum_{i=1}^{n} y_i - n\bar{y}$$</span>
<span id="cb29-864"><a href="#cb29-864" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb29-865"><a href="#cb29-865" aria-hidden="true" tabindex="-1"></a>$$ = \sum*{i=1}^{n} y_i - n\frac{1}{n}\sum*{i=1}^{n}y$$</span>
<span id="cb29-865"><a href="#cb29-865" aria-hidden="true" tabindex="-1"></a>$$ = \sum_{i=1}^{n} y_i - n\frac{1}{n}\sum_{i=1}^{n}y$$</span>
<span id="cb29-866"><a href="#cb29-866" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb29-867"><a href="#cb29-867" aria-hidden="true" tabindex="-1"></a>$$ = \sum*{i=1}^{n} y_i - \sum*{i=1}^{n}y_i$$</span>
<span id="cb29-867"><a href="#cb29-867" aria-hidden="true" tabindex="-1"></a>$$ = \sum_{i=1}^{n} y_i - \sum_{i=1}^{n}y_i$$</span>
<span id="cb29-868"><a href="#cb29-868" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb29-869"><a href="#cb29-869" aria-hidden="true" tabindex="-1"></a>In our calculations, we'll also be using the definition of the variance as a sample. As a refresher:</span>
<span id="cb29-870"><a href="#cb29-870" aria-hidden="true" tabindex="-1"></a></span>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 35 additions & 35 deletions docs/pandas_2/pandas_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -1602,12 +1602,12 @@ <h3 data-number="3.3.4" class="anchored" data-anchor-id="sample"><span class="he
</thead>
<tbody>
<tr class="odd">
<td data-quarto-table-cell-role="th">328525</td>
<td data-quarto-table-cell-role="th">384635</td>
<td>CA</td>
<td>M</td>
<td>1994</td>
<td>Refugio</td>
<td>17</td>
<td>2015</td>
<td>August</td>
<td>177</td>
</tr>
</tbody>
</table>
Expand All @@ -1634,34 +1634,34 @@ <h3 data-number="3.3.4" class="anchored" data-anchor-id="sample"><span class="he
</thead>
<tbody>
<tr class="odd">
<td data-quarto-table-cell-role="th">337557</td>
<td>1998</td>
<td>Ryan</td>
<td>2432</td>
<td data-quarto-table-cell-role="th">229975</td>
<td>2020</td>
<td>Alyana</td>
<td>17</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">353111</td>
<td>2004</td>
<td>Rylan</td>
<td>72</td>
<td data-quarto-table-cell-role="th">50602</td>
<td>1964</td>
<td>Joanie</td>
<td>9</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">274384</td>
<td>1962</td>
<td>Gerhard</td>
<td>8</td>
<td data-quarto-table-cell-role="th">332277</td>
<td>1995</td>
<td>Antonino</td>
<td>5</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">251406</td>
<td>1935</td>
<td>Lester</td>
<td>41</td>
<td data-quarto-table-cell-role="th">89092</td>
<td>1982</td>
<td>Doris</td>
<td>44</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">48869</td>
<td>1963</td>
<td>Terilyn</td>
<td>8</td>
<td data-quarto-table-cell-role="th">7620</td>
<td>1925</td>
<td>Hiroko</td>
<td>6</td>
</tr>
</tbody>
</table>
Expand All @@ -1687,27 +1687,27 @@ <h3 data-number="3.3.4" class="anchored" data-anchor-id="sample"><span class="he
</thead>
<tbody>
<tr class="odd">
<td data-quarto-table-cell-role="th">343302</td>
<td data-quarto-table-cell-role="th">149281</td>
<td>2000</td>
<td>Timmy</td>
<td>21</td>
<td>Jada</td>
<td>193</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">151635</td>
<td data-quarto-table-cell-role="th">342595</td>
<td>2000</td>
<td>Victor</td>
<td>8</td>
<td>Israel</td>
<td>374</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">150822</td>
<td data-quarto-table-cell-role="th">344601</td>
<td>2000</td>
<td>Ankita</td>
<td>12</td>
<td>Zayd</td>
<td>6</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">152044</td>
<td data-quarto-table-cell-role="th">152062</td>
<td>2000</td>
<td>Hania</td>
<td>Jaileen</td>
<td>6</td>
</tr>
</tbody>
Expand Down
14 changes: 7 additions & 7 deletions docs/pandas_3/pandas_3.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/regex/regex.html
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,11 @@ <h4 data-number="6.2.1.2" class="anchored" data-anchor-id="canonicalization-with
<span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a>county_and_state[<span class="st">'clean_county_pandas'</span>] <span class="op">=</span> canonicalize_county_series(county_and_state[<span class="st">'County'</span>])</span>
<span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a>display(county_and_pop), display(county_and_state)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>/var/folders/7t/zbwy02ts2m7cn64fvwjqb8xw0000gp/T/ipykernel_6509/2523629438.py:3: FutureWarning:
<pre><code>/var/folders/7t/zbwy02ts2m7cn64fvwjqb8xw0000gp/T/ipykernel_68270/2523629438.py:3: FutureWarning:

The default value of regex will change from True to False in a future version. In addition, single character regular expressions will *not* be treated as literal strings when regex=True.

/var/folders/7t/zbwy02ts2m7cn64fvwjqb8xw0000gp/T/ipykernel_6509/2523629438.py:3: FutureWarning:
/var/folders/7t/zbwy02ts2m7cn64fvwjqb8xw0000gp/T/ipykernel_68270/2523629438.py:3: FutureWarning:

The default value of regex will change from True to False in a future version. In addition, single character regular expressions will *not* be treated as literal strings when regex=True.
</code></pre>
Expand Down
6 changes: 3 additions & 3 deletions docs/sampling/sampling.html
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ <h4 data-number="9.3.3.3" class="anchored" data-anchor-id="simple-random-sample"
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>random_sample <span class="op">=</span> movie.sample(n, replace <span class="op">=</span> <span class="va">False</span>) <span class="co">## By default, replace = False</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>np.mean(random_sample[<span class="st">"barbie"</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="9">
<pre><code>0.5304983917461519</code></pre>
<pre><code>0.5293715010740242</code></pre>
</div>
</div>
<p>This is very close to the actual vote of 0.5302792307692308!</p>
Expand All @@ -674,7 +674,7 @@ <h4 data-number="9.3.3.3" class="anchored" data-anchor-id="simple-random-sample"
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a>Markdown(<span class="ss">f"**Actual** = </span><span class="sc">{</span>actual_barbie<span class="sc">:.4f}</span><span class="ss">, **Sample** = </span><span class="sc">{</span>sample_barbie<span class="sc">:.4f}</span><span class="ss">, "</span></span>
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a> <span class="ss">f"**Err** = </span><span class="sc">{</span><span class="dv">100</span><span class="op">*</span>err<span class="sc">:.2f}</span><span class="ss">%."</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="10">
<p><strong>Actual</strong> = 0.5303, <strong>Sample</strong> = 0.5275, <strong>Err</strong> = 0.52%.</p>
<p><strong>Actual</strong> = 0.5303, <strong>Sample</strong> = 0.5325, <strong>Err</strong> = 0.42%.</p>
</div>
</div>
<p>We’ll learn how to choose this number when we (re)learn the Central Limit Theorem later in the semester.</p>
Expand Down Expand Up @@ -707,7 +707,7 @@ <h4 data-number="9.3.3.4" class="anchored" data-anchor-id="quantifying-chance-er
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>poll_result <span class="op">=</span> pd.Series(poll_result)</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>np.<span class="bu">sum</span>(poll_result <span class="op">&gt;</span> <span class="fl">0.5</span>)<span class="op">/</span><span class="dv">1000</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="13">
<pre><code>0.944</code></pre>
<pre><code>0.952</code></pre>
</div>
</div>
<p>You can see the curve looks roughly Gaussian/normal. Using KDE:</p>
Expand Down
Binary file modified docs/sampling/sampling_files/figure-html/cell-13-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/sampling/sampling_files/figure-html/cell-15-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
471 changes: 0 additions & 471 deletions docs/search.json

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions index.log
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex 2024.2.20) 22 FEB 2024 10:43
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex 2024.2.22) 25 FEB 2024 12:39
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**index.tex
(./index.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-18>
L3 programming layer <2024-02-20>
(/Users/Ishani/Library/TinyTeX/texmf-dist/tex/latex/koma-script/scrreprt.cls
Document Class: scrreprt 2023/07/07 v3.41 KOMA-Script document class (report)
(/Users/Ishani/Library/TinyTeX/texmf-dist/tex/latex/koma-script/scrkbase.sty
Expand Down Expand Up @@ -196,9 +196,9 @@ LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold'
)) (/Users/Ishani/Library/TinyTeX/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
) (/Users/Ishani/Library/TinyTeX/texmf-dist/tex/latex/unicode-math/unicode-math.sty (/Users/Ishani/Library/TinyTeX/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2024-02-18 L3 programming layer (loader)
Package: expl3 2024-02-20 L3 programming layer (loader)
(/Users/Ishani/Library/TinyTeX/texmf-dist/tex/latex/l3backend/l3backend-xetex.def
File: l3backend-xetex.def 2024-01-04 L3 backend support: XeTeX
File: l3backend-xetex.def 2024-02-20 L3 backend support: XeTeX
\g__graphics_track_int=\count272
\l__pdf_internal_box=\box55
\g__pdf_backend_object_int=\count273
Expand Down Expand Up @@ -2001,10 +2001,10 @@ Overfull \hbox (1214.62836pt too wide) in paragraph at lines 19012--19012
l.19055 \end{Shaded}

Here is how much of TeX's memory you used:
39295 strings out of 476785
805632 string characters out of 5802145
39295 strings out of 476779
805632 string characters out of 5801987
5000000 words of memory out of 5000000
60727 multiletter control sequences out of 15000+600000
60733 multiletter control sequences out of 15000+600000
564564 words of font info for 94 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
108i,8n,121p,10900b,1030s stack positions out of 10000i,1000n,20000p,200000b,200000s
Expand Down
Binary file modified index.pdf
Binary file not shown.
Loading

0 comments on commit 149aef2

Please sign in to comment.