Skip to content

Commit b4b10b9

Browse files
Merge pull request #63 from UBC-DSCI/patch-my-section
removed my-section tags
2 parents 131d25a + b608195 commit b4b10b9

13 files changed

+175
-179
lines changed

03-viz.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ are external references that contain a wealth of additional information on the t
3939
- Use `ggsave` to save visualizations in `.png` and `.svg` format
4040

4141
## Choosing the visualization
42-
#### *Ask a question, and answer it* {-#my-section}
42+
#### *Ask a question, and answer it*
4343

4444
The purpose of a visualization is to answer a question about a data set of interest. So naturally, the first thing to do **before** creating
4545
a visualization is to formulate the question about the data that you are trying to answer.
@@ -68,7 +68,7 @@ again typically a better alternative.
6868

6969

7070
## Refining the visualization
71-
#### *Convey the message, minimize noise* {-#my-section}
71+
#### *Convey the message, minimize noise*
7272

7373
Just being able to make a visualization in R with `ggplot2` (or any other tool for that matter) doesn't mean that it is effective at communicating
7474
your message to others. Once you have selected a broad type of visualization to use, you will have to refine it to suit your particular need.
@@ -98,7 +98,7 @@ making it easier for them to quickly understand and remember your message.
9898

9999

100100
## Creating visualizations with `ggplot2`
101-
#### *Build the visualization iteratively* {-#my-section}
101+
#### *Build the visualization iteratively*
102102

103103
This section will cover examples of how to choose and refine a visualization given a data set and a question that you want to answer,
104104
and then how to create the visualization in R using `ggplot2`. To use the `ggplot2` library, we need to load the `tidyverse` metapackage.
@@ -379,7 +379,7 @@ admirable job given the technology available at the time period.
379379

380380

381381
## Explaining the visualization
382-
#### *Tell a story* {-#my-section}
382+
#### *Tell a story*
383383

384384
Typically, your visualization will not be shown completely on its own, but rather it will be part of a larger presentation.
385385
Further, visualizations can provide supporting information for any part of a presentation, from opening to conclusion.
@@ -425,7 +425,7 @@ worth further investigation into the differences between these experiments to se
425425

426426

427427
## Saving the visualization
428-
#### *Choose the right output format for your needs* {-#my-section}
428+
#### *Choose the right output format for your needs*
429429

430430
Just as there are many ways to store data sets, there are many ways to store visualizations and images.
431431
Which one you choose can depend on a number of factors, such as file size/type limitations

docs/GitHub.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<meta name="author" content="Melissa Lee" />
2727

2828

29-
<meta name="date" content="2020-11-22" />
29+
<meta name="date" content="2020-11-24" />
3030

3131
<meta name="viewport" content="width=device-width, initial-scale=1" />
3232
<meta name="apple-mobile-web-app-capable" content="yes" />

docs/classification-continued.html

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<meta name="author" content="Melissa Lee" />
2727

2828

29-
<meta name="date" content="2020-11-22" />
29+
<meta name="date" content="2020-11-24" />
3030

3131
<meta name="viewport" content="width=device-width, initial-scale=1" />
3232
<meta name="apple-mobile-web-app-capable" content="yes" />
@@ -453,33 +453,33 @@ <h2><span class="header-section-number">7.3</span> Evaluating accuracy</h2>
453453
<div class="sourceCode" id="cb213"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb213-1"><a href="classification-continued.html#cb213-1"></a><span class="kw">glimpse</span>(cancer_train)</span></code></pre></div>
454454
<pre><code>## Rows: 427
455455
## Columns: 12
456-
## $ ID &lt;dbl&gt; 842302, 842517, 84300903, 84348301, 84358402, 84378
457-
## $ Class &lt;fct&gt; M, M, M, M, M, M, M, M, M, M, M, M, M, M, M, B, B, …
458-
## $ Radius &lt;dbl&gt; 17.990, 20.570, 19.690, 11.420, 20.290, 12.450, 18.…
459-
## $ Texture &lt;dbl&gt; 10.38, 17.77, 21.25, 20.38, 14.34, 15.70, 19.98, 20…
460-
## $ Perimeter &lt;dbl&gt; 122.80, 132.90, 130.00, 77.58, 135.10, 82.57, 119.6
461-
## $ Area &lt;dbl&gt; 1001.0, 1326.0, 1203.0, 386.1, 1297.0, 477.1, 1040.…
462-
## $ Smoothness &lt;dbl&gt; 0.11840, 0.08474, 0.10960, 0.14250, 0.10030, 0.1278
463-
## $ Compactness &lt;dbl&gt; 0.27760, 0.07864, 0.15990, 0.28390, 0.13280, 0.1700
464-
## $ Concavity &lt;dbl&gt; 0.30010, 0.08690, 0.19740, 0.24140, 0.19800, 0.1578
465-
## $ Concave_Points &lt;dbl&gt; 0.14710, 0.07017, 0.12790, 0.10520, 0.10430, 0.0808
466-
## $ Symmetry &lt;dbl&gt; 0.2419, 0.1812, 0.2069, 0.2597, 0.1809, 0.2087, 0.1
467-
## $ Fractal_Dimension &lt;dbl&gt; 0.07871, 0.05667, 0.05999, 0.09744, 0.05883, 0.0761</code></pre>
456+
## $ ID &lt;dbl&gt; 842302, 842517, 84300903, 84348301, 84358402, 843786, 844359, 84458202, 84501001, 845
457+
## $ Class &lt;fct&gt; M, M, M, M, M, M, M, M, M, M, M, M, M, M, M, B, B, M, M, M, M, M, M, M, M, M, M, M, M
458+
## $ Radius &lt;dbl&gt; 17.990, 20.570, 19.690, 11.420, 20.290, 12.450, 18.250, 13.710, 12.460, 16.020, 15.78
459+
## $ Texture &lt;dbl&gt; 10.38, 17.77, 21.25, 20.38, 14.34, 15.70, 19.98, 20.83, 24.04, 23.24, 17.89, 24.80, 2
460+
## $ Perimeter &lt;dbl&gt; 122.80, 132.90, 130.00, 77.58, 135.10, 82.57, 119.60, 90.20, 83.97, 102.70, 103.60, 1
461+
## $ Area &lt;dbl&gt; 1001.0, 1326.0, 1203.0, 386.1, 1297.0, 477.1, 1040.0, 577.9, 475.9, 797.8, 781.0, 112
462+
## $ Smoothness &lt;dbl&gt; 0.11840, 0.08474, 0.10960, 0.14250, 0.10030, 0.12780, 0.09463, 0.11890, 0.11860, 0.08
463+
## $ Compactness &lt;dbl&gt; 0.27760, 0.07864, 0.15990, 0.28390, 0.13280, 0.17000, 0.10900, 0.16450, 0.23960, 0.06
464+
## $ Concavity &lt;dbl&gt; 0.30010, 0.08690, 0.19740, 0.24140, 0.19800, 0.15780, 0.11270, 0.09366, 0.22730, 0.03
465+
## $ Concave_Points &lt;dbl&gt; 0.147100, 0.070170, 0.127900, 0.105200, 0.104300, 0.080890, 0.074000, 0.059850, 0.085
466+
## $ Symmetry &lt;dbl&gt; 0.2419, 0.1812, 0.2069, 0.2597, 0.1809, 0.2087, 0.1794, 0.2196, 0.2030, 0.1528, 0.184
467+
## $ Fractal_Dimension &lt;dbl&gt; 0.07871, 0.05667, 0.05999, 0.09744, 0.05883, 0.07613, 0.05742, 0.07451, 0.08243, 0.05</code></pre>
468468
<div class="sourceCode" id="cb215"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb215-1"><a href="classification-continued.html#cb215-1"></a><span class="kw">glimpse</span>(cancer_test)</span></code></pre></div>
469469
<pre><code>## Rows: 142
470470
## Columns: 12
471-
## $ ID &lt;dbl&gt; 844981, 84799002, 848406, 849014, 8510426, 8511133,…
472-
## $ Class &lt;fct&gt; M, M, M, M, B, M, M, M, M, M, M, B, B, M, M, M, B, …
473-
## $ Radius &lt;dbl&gt; 13.000, 14.540, 14.680, 19.810, 13.540, 15.340, 18.…
474-
## $ Texture &lt;dbl&gt; 21.82, 27.54, 20.13, 22.15, 14.36, 14.26, 25.11, 26…
475-
## $ Perimeter &lt;dbl&gt; 87.50, 96.73, 94.74, 130.00, 87.46, 102.50, 124.80,…
476-
## $ Area &lt;dbl&gt; 519.8, 658.8, 684.5, 1260.0, 566.3, 704.4, 1088.0, …
477-
## $ Smoothness &lt;dbl&gt; 0.12730, 0.11390, 0.09867, 0.09831, 0.09779, 0.1073
478-
## $ Compactness &lt;dbl&gt; 0.19320, 0.15950, 0.07200, 0.10270, 0.08129, 0.2135
479-
## $ Concavity &lt;dbl&gt; 0.18590, 0.16390, 0.07395, 0.14790, 0.06664, 0.2077
480-
## $ Concave_Points &lt;dbl&gt; 0.093530, 0.073640, 0.052590, 0.094980, 0.047810, 0…
481-
## $ Symmetry &lt;dbl&gt; 0.2350, 0.2303, 0.1586, 0.1582, 0.1885, 0.2521, 0.2
482-
## $ Fractal_Dimension &lt;dbl&gt; 0.07389, 0.07077, 0.05922, 0.05395, 0.05766, 0.0703</code></pre>
471+
## $ ID &lt;dbl&gt; 844981, 84799002, 848406, 849014, 8510426, 8511133, 853401, 854002, 855167, 856106, 8
472+
## $ Class &lt;fct&gt; M, M, M, M, B, M, M, M, M, M, M, B, B, M, M, M, B, M, M, B, B, B, M, M, B, B, M, B, B
473+
## $ Radius &lt;dbl&gt; 13.000, 14.540, 14.680, 19.810, 13.540, 15.340, 18.630, 19.270, 13.440, 13.280, 18.22
474+
## $ Texture &lt;dbl&gt; 21.82, 27.54, 20.13, 22.15, 14.36, 14.26, 25.11, 26.47, 21.58, 20.28, 18.70, 11.79, 1
475+
## $ Perimeter &lt;dbl&gt; 87.50, 96.73, 94.74, 130.00, 87.46, 102.50, 124.80, 127.90, 86.18, 87.32, 120.30, 54.
476+
## $ Area &lt;dbl&gt; 519.8, 658.8, 684.5, 1260.0, 566.3, 704.4, 1088.0, 1162.0, 563.0, 545.2, 1033.0, 224.
477+
## $ Smoothness &lt;dbl&gt; 0.12730, 0.11390, 0.09867, 0.09831, 0.09779, 0.10730, 0.10640, 0.09401, 0.08162, 0.10
478+
## $ Compactness &lt;dbl&gt; 0.19320, 0.15950, 0.07200, 0.10270, 0.08129, 0.21350, 0.18870, 0.17190, 0.06031, 0.14
479+
## $ Concavity &lt;dbl&gt; 0.18590, 0.16390, 0.07395, 0.14790, 0.06664, 0.20770, 0.23190, 0.16570, 0.03110, 0.09
480+
## $ Concave_Points &lt;dbl&gt; 0.093530, 0.073640, 0.052590, 0.094980, 0.047810, 0.097560, 0.124400, 0.075930, 0.020
481+
## $ Symmetry &lt;dbl&gt; 0.2350, 0.2303, 0.1586, 0.1582, 0.1885, 0.2521, 0.2183, 0.1853, 0.1784, 0.1974, 0.209
482+
## $ Fractal_Dimension &lt;dbl&gt; 0.07389, 0.07077, 0.05922, 0.05395, 0.05766, 0.07032, 0.06197, 0.06261, 0.05587, 0.06</code></pre>
483483
<p>We can see from <code>glimpse</code> in the code above that the training set contains 427
484484
observations, while the test set contains 142 observations. This corresponds to
485485
a train / test split of 75% / 25%, as desired.</p>
@@ -514,17 +514,17 @@ <h2><span class="header-section-number">7.3</span> Evaluating accuracy</h2>
514514
<span id="cb218-9"><a href="classification-continued.html#cb218-9"></a><span class="st"> </span><span class="kw">fit</span>(<span class="dt">data =</span> cancer_train)</span>
515515
<span id="cb218-10"><a href="classification-continued.html#cb218-10"></a></span>
516516
<span id="cb218-11"><a href="classification-continued.html#cb218-11"></a>knn_fit</span></code></pre></div>
517-
<pre><code>## ══ Workflow [trained] ══════════════════════════════════════════════════════════
517+
<pre><code>## ══ Workflow [trained] ════════════════════════════════════════════════════════════════════════════════════════════
518518
## Preprocessor: Recipe
519519
## Model: nearest_neighbor()
520520
##
521-
## ── Preprocessor ────────────────────────────────────────────────────────────────
521+
## ── Preprocessor ──────────────────────────────────────────────────────────────────────────────────────────────────
522522
## 2 Recipe Steps
523523
##
524524
## ● step_scale()
525525
## ● step_center()
526526
##
527-
## ── Model ───────────────────────────────────────────────────────────────────────
527+
## ── Model ─────────────────────────────────────────────────────────────────────────────────────────────────────────
528528
##
529529
## Call:
530530
## kknn::train.kknn(formula = formula, data = data, ks = ~3, kernel = ~&quot;rectangular&quot;)
@@ -551,16 +551,15 @@ <h2><span class="header-section-number">7.3</span> Evaluating accuracy</h2>
551551
<span id="cb220-2"><a href="classification-continued.html#cb220-2"></a><span class="st"> </span><span class="kw">bind_cols</span>(cancer_test)</span>
552552
<span id="cb220-3"><a href="classification-continued.html#cb220-3"></a><span class="kw">head</span>(cancer_test_predictions)</span></code></pre></div>
553553
<pre><code>## # A tibble: 6 x 13
554-
## .pred_class ID Class Radius Texture Perimeter Area Smoothness Compactness
555-
## &lt;fct&gt; &lt;dbl&gt; &lt;fct&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;
556-
## 1 M 8.45e5 M 13 21.8 87.5 520. 0.127 0.193
557-
## 2 M 8.48e7 M 14.5 27.5 96.7 659. 0.114 0.160
558-
## 3 B 8.48e5 M 14.7 20.1 94.7 684. 0.0987 0.072
559-
## 4 M 8.49e5 M 19.8 22.2 130 1260 0.0983 0.103
560-
## 5 B 8.51e6 B 13.5 14.4 87.5 566. 0.0978 0.0813
561-
## 6 M 8.51e6 M 15.3 14.3 102. 704. 0.107 0.214
562-
## # … with 4 more variables: Concavity &lt;dbl&gt;, Concave_Points &lt;dbl&gt;,
563-
## # Symmetry &lt;dbl&gt;, Fractal_Dimension &lt;dbl&gt;</code></pre>
554+
## .pred_class ID Class Radius Texture Perimeter Area Smoothness Compactness Concavity Concave_Points Symmetry
555+
## &lt;fct&gt; &lt;dbl&gt; &lt;fct&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;
556+
## 1 M 8.45e5 M 13 21.8 87.5 520. 0.127 0.193 0.186 0.0935 0.235
557+
## 2 M 8.48e7 M 14.5 27.5 96.7 659. 0.114 0.160 0.164 0.0736 0.230
558+
## 3 B 8.48e5 M 14.7 20.1 94.7 684. 0.0987 0.072 0.0740 0.0526 0.159
559+
## 4 M 8.49e5 M 19.8 22.2 130 1260 0.0983 0.103 0.148 0.0950 0.158
560+
## 5 B 8.51e6 B 13.5 14.4 87.5 566. 0.0978 0.0813 0.0666 0.0478 0.188
561+
## 6 M 8.51e6 M 15.3 14.3 102. 704. 0.107 0.214 0.208 0.0976 0.252
562+
## # … with 1 more variable: Fractal_Dimension &lt;dbl&gt;</code></pre>
564563
<p><strong>5. Compute the accuracy</strong></p>
565564
<p>Finally we can assess our classifier’s accuracy. To do this we use the <code>metrics</code> function
566565
from <code>tidymodels</code> to get the statistics about the quality of our model, specifying

0 commit comments

Comments
 (0)