-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1787 lines (1655 loc) · 87.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.2.313">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Nils Indreiten">
<title>Developer Working Status - Stack Overflow 2022 Survey</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script src="index_files/libs/clipboard/clipboard.min.js"></script>
<script src="index_files/libs/quarto-html/quarto.js"></script>
<script src="index_files/libs/quarto-html/popper.min.js"></script>
<script src="index_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="index_files/libs/quarto-html/anchor.min.js"></script>
<link href="index_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="index_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="index_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="index_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="index_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
</head>
<body>
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#executive-summary" id="toc-executive-summary" class="nav-link active" data-scroll-target="#executive-summary">Executive Summary</a></li>
<li><a href="#data-understanding" id="toc-data-understanding" class="nav-link" data-scroll-target="#data-understanding">Data Understanding</a>
<ul class="collapse">
<li><a href="#data-visualisation" id="toc-data-visualisation" class="nav-link" data-scroll-target="#data-visualisation">Data Visualisation</a></li>
<li><a href="#the-relationship-between-working-status-and-compensation" id="toc-the-relationship-between-working-status-and-compensation" class="nav-link" data-scroll-target="#the-relationship-between-working-status-and-compensation">The relationship between working status and compensation</a></li>
</ul></li>
<li><a href="#predictive-analytics" id="toc-predictive-analytics" class="nav-link" data-scroll-target="#predictive-analytics">Predictive Analytics</a></li>
<li><a href="#conclusion-recommendations-and-future-research-directions" id="toc-conclusion-recommendations-and-future-research-directions" class="nav-link" data-scroll-target="#conclusion-recommendations-and-future-research-directions">Conclusion, Recommendations and Future Research Directions</a></li>
<li><a href="#session-info" id="toc-session-info" class="nav-link" data-scroll-target="#session-info">Session Info</a></li>
</ul>
</nav>
</div>
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Developer Working Status - Stack Overflow 2022 Survey</h1>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Author</div>
<div class="quarto-title-meta-contents">
<p>Nils Indreiten </p>
</div>
</div>
</div>
</header>
<section id="executive-summary" class="level2">
<h2 class="anchored" data-anchor-id="executive-summary">Executive Summary</h2>
<p>This project is concerned with the Stack Overflow 2022 developer survey, this is a yearly survey conducted by Stack Overflow on developers and their current state of affairs. It covers a range of topics from income to how many years of experience they have and so on. Remote and Hybrid working arrangements have become increasingly important post COVID-19, as hybrid/fully remote arrangements become more popular; it is important that organisations adequately prepare for the. The objectives of this project are as follows. First to engage in exploratory data analysis. Second to understand whether there is a statistically significant difference in the compensation between remote and hybrid developers. Finally to train and screen some models with the view to deploy the best performing one to production.</p>
</section>
<section id="data-understanding" class="level2">
<h2 class="anchored" data-anchor-id="data-understanding">Data Understanding</h2>
<p>The data set contains more than 50 variables, ranging from years of experience to employment etc. For the purposes of this project we will select only a few and only Germany, The United Kingdom and The United States of America will be considered the variables chosen are outlined below:</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code> [1] "ResponseId" "Employment" "EdLevel" "YearsCode" "YearsCodePro"
[6] "OrgSize" "Country" "CompTotal" "Currency" "WorkExp"
[11] "RemoteWork" </code></pre>
</div>
</div>
<p>There is some data cleaning that we need to do, for example, consider the difference in the currencies across the countries in our sample:</p>
<div class="cell">
<div class="cell-output-display">
<table class="table table-sm table-striped">
<colgroup>
<col style="width: 63%">
<col style="width: 28%">
<col style="width: 7%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Country</th>
<th style="text-align: left;">Currency</th>
<th style="text-align: right;">Count</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Germany</td>
<td style="text-align: left;">EUR European Euro</td>
<td style="text-align: right;">3431</td>
</tr>
<tr class="even">
<td style="text-align: left;">Germany</td>
<td style="text-align: left;">USD United States dollar</td>
<td style="text-align: right;">2</td>
</tr>
<tr class="odd">
<td style="text-align: left;">United Kingdom of Great Britain and Northern Ireland</td>
<td style="text-align: left;">EUR European Euro</td>
<td style="text-align: right;">6</td>
</tr>
<tr class="even">
<td style="text-align: left;">United Kingdom of Great Britain and Northern Ireland</td>
<td style="text-align: left;">GBP Pound sterling</td>
<td style="text-align: right;">3039</td>
</tr>
<tr class="odd">
<td style="text-align: left;">United Kingdom of Great Britain and Northern Ireland</td>
<td style="text-align: left;">USD United States dollar</td>
<td style="text-align: right;">16</td>
</tr>
<tr class="even">
<td style="text-align: left;">United States of America</td>
<td style="text-align: left;">EUR European Euro</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="odd">
<td style="text-align: left;">United States of America</td>
<td style="text-align: left;">USD United States dollar</td>
<td style="text-align: right;">9543</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>We can see that there is a difference in the currencies between the countries, let’s convert the euro and pound sterling to dollar:</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>survey <span class="sc">%>%</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="at">Currency =</span> <span class="fu">str_sub</span>(Currency, <span class="dv">1</span>, <span class="dv">3</span>),</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="at">Compensation_usd =</span> <span class="fu">case_when</span>(</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> Currency <span class="sc">==</span> <span class="st">"GBP"</span> <span class="sc">~</span> CompTotal <span class="sc">*</span> <span class="fl">1.21</span>,</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> Currency <span class="sc">==</span> <span class="st">"EUR"</span> <span class="sc">~</span> CompTotal <span class="sc">*</span> <span class="fl">1.06</span>,</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> CompTotal</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(<span class="sc">-</span>CompTotal,<span class="sc">-</span>Currency,<span class="sc">-</span>ResponseId) <span class="sc">%>%</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">YearsCode =</span> <span class="fu">as.double</span>(YearsCode),</span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="at">YearsCodePro =</span> <span class="fu">as.double</span>(YearsCodePro),</span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a> <span class="at">Country =</span> <span class="fu">case_when</span>(</span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> Country <span class="sc">==</span> <span class="st">"United States of America"</span> <span class="sc">~</span> <span class="st">"USA"</span>,</span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> Country <span class="sc">==</span> <span class="st">"United Kingdom of Great Britain and Northern Ireland"</span> <span class="sc">~</span> <span class="st">"GB"</span>,</span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> Country</span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">%>%</span> </span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">na.omit</span>() <span class="sc">%>%</span> </span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(Compensation_usd <span class="sc"><=</span> <span class="dv">6000000</span> <span class="sc">&</span> Compensation_usd <span class="sc">>=</span> <span class="dv">1000</span>) <span class="ot">-></span> survey </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stderr">
<pre><code>Warning in mask$eval_all_mutate(quo): NAs introduced by coercion
Warning in mask$eval_all_mutate(quo): NAs introduced by coercion</code></pre>
</div>
</div>
<p>The exchange rate was determined at the time of writing this project and may be different at the time of reading this. In addition we also changed the columns denoting the numbers of years with coding experience to be numeric, since they where characters, and shortened the country names. Finally we also removed some outliers.</p>
<section id="data-visualisation" class="level3">
<h3 class="anchored" data-anchor-id="data-visualisation">Data Visualisation</h3>
<p>Disparities between the compensation among developers depending on geographical region has long been a subject of study. Let’s take a look at this difference for the three countries in the sample:</p>
<div class="cell">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Figure 1. Distribution of total compensation for developers</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>At a general level it seems that the distributions in each country follow a similar trend, they are right skewed. When comparing the distributions to the median of the compensation for the sample as a whole it becomes clear that, The United States has a larger share of developers earning more than the median compensation, which is $ 110,000. In contrast, the majority of developers in both the United Kingdom and Germany have a total compensation that is below the median.</p>
<p>It would be interesting to see how this relationship holds up when considering other factors such as years coding professionally and working status:</p>
<div class="cell">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Figure 2. Relationship between work experience and compensastion broken down by work status</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>It is somewhat difficult to see whether a pattern exists, however, the plot above demonstrates that the sample size for The United States is much larger than the other countries. If we focus on The United Kingdom on may be able to suggest that there are more hybrid developers earning $200k or more with varying years of professional experience. In contrast, we may say the inverse about developers in Germany. Due to the large sample size for The United States it is much harder to pick out the nuances in the developers earning $200k or more and what level of experience and working status they have.</p>
</section>
<section id="the-relationship-between-working-status-and-compensation" class="level3">
<h3 class="anchored" data-anchor-id="the-relationship-between-working-status-and-compensation">The relationship between working status and compensation</h3>
<p>Focusing on the USA sample, let’s look into the effect size of the years of professional coding and work experience, when considering remote working status and when not taking the effect into account:</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>survey_usa <span class="ot"><-</span> survey <span class="sc">%>%</span> </span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(Country <span class="sc">==</span> <span class="st">"USA"</span>)</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">123</span>)</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a>ignore_remote_usa_intervals <span class="ot"><-</span> <span class="fu">reg_intervals</span>(Compensation_usd <span class="sc">~</span> YearsCodePro<span class="sc">+</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> WorkExp,</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="at">data=</span>survey_usa,</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="at">times =</span> <span class="dv">500</span>)</span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">123</span>)</span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a>account_for_remote_usa <span class="ot"><-</span> </span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">reg_intervals</span>(Compensation_usd <span class="sc">~</span> YearsCodePro<span class="sc">+</span></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a> WorkExp<span class="sc">+</span></span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a> RemoteWork,</span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a> <span class="at">data=</span>survey_usa,</span>
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a> <span class="at">times =</span> <span class="dv">500</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>The bootstrapped results show that there is virtually no difference when accounting for remote status. In other words, there is no difference between the effect of years professionally coding and years of work experience on the compensation in USD. Perhaps more importantly we see that the number of years professionally coded actually has a more positive impact on compensation, whereas work experience has a negative effect. Why might this be the case?</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">bind_rows</span>(</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> ignore_remote_usa_intervals <span class="sc">%>%</span> <span class="fu">mutate</span>(<span class="at">Remote =</span> <span class="st">"ignore"</span>), </span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> account_for_remote_usa <span class="sc">%>%</span> <span class="fu">mutate</span>(<span class="at">Remote =</span> <span class="st">"account for remote"</span>)</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>) <span class="sc">%>%</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">str_detect</span>(term, <span class="st">"Remote"</span>)) <span class="sc">%>%</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(.estimate, term, <span class="at">color =</span> Remote)) <span class="sc">+</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="at">xintercept =</span> <span class="dv">0</span>, <span class="at">linewidth =</span> <span class="fl">1.5</span>, <span class="at">lty =</span> <span class="dv">2</span>, <span class="at">color =</span> <span class="st">"gray50"</span>) <span class="sc">+</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_errorbar</span>(<span class="at">linewidth =</span> <span class="fl">1.4</span>, <span class="at">alpha =</span> <span class="fl">0.7</span>,</span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">xmin =</span> .lower, <span class="at">xmax =</span> .upper)) <span class="sc">+</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">size =</span> <span class="dv">3</span>) <span class="sc">+</span></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_continuous</span>(<span class="at">labels =</span> scales<span class="sc">::</span>dollar) <span class="sc">+</span></span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_color_manual</span>(<span class="at">values =</span> values) <span class="sc">+</span></span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">legend.position=</span><span class="st">"bottom"</span>) <span class="sc">+</span></span>
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x =</span> <span class="st">"Change in compensation (USD $)"</span>, <span class="at">y =</span> <span class="cn">NULL</span>, <span class="at">color =</span> <span class="st">"Include working status in model?"</span>,</span>
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a> <span class="at">subtitle =</span> <span class="st">"There is no difference in the effect of coding and work experience on compensation that developers get</span><span class="sc">\n</span><span class="st">according to whether they are remote or hybrid"</span>)<span class="sc">+</span></span>
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a> tidyquant<span class="sc">::</span><span class="fu">theme_tq</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-7-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Figure 3. Bootstrapp intervals when accounting for working status</figcaption><p></p>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="predictive-analytics" class="level2">
<h2 class="anchored" data-anchor-id="predictive-analytics">Predictive Analytics</h2>
<p>Now that we have a better understanding of the data, let’s proceed to build some predictive models that will aid us in predicting whether a developer will opt for being fully remote or hybrid. We begin by creating our training and testing splits, using stratified re-sampling on the outcome variable:</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">1234</span>)</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>Stack_split <span class="ot"><-</span> <span class="fu">initial_split</span>(survey, <span class="at">strata =</span> RemoteWork)</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>Stack_train <span class="ot"><-</span> <span class="fu">training</span>(Stack_split)</span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>Stack_test <span class="ot"><-</span> <span class="fu">testing</span>(Stack_split)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>Next we want to specify our pre-processing recipe or our feature engineering steps:</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>Stack_recipe <span class="ot"><-</span> <span class="fu">recipe</span>(RemoteWork <span class="sc">~</span> ., <span class="at">data =</span> survey) <span class="sc">%>%</span> </span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">step_YeoJohnson</span>(<span class="fu">all_numeric_predictors</span>()) <span class="sc">%>%</span> </span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">step_normalize</span>(<span class="fu">all_numeric_predictors</span>())</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>We applied two preprocessing steps, the first applies the Yeo-Johnson transformation to the data and the second normalises the data. One could argue that only one is needed, however given the anomalies in the data, it would be safe to include both. We can also consider this when selecting the best model as a method for boosting performance.</p>
<p>Let’s begin by specifying three models, all of which we will tune to get good candidates for the final models. The specs for the models are outlined below:</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>glm_spec <span class="ot"><-</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">logistic_reg</span>(<span class="at">mixture =</span> <span class="dv">1</span>) <span class="sc">|></span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">set_engine</span>(<span class="st">"glm"</span>)</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a>cart_spec <span class="ot"><-</span> </span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">decision_tree</span>(<span class="at">cost_complexity =</span> <span class="fu">tune</span>(), <span class="at">min_n =</span> <span class="fu">tune</span>()) <span class="sc">%>%</span> </span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">set_engine</span>(<span class="st">"rpart"</span>) <span class="sc">%>%</span> </span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">set_mode</span>(<span class="st">"classification"</span>)</span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a>tree_spec <span class="ot"><-</span></span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">rand_forest</span>(<span class="at">min_n =</span> <span class="fu">tune</span>(),<span class="at">trees=</span><span class="dv">1000</span>) <span class="sc">|></span></span>
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">set_engine</span>(<span class="st">"ranger"</span>) <span class="sc">|></span></span>
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">set_mode</span>(<span class="st">"classification"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>In addition, we will also implement 5-fold cross-validation, to make the model selection more robust. This is defined below:</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">1234</span>)</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>Stack_folds <span class="ot"><-</span> <span class="fu">vfold_cv</span>(Stack_train,<span class="at">strata =</span> RemoteWork,<span class="at">v =</span> <span class="dv">5</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>Next, we specify a workflow set, which includes all of the models that we specified. This will apply the recipe across the models.</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>doParallel<span class="sc">::</span><span class="fu">registerDoParallel</span>()</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>workflow_set <span class="ot"><-</span></span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">workflow_set</span>(</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a> <span class="at">preproc =</span> <span class="fu">list</span>(Stack_recipe),</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a> <span class="at">models =</span> <span class="fu">list</span>(</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a> <span class="at">glm =</span> glm_spec,</span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a> <span class="at">cart =</span> cart_spec ,</span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="at">tree =</span> tree_spec)</span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> ) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>Finally we need to set up a tuning grid such that different values for the different parameters can be passed to the relevant models. We set this grid up below, assigning the results to <code>grid_results</code>.</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Grid:</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>grid_ctrl <span class="ot"><-</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">control_grid</span>(</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="at">save_pred =</span> <span class="cn">TRUE</span>,</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="at">parallel_over =</span> <span class="st">"everything"</span>,</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="at">save_workflow =</span> <span class="cn">TRUE</span></span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a>grid_results <span class="ot"><-</span></span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a> workflow_set <span class="sc">%>%</span></span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">workflow_map</span>(</span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a> <span class="at">seed =</span> <span class="dv">1503</span>,</span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a> <span class="at">resamples =</span> Stack_folds,</span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a> <span class="at">grid =</span> <span class="dv">25</span>,</span>
<span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a> <span class="at">control =</span> grid_ctrl,</span>
<span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a> <span class="at">metrics =</span> <span class="fu">metric_set</span>(roc_auc,accuracy, sensitivity, specificity)</span>
<span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>We now have a set of candidates for our different types of models. Let’s get a quick summary of the best candidates considering the <code>roc_auc</code> metric:</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">rank_results</span>(grid_results,</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="at">rank_metric =</span> <span class="st">"roc_auc"</span>,</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="at">select_best =</span> <span class="cn">TRUE</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a>) <span class="sc">|></span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">gt</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div id="vcjkqbilaj" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>html {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
}
:where(#vcjkqbilaj) .gt_table {
display: table;
border-collapse: collapse;
margin-left: auto;
margin-right: auto;
color: #333333;
font-size: 16px;
font-weight: normal;
font-style: normal;
background-color: #FFFFFF;
width: auto;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #A8A8A8;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #A8A8A8;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_heading {
background-color: #FFFFFF;
text-align: center;
border-bottom-color: #FFFFFF;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_caption {
padding-top: 4px;
padding-bottom: 4px;
}
:where(#vcjkqbilaj) .gt_title {
color: #333333;
font-size: 125%;
font-weight: initial;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
border-bottom-color: #FFFFFF;
border-bottom-width: 0;
}
:where(#vcjkqbilaj) .gt_subtitle {
color: #333333;
font-size: 85%;
font-weight: initial;
padding-top: 0;
padding-bottom: 6px;
padding-left: 5px;
padding-right: 5px;
border-top-color: #FFFFFF;
border-top-width: 0;
}
:where(#vcjkqbilaj) .gt_bottom_border {
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_col_headings {
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_col_heading {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: normal;
text-transform: inherit;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: bottom;
padding-top: 5px;
padding-bottom: 6px;
padding-left: 5px;
padding-right: 5px;
overflow-x: hidden;
}
:where(#vcjkqbilaj) .gt_column_spanner_outer {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: normal;
text-transform: inherit;
padding-top: 0;
padding-bottom: 0;
padding-left: 4px;
padding-right: 4px;
}
:where(#vcjkqbilaj) .gt_column_spanner_outer:first-child {
padding-left: 0;
}
:where(#vcjkqbilaj) .gt_column_spanner_outer:last-child {
padding-right: 0;
}
:where(#vcjkqbilaj) .gt_column_spanner {
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
vertical-align: bottom;
padding-top: 5px;
padding-bottom: 5px;
overflow-x: hidden;
display: inline-block;
width: 100%;
}
:where(#vcjkqbilaj) .gt_group_heading {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: middle;
text-align: left;
}
:where(#vcjkqbilaj) .gt_empty_group_heading {
padding: 0.5px;
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
vertical-align: middle;
}
:where(#vcjkqbilaj) .gt_from_md > :first-child {
margin-top: 0;
}
:where(#vcjkqbilaj) .gt_from_md > :last-child {
margin-bottom: 0;
}
:where(#vcjkqbilaj) .gt_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
margin: 10px;
border-top-style: solid;
border-top-width: 1px;
border-top-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: middle;
overflow-x: hidden;
}
:where(#vcjkqbilaj) .gt_stub {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-right-style: solid;
border-right-width: 2px;
border-right-color: #D3D3D3;
padding-left: 5px;
padding-right: 5px;
}
:where(#vcjkqbilaj) .gt_stub_row_group {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-right-style: solid;
border-right-width: 2px;
border-right-color: #D3D3D3;
padding-left: 5px;
padding-right: 5px;
vertical-align: top;
}
:where(#vcjkqbilaj) .gt_row_group_first td {
border-top-width: 2px;
}
:where(#vcjkqbilaj) .gt_summary_row {
color: #333333;
background-color: #FFFFFF;
text-transform: inherit;
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
}
:where(#vcjkqbilaj) .gt_first_summary_row {
border-top-style: solid;
border-top-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_first_summary_row.thick {
border-top-width: 2px;
}
:where(#vcjkqbilaj) .gt_last_summary_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_grand_summary_row {
color: #333333;
background-color: #FFFFFF;
text-transform: inherit;
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
}
:where(#vcjkqbilaj) .gt_first_grand_summary_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
border-top-style: double;
border-top-width: 6px;
border-top-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_striped {
background-color: rgba(128, 128, 128, 0.05);
}
:where(#vcjkqbilaj) .gt_table_body {
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_footnotes {
color: #333333;
background-color: #FFFFFF;
border-bottom-style: none;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_footnote {
margin: 0px;
font-size: 90%;
padding-left: 4px;
padding-right: 4px;
padding-left: 5px;
padding-right: 5px;
}
:where(#vcjkqbilaj) .gt_sourcenotes {
color: #333333;
background-color: #FFFFFF;
border-bottom-style: none;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
}
:where(#vcjkqbilaj) .gt_sourcenote {
font-size: 90%;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
}
:where(#vcjkqbilaj) .gt_left {
text-align: left;
}
:where(#vcjkqbilaj) .gt_center {
text-align: center;
}
:where(#vcjkqbilaj) .gt_right {
text-align: right;
font-variant-numeric: tabular-nums;
}
:where(#vcjkqbilaj) .gt_font_normal {
font-weight: normal;
}
:where(#vcjkqbilaj) .gt_font_bold {
font-weight: bold;
}
:where(#vcjkqbilaj) .gt_font_italic {
font-style: italic;
}
:where(#vcjkqbilaj) .gt_super {
font-size: 65%;
}
:where(#vcjkqbilaj) .gt_footnote_marks {
font-style: italic;
font-weight: normal;
font-size: 75%;
vertical-align: 0.4em;
}
:where(#vcjkqbilaj) .gt_asterisk {
font-size: 100%;
vertical-align: 0;
}
:where(#vcjkqbilaj) .gt_indent_1 {
text-indent: 5px;
}
:where(#vcjkqbilaj) .gt_indent_2 {
text-indent: 10px;
}
:where(#vcjkqbilaj) .gt_indent_3 {
text-indent: 15px;
}
:where(#vcjkqbilaj) .gt_indent_4 {
text-indent: 20px;
}
:where(#vcjkqbilaj) .gt_indent_5 {
text-indent: 25px;
}
</style>
<table class="gt_table">
<thead class="gt_col_headings">
<tr>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="wflow_id">wflow_id</th>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id=".config">.config</th>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id=".metric">.metric</th>
<th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="mean">mean</th>
<th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="std_err">std_err</th>
<th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="n">n</th>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="preprocessor">preprocessor</th>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="model">model</th>
<th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="rank">rank</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_glm</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model1</td>
<td headers=".metric" class="gt_row gt_left">accuracy</td>
<td headers="mean" class="gt_row gt_right">0.6501339</td>
<td headers="std_err" class="gt_row gt_right">0.007533341</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">logistic_reg</td>
<td headers="rank" class="gt_row gt_right">1</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_glm</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model1</td>
<td headers=".metric" class="gt_row gt_left">roc_auc</td>
<td headers="mean" class="gt_row gt_right">0.6883320</td>
<td headers="std_err" class="gt_row gt_right">0.008206433</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">logistic_reg</td>
<td headers="rank" class="gt_row gt_right">1</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_glm</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model1</td>
<td headers=".metric" class="gt_row gt_left">sensitivity</td>
<td headers="mean" class="gt_row gt_right">0.7742917</td>
<td headers="std_err" class="gt_row gt_right">0.010852420</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">logistic_reg</td>
<td headers="rank" class="gt_row gt_right">1</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_glm</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model1</td>
<td headers=".metric" class="gt_row gt_left">specificity</td>
<td headers="mean" class="gt_row gt_right">0.4826992</td>
<td headers="std_err" class="gt_row gt_right">0.006106401</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">logistic_reg</td>
<td headers="rank" class="gt_row gt_right">1</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_tree</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model10</td>
<td headers=".metric" class="gt_row gt_left">accuracy</td>
<td headers="mean" class="gt_row gt_right">0.6414131</td>
<td headers="std_err" class="gt_row gt_right">0.005782571</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">rand_forest</td>
<td headers="rank" class="gt_row gt_right">2</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_tree</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model10</td>
<td headers=".metric" class="gt_row gt_left">roc_auc</td>
<td headers="mean" class="gt_row gt_right">0.6817129</td>
<td headers="std_err" class="gt_row gt_right">0.009726259</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">rand_forest</td>
<td headers="rank" class="gt_row gt_right">2</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_tree</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model10</td>
<td headers=".metric" class="gt_row gt_left">sensitivity</td>
<td headers="mean" class="gt_row gt_right">0.7549134</td>
<td headers="std_err" class="gt_row gt_right">0.012270465</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">rand_forest</td>
<td headers="rank" class="gt_row gt_right">2</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_tree</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model10</td>
<td headers=".metric" class="gt_row gt_left">specificity</td>
<td headers="mean" class="gt_row gt_right">0.4883598</td>
<td headers="std_err" class="gt_row gt_right">0.015144115</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">rand_forest</td>
<td headers="rank" class="gt_row gt_right">2</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_cart</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model11</td>
<td headers=".metric" class="gt_row gt_left">accuracy</td>
<td headers="mean" class="gt_row gt_right">0.6352469</td>
<td headers="std_err" class="gt_row gt_right">0.008110769</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">decision_tree</td>
<td headers="rank" class="gt_row gt_right">3</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_cart</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model11</td>
<td headers=".metric" class="gt_row gt_left">roc_auc</td>
<td headers="mean" class="gt_row gt_right">0.6509728</td>
<td headers="std_err" class="gt_row gt_right">0.008873967</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">decision_tree</td>
<td headers="rank" class="gt_row gt_right">3</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_cart</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model11</td>
<td headers=".metric" class="gt_row gt_left">sensitivity</td>
<td headers="mean" class="gt_row gt_right">0.7777017</td>
<td headers="std_err" class="gt_row gt_right">0.019648875</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">decision_tree</td>
<td headers="rank" class="gt_row gt_right">3</td></tr>
<tr><td headers="wflow_id" class="gt_row gt_left">recipe_cart</td>
<td headers=".config" class="gt_row gt_left">Preprocessor1_Model11</td>
<td headers=".metric" class="gt_row gt_left">specificity</td>
<td headers="mean" class="gt_row gt_right">0.4431613</td>
<td headers="std_err" class="gt_row gt_right">0.016071975</td>
<td headers="n" class="gt_row gt_right">5</td>
<td headers="preprocessor" class="gt_row gt_left">recipe</td>
<td headers="model" class="gt_row gt_left">decision_tree</td>
<td headers="rank" class="gt_row gt_right">3</td></tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Performance isn’t great, our accuracy and area under the curve remain between 63% and 68%, for the best model candidates. It seems a simple logistic regression model will do the job, eliminating the need for additional computation that is required for the other models. However, it would be wise to consider other aspects of the performance according to other metrics. This is shown in the figure below, broken down by the model type.</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>grid_results <span class="sc">%>%</span> </span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">autoplot</span>()<span class="sc">+</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-15-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption class="figure-caption">Figure 4. Metric results for workflow sets</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>Let’s consider, the decision tree that is rankled 25th. In terms of sensitivity the 25th ranked model, which is a decision tree. We can see that is achieves an accuracy score of around 6.40, whilst in terms of sensitivity it achieves around 0.77, however this comes at the expense of specificity which is just below 0.45. Finally, the area under the curve for this model is 0.65. We can see how these metrics fluctuate for the different model candidates, according to their rank.</p>
<p>In addition to looking at how the metrics fluctuate at the overall level, we can also see how the tuned hyper-parameters affect the metrics. Let’s consider the tuned parameter of the decision tree, minimal node size:</p>
<div class="cell">
<details>
<summary>Show the code</summary>
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>grid_results <span class="sc">%>%</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">extract_workflow_set_result</span>(<span class="st">"recipe_tree"</span>) <span class="sc">%>%</span> </span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="fu">autoplot</span>()<span class="sc">+</span></span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>()<span class="sc">+</span></span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">title =</span> <span class="st">"Minimal Node Size Effect on Metrics"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>