generated from laser-institute/laser-getting-started
-
Notifications
You must be signed in to change notification settings - Fork 65
/
orientation-case-study-key-python.html
2426 lines (2373 loc) · 133 KB
/
orientation-case-study-key-python.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.4.550">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="LASER Institute">
<meta name="dcterms.date" content="2024-07-14">
<title>A Coding Case Study with Quarto</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 -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { 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;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
margin-bottom: 0em;
}
.hanging-indent div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script><script src="orientation-case-study-key-python_files/libs/clipboard/clipboard.min.js"></script>
<script src="orientation-case-study-key-python_files/libs/quarto-html/quarto.js"></script>
<script src="orientation-case-study-key-python_files/libs/quarto-html/popper.min.js"></script>
<script src="orientation-case-study-key-python_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="orientation-case-study-key-python_files/libs/quarto-html/anchor.min.js"></script>
<link href="orientation-case-study-key-python_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="orientation-case-study-key-python_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-text-highlighting-styles">
<link href="orientation-case-study-key-python_files/libs/quarto-html/quarto-syntax-highlighting-dark.css" rel="prefetch" class="quarto-color-scheme quarto-color-alternate" id="quarto-text-highlighting-styles">
<script src="orientation-case-study-key-python_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="orientation-case-study-key-python_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="orientation-case-study-key-python_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-bootstrap" data-mode="light">
<link href="orientation-case-study-key-python_files/libs/bootstrap/bootstrap-dark.min.css" rel="prefetch" class="quarto-color-scheme quarto-color-alternate" id="quarto-bootstrap" data-mode="dark">
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" integrity="sha512-c3Nl8+7g4LMSTdrm621y7kf9v3SDPnhxLNhcjFJbKECVnmZHTdo+IRO05sNLTH/D3vA6u1X32ehoLC7WFVdheg==" crossorigin="anonymous"></script>
<script type="application/javascript">define('jquery', [],function() {return window.jQuery;})</script>
</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="#introduction" id="toc-introduction" class="nav-link active" data-scroll-target="#introduction">0. INTRODUCTION</a>
<ul>
<li><a href="#how-to-use-this-quarto-document" id="toc-how-to-use-this-quarto-document" class="nav-link" data-scroll-target="#how-to-use-this-quarto-document">How to use this Quarto document</a>
<ul class="collapse">
<li><a href="#source-vs.-visual-editor" id="toc-source-vs.-visual-editor" class="nav-link" data-scroll-target="#source-vs.-visual-editor">Source vs. Visual Editor</a></li>
<li><a href="#your-turn" id="toc-your-turn" class="nav-link" data-scroll-target="#your-turn">👉 Your Turn ⤵</a></li>
<li><a href="#code-chunks" id="toc-code-chunks" class="nav-link" data-scroll-target="#code-chunks">Code “Chunks”</a></li>
<li><a href="#your-turn-1" id="toc-your-turn-1" class="nav-link" data-scroll-target="#your-turn-1">👉 Your Turn ⤵</a></li>
<li><a href="#question" id="toc-question" class="nav-link" data-scroll-target="#question">❓Question</a></li>
</ul></li>
<li><a href="#the-data-intensive-research-workflow" id="toc-the-data-intensive-research-workflow" class="nav-link" data-scroll-target="#the-data-intensive-research-workflow">The Data-Intensive Research Workflow</a></li>
</ul></li>
<li><a href="#prepare" id="toc-prepare" class="nav-link" data-scroll-target="#prepare">1. PREPARE</a>
<ul>
<li><a href="#research-question" id="toc-research-question" class="nav-link" data-scroll-target="#research-question">Research Question</a></li>
<li><a href="#projects-packages" id="toc-projects-packages" class="nav-link" data-scroll-target="#projects-packages">Projects & Packages 📦</a>
<ul class="collapse">
<li><a href="#your-turn-2" id="toc-your-turn-2" class="nav-link" data-scroll-target="#your-turn-2">👉 Your Turn ⤵</a></li>
<li><a href="#pandas" id="toc-pandas" class="nav-link" data-scroll-target="#pandas">pandas 📦</a></li>
<li><a href="#numpy" id="toc-numpy" class="nav-link" data-scroll-target="#numpy">NumPy 📦</a></li>
<li><a href="#pyplot" id="toc-pyplot" class="nav-link" data-scroll-target="#pyplot">Pyplot 📦</a></li>
<li><a href="#statsmodels" id="toc-statsmodels" class="nav-link" data-scroll-target="#statsmodels">Statsmodels 📦</a></li>
<li><a href="#scikit-learn" id="toc-scikit-learn" class="nav-link" data-scroll-target="#scikit-learn">scikit-learn 📦</a></li>
<li><a href="#your-turn-3" id="toc-your-turn-3" class="nav-link" data-scroll-target="#your-turn-3">👉 Your Turn ⤵</a></li>
</ul></li>
<li><a href="#loading-or-reading-in-data" id="toc-loading-or-reading-in-data" class="nav-link" data-scroll-target="#loading-or-reading-in-data">Loading (or reading in) data</a>
<ul class="collapse">
<li><a href="#your-turn-4" id="toc-your-turn-4" class="nav-link" data-scroll-target="#your-turn-4">👉 Your Turn ⤵</a></li>
<li><a href="#viewing-and-inspecting-data" id="toc-viewing-and-inspecting-data" class="nav-link" data-scroll-target="#viewing-and-inspecting-data">Viewing and inspecting data</a></li>
<li><a href="#your-turn-5" id="toc-your-turn-5" class="nav-link" data-scroll-target="#your-turn-5"><strong>👉 Your Turn ⤵</strong></a></li>
<li><a href="#question-1" id="toc-question-1" class="nav-link" data-scroll-target="#question-1">❓Question</a></li>
<li><a href="#data-types" id="toc-data-types" class="nav-link" data-scroll-target="#data-types">Data Types</a></li>
<li><a href="#your-turn-6" id="toc-your-turn-6" class="nav-link" data-scroll-target="#your-turn-6">👉 Your Turn ⤵</a></li>
<li><a href="#question-2" id="toc-question-2" class="nav-link" data-scroll-target="#question-2">❓Question</a></li>
</ul></li>
</ul></li>
<li><a href="#wrangle" id="toc-wrangle" class="nav-link" data-scroll-target="#wrangle">2. WRANGLE</a>
<ul>
<li><a href="#selecting-variables" id="toc-selecting-variables" class="nav-link" data-scroll-target="#selecting-variables">Selecting variables</a>
<ul class="collapse">
<li><a href="#your-turn-7" id="toc-your-turn-7" class="nav-link" data-scroll-target="#your-turn-7">👉 Your Turn ⤵</a></li>
<li><a href="#your-turn-8" id="toc-your-turn-8" class="nav-link" data-scroll-target="#your-turn-8">👉 Your Turn ⤵</a></li>
</ul></li>
<li><a href="#cleaning-data" id="toc-cleaning-data" class="nav-link" data-scroll-target="#cleaning-data">Cleaning data</a></li>
<li><a href="#handling-missing-values" id="toc-handling-missing-values" class="nav-link" data-scroll-target="#handling-missing-values">Handling Missing Values</a>
<ul class="collapse">
<li><a href="#your-turn-9" id="toc-your-turn-9" class="nav-link" data-scroll-target="#your-turn-9">👉 Your Turn ⤵</a></li>
<li><a href="#drop-missing-values" id="toc-drop-missing-values" class="nav-link" data-scroll-target="#drop-missing-values">Drop missing values</a></li>
<li><a href="#substitute-with-column-means" id="toc-substitute-with-column-means" class="nav-link" data-scroll-target="#substitute-with-column-means">Substitute with column means</a></li>
</ul></li>
<li><a href="#filtering-variables" id="toc-filtering-variables" class="nav-link" data-scroll-target="#filtering-variables">Filtering variables</a>
<ul class="collapse">
<li><a href="#your-turn-10" id="toc-your-turn-10" class="nav-link" data-scroll-target="#your-turn-10">👉 Your Turn ⤵</a></li>
<li><a href="#question-3" id="toc-question-3" class="nav-link" data-scroll-target="#question-3">❓Question</a></li>
</ul></li>
</ul></li>
<li><a href="#explore" id="toc-explore" class="nav-link" data-scroll-target="#explore">3. EXPLORE</a>
<ul>
<li><a href="#summary-statistics" id="toc-summary-statistics" class="nav-link" data-scroll-target="#summary-statistics">Summary Statistics</a>
<ul class="collapse">
<li><a href="#your-turn-11" id="toc-your-turn-11" class="nav-link" data-scroll-target="#your-turn-11"><strong>👉 Your Turn</strong> <strong>⤵</strong></a></li>
</ul></li>
<li><a href="#data-visualization" id="toc-data-visualization" class="nav-link" data-scroll-target="#data-visualization">Data Visualization</a>
<ul class="collapse">
<li><a href="#the-graphing-workflow" id="toc-the-graphing-workflow" class="nav-link" data-scroll-target="#the-graphing-workflow">The Graphing Workflow</a></li>
<li><a href="#your-turn-12" id="toc-your-turn-12" class="nav-link" data-scroll-target="#your-turn-12"><strong>👉 Your Turn</strong> <strong>⤵</strong></a></li>
<li><a href="#scatterplots" id="toc-scatterplots" class="nav-link" data-scroll-target="#scatterplots">Scatterplots</a></li>
<li><a href="#your-turn-13" id="toc-your-turn-13" class="nav-link" data-scroll-target="#your-turn-13"><strong>👉 Your Turn</strong> <strong>⤵</strong></a></li>
</ul></li>
</ul></li>
<li><a href="#model" id="toc-model" class="nav-link" data-scroll-target="#model">4. MODEL</a>
<ul>
<li><a href="#an-inferential-model" id="toc-an-inferential-model" class="nav-link" data-scroll-target="#an-inferential-model">An Inferential Model</a>
<ul class="collapse">
<li><a href="#your-turn-14" id="toc-your-turn-14" class="nav-link" data-scroll-target="#your-turn-14"><strong>👉 Your Turn</strong> <strong>⤵</strong></a></li>
</ul></li>
<li><a href="#a-predictive-model" id="toc-a-predictive-model" class="nav-link" data-scroll-target="#a-predictive-model">A Predictive Model</a>
<ul class="collapse">
<li><a href="#your-turn-15" id="toc-your-turn-15" class="nav-link" data-scroll-target="#your-turn-15"><strong>👉 Your Turn</strong> <strong>⤵</strong></a></li>
<li><a href="#your-turn-16" id="toc-your-turn-16" class="nav-link" data-scroll-target="#your-turn-16"><strong>👉 Your Turn</strong> <strong>⤵</strong></a></li>
<li><a href="#question-4" id="toc-question-4" class="nav-link" data-scroll-target="#question-4">❓Question</a></li>
</ul></li>
</ul></li>
<li><a href="#communicate" id="toc-communicate" class="nav-link" data-scroll-target="#communicate">5. COMMUNICATE</a>
<ul>
<li><a href="#render-document" id="toc-render-document" class="nav-link" data-scroll-target="#render-document">Render Document</a>
<ul class="collapse">
<li><a href="#your-turn-17" id="toc-your-turn-17" class="nav-link" data-scroll-target="#your-turn-17">👉 Your Turn ⤵</a></li>
</ul></li>
<li><a href="#publish-file" id="toc-publish-file" class="nav-link" data-scroll-target="#publish-file">Publish File</a>
<ul class="collapse">
<li><a href="#your-turn-18" id="toc-your-turn-18" class="nav-link" data-scroll-target="#your-turn-18">👉 Your Turn ⤵</a></li>
<li><a href="#publishing-with-quarto-pub" id="toc-publishing-with-quarto-pub" class="nav-link" data-scroll-target="#publishing-with-quarto-pub">Publishing with Quarto Pub</a></li>
<li><a href="#publishing-with-r-pubs" id="toc-publishing-with-r-pubs" class="nav-link" data-scroll-target="#publishing-with-r-pubs">Publishing with R Pubs</a></li>
</ul></li>
<li><a href="#your-first-laser-badge" id="toc-your-first-laser-badge" class="nav-link" data-scroll-target="#your-first-laser-badge">Your First LASER Badge!</a></li>
<li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li>
</ul></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">A Coding Case Study with Quarto</h1>
<p class="subtitle lead">LASER Orientation Module</p>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Author</div>
<div class="quarto-title-meta-contents">
<p>LASER Institute </p>
</div>
</div>
<div>
<div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents">
<p class="date">July 14, 2024</p>
</div>
</div>
</div>
</header>
<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">0. INTRODUCTION</h2>
<p><img src="img/LASER_Hx.png" class="img-fluid" style="width:40.0%"></p>
<p>Welcome to your first LASER Case Study! The case study activities included in each module demonstrate how key Learning Analytics (LA) techniques featured in exemplary STEM education research studies can be implemented with R or Python. Case studies also provide a holistic setting to explore important foundational topics integral to Learning Analytics such as reproducible research, use of APIs, and ethical use of educational data.</p>
<p>This orientation case study will also introduce you to <a href="https://quarto.org">Quarto</a>, which is heavily integrated into each LASER Module. You may have used Quarto before - or you may not have! Either is fine as this task will be designed with the assumption that you have not used Quarto before.</p>
<section id="how-to-use-this-quarto-document" class="level3">
<h3 class="anchored" data-anchor-id="how-to-use-this-quarto-document">How to use this Quarto document</h3>
<p>What you are working in now is an <strong>Q</strong>uarto <strong>m</strong>ark<strong>d</strong>own file as indicated by the .<strong>qmd</strong> file name extension. Quarto documents are fully reproducible and use a productive notebook interface to combine formatted text and “chunks” of code to produce a range of <a href="https://quarto.org/docs/guide/">static and dynamic output formats</a> including: HTML, PDF, Word, HTML5 slides, Tufte-style handouts, books, dashboards, shiny applications, scientific articles, websites, and more.</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Tip
</div>
</div>
<div class="callout-body-container callout-body">
<p>Quarto docs can include specially formatted <strong>callout boxes</strong> like this one to draw special attention to provide notes, tips, cautions, warnings, and important information.</p>
<p><strong>Pro tip</strong>: Quarto documents also have a handy Outline feature that allow you to easily navigate the entire document. If the outline is not currently visible, click the Outline button located on the right of the toolbar at the top of this document.</p>
</div>
</div>
<section id="source-vs.-visual-editor" class="level4">
<h4 class="anchored" data-anchor-id="source-vs.-visual-editor">Source vs. Visual Editor</h4>
<p>Following best practices for reproducible research <span class="citation" data-cites="gandrud2021">(<a href="#ref-gandrud2021" role="doc-biblioref">Gandrud 2021</a>)</span>, Quarto files store information in plain text <a href="https://bookdown.org/yihui/rmarkdown/markdown-syntax.html">markdown</a> syntax. You are currently viewing this Quarto document using the visual editor, The visual editor is set as the default view in the <a href="https://quarto.org/docs/get-started/hello/rstudio.html#yaml-header">Quarto YAML header</a> at the top of this document. Basically, a <a href="https://monashdatafluency.github.io/r-rep-res/yaml-header.html#">YAML header</a> is:</p>
<blockquote class="blockquote">
<p>a short blob of text that… not only dictates the final file format, but a style and feel for our final document.</p>
</blockquote>
<p>The visual editor allows you to view formatted headers, text and code chunks and is a bit more “human readable” than markdown syntax but there will be many occasions where you will want to take a look at the plain text source code underlying this document. This can be viewed at any point by switching to source mode for editing. You can toggle back and forth between these two modes by clicking on <strong>Source</strong> and <strong>Visual</strong> in the editor toolbar.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>You may have noticed a special kind of link in the text above. Specifically, a link citing Reproducible Research with R and R Studio by Chris Gandrud. The YAML header includes a bibliography option and points to our <code>reference.bib</code> file in the <code>lit</code> folder of this project, which produces a nice tooltip for linked references and a bibliography when our doc is <a href="https://quarto.org/docs/get-started/hello/rstudio.html#rendering">rendered</a> and <a href="https://quarto.org/docs/get-started/authoring/rstudio.html#publishing">published</a>. Click the following link to learn more about <a href="https://quarto.org/docs/authoring/citations.html">citations in Quarto</a>.</p>
</div>
</div>
</section>
<section id="your-turn" class="level4">
<h4 class="anchored" data-anchor-id="your-turn">👉 Your Turn ⤵</h4>
<p>LASER case studies include many interactive elements in which you are asked to perform an action, answer some questions, or write some code. These are indicated by the <strong>👉 Your Turn</strong> <strong>⤵</strong> header. Now it’s your turn to do something.</p>
<p>Take a look at the markdown syntax used to create this document by viewing with the source editor. To do so, click the “Source” button in the toolbar at the top of this file. After you’ve had a look, click back to the visual editor to continue.</p>
<p><img src="img/source-view.png" class="img-fluid" style="width:100.0%"></p>
<p>Great job! Let’s continue!</p>
</section>
<section id="code-chunks" class="level4">
<h4 class="anchored" data-anchor-id="code-chunks">Code “Chunks”</h4>
<p>In addition to including formatted text hyperlinks, and embedded images like above, Quarto documents can also include a specially formatted text box called a “<a href="https://quarto.org/docs/get-started/hello/rstudio.html#code-chunks">code chunk</a>.” These chunks allows you to run code from multiple languages including R, Python, and SQL. For example, the code chunk below is intended to run Python code as specified by “python” inside the curly brackets <code>{}</code>. It also contains a contains some code “comments” as indicted by the # hashtags and several lines of python code. You may have also noticed a set of buttons in the upper right corner of the code chunk which are used to execute the code.</p>
</section>
<section id="your-turn-1" class="level4">
<h4 class="anchored" data-anchor-id="your-turn-1">👉 Your Turn ⤵</h4>
<p>Click the green arrow <img src="https://d33wubrfki0l68.cloudfront.net/18153fb9953057ee5cff086122bd26f9cee8fe93/3aba9/images/notebook-run-chunk.png" class="img-fluid">icon on the right side of the code chunk to run the Python code and view the image file name <code>laser-cycle.png</code> stored in the <code>img</code> folder in your files pane. Quarto will execute the code and its output and any related messages are displayed below the chunk.</p>
<div id="83b24682" class="cell" data-execution_count="1">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Import the pyplot and image modules from the matplotlib library</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> matplotlib.pyplot <span class="im">as</span> plt</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Read and display an image from file</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>plt.imshow(plt.imread(<span class="st">'img/laser-cycle.png'</span>))</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>plt.axis(<span class="st">'off'</span>) <span class="co"># Hide axes</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>plt.show()</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">
<div>
<figure class="figure">
<p><img src="orientation-case-study-key-python_files/figure-html/cell-2-output-1.png" width="540" height="218" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Nice work! For this case study, <strong>don’t stress too much about understanding the code</strong>. We’ll spend a lot of time doing that in the other modules. For now, take a look at the image displayed and answer the question that follows by typing your response directly in this document.</p>
</section>
<section id="question" class="level4">
<h4 class="anchored" data-anchor-id="question">❓Question</h4>
<p>In LASER case studies, you will often see as part of “Your Turns” a ❓ icon that indicates you are being promoted to answer a question. Type your response to the following question by deleting “YOUR RESPONSE HERE” and adding your own response:</p>
<p>What do you think this image is intended to illustrate?</p>
<ul>
<li>YOUR RESPONSE HERE</li>
</ul>
</section>
</section>
<section id="the-data-intensive-research-workflow" class="level3">
<h3 class="anchored" data-anchor-id="the-data-intensive-research-workflow">The Data-Intensive Research Workflow</h3>
<p>The diagram shown above illustrates a Learning Analytics framework called the Data-Intensive Research workflow and comes from the excellent book, Learning Analytics Goes to School <span class="citation" data-cites="krumm2018">(<a href="#ref-krumm2018" role="doc-biblioref">Krumm, Means, and Bienkowski 2018</a>)</span><em>.</em> You can check that out later, but don’t feel any need to dive deep into it for now - we spend more time unpacking this framework in our <a href="https://laser-institute.github.io/laser-website/curriculum-la-workflow.html">Learning Analytics Workflow Modules</a>; just know that this case study and all of the case studies in our <a href="https://laser-institute.github.io/laser-website/curriculum-design.html#modules-topics">LASER curriculum modules</a> are organized around the five main components of this workflow.</p>
<p>In this introductory coding case study, we’ll focus on the following tasks specific to each component of the workflow:</p>
<ol type="1">
<li><strong>Prepare</strong>. Understand the research context, software packages, and data collected.</li>
<li><strong>Wrangle</strong>. Select and filter variables and “wrangle” them in a tabular (think spreadsheet!) format.</li>
<li><strong>Explore</strong>. Create some basic summary tables and plots to understand our data better.</li>
<li><strong>Model</strong>. Run a basic model - specifically, a simple regression model.</li>
<li><strong>Communicate</strong>. Create a reproducible report of your work that you can share with others.</li>
</ol>
<p>Now, let’s get started!</p>
</section>
</section>
<section id="prepare" class="level2">
<h2 class="anchored" data-anchor-id="prepare">1. PREPARE</h2>
<p>First and foremost, data-intensive research involves defining and refining a research question and developing an understanding of where your data comes from <span class="citation" data-cites="krumm2018">(<a href="#ref-krumm2018" role="doc-biblioref">Krumm, Means, and Bienkowski 2018</a>)</span>. This part of the process also involves setting up a reproducible research environment so your work can be understood and replicated by other researchers <span class="citation" data-cites="gandrud2021">(<a href="#ref-gandrud2021" role="doc-biblioref">Gandrud 2021</a>)</span>. For now, we’ll focus on just a few parts of this process, diving in much more deeply into these components in later learning modules.</p>
<section id="research-question" class="level3">
<h3 class="anchored" data-anchor-id="research-question">Research Question</h3>
<p>In this case study, we’ll be working with data come from an unpublished research study by LASER team member, <a href="https://joshuamrosenberg.com">Josh Rosenberg</a>, which utilized a number of different data sources to understand high school students’ motivation within the context of online courses.</p>
<p>These data sets and related research questions are explored in much greater detail in other modules, but for the purpose of this case study, our analysis will be driven by the following research question:</p>
<p><em>Is there a relationship between the time students spend on a course (as measured through their learning management system) and their final course grade?</em></p>
</section>
<section id="projects-packages" class="level3">
<h3 class="anchored" data-anchor-id="projects-packages">Projects & Packages 📦</h3>
<p>As highlighted in <a href="https://datascienceineducation.com/c06.html">Chapter 6 of Data Science in Education Using R</a> <span class="citation" data-cites="estrellado2020e">(<a href="#ref-estrellado2020e" role="doc-biblioref">Estrellado et al. 2020</a>)</span>, one of the first steps of every research workflow should be to set up a “Project” within RStudio.</p>
<blockquote class="blockquote">
<p>A <strong>Project</strong> is the home for all of the files, images, reports, and code that are used in any given project.</p>
</blockquote>
<p>We are working in Posit Cloud with an R project <a href="https://github.com/laser-institute/laser-orientation">cloned from GitHub</a>, so a project has already been set up for you as indicated by the <code>.Rproj</code> file in the main directory.</p>
<section id="your-turn-2" class="level4">
<h4 class="anchored" data-anchor-id="your-turn-2">👉 Your Turn ⤵</h4>
<p>Locate the Files tab lower right hand window pane and see if you can find the file named <code>laser-orientation.Rproj</code>.</p>
<p>Since a project already set up for us, we will instead focus on loading the required <strong>packages</strong> we’ll need for analysis.</p>
<blockquote class="blockquote">
<p>Packages, sometimes referred to as libraries, are shareable collections of R code that can contain functions, data, and/or documentation and extend the functionality of R.</p>
</blockquote>
</section>
<section id="pandas" class="level4">
<h4 class="anchored" data-anchor-id="pandas">pandas 📦</h4>
<p><img src="img/pandas.svg" class="img-fluid" style="width:30.0%"></p>
<p>One package that we’ll be using extensively is {pandas}. <a href="https://pandas.pydata.org">Pandas</a> <span class="citation" data-cites="mckinney-proc-scipy-2010">(<a href="#ref-mckinney-proc-scipy-2010" role="doc-biblioref">McKinney 2010</a>)</span> is a powerful and flexible open source data analysis and wrangling tool for Python that is used widely by the data science community.</p>
</section>
<section id="numpy" class="level4">
<h4 class="anchored" data-anchor-id="numpy">NumPy 📦</h4>
<p><img src="img/numpy.png" class="img-fluid" style="width:20.0%"></p>
<p><a href="https://numpy.org">NumPy</a> is a fundamental package for scientific computing with Python and includes a collection of mathematical algorithms and convenience functions. NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more.</p>
</section>
<section id="pyplot" class="level4">
<h4 class="anchored" data-anchor-id="pyplot">Pyplot 📦</h4>
<p><img src="img/matplotlib.png" class="img-fluid" style="width:40.0%"></p>
<p>Pyplot is a module in the {matplotlib) package, a comprehensive library for creating static, animated, and interactive visualizations in Python. <strong><code>pyplot</code></strong> provides a MATLAB-like interface for making plots and is particularly suited for interactive plotting and simple cases of programmatic plot generation.</p>
</section>
<section id="statsmodels" class="level4">
<h4 class="anchored" data-anchor-id="statsmodels">Statsmodels 📦</h4>
<p><img src="img/statsmodels.svg" class="img-fluid" style="width:40.0%"></p>
<p>The <a href="https://www.statsmodels.org/stable/about.html#about-statsmodels">statsmodels</a> package provides classes and functions for the estimation of many different statistical models, as well as for conducting statistical tests, and statistical data exploration. An extensive list of result statistics are available for each estimator. The results are tested against existing statistical packages to ensure that they are correct.</p>
</section>
<section id="scikit-learn" class="level4">
<h4 class="anchored" data-anchor-id="scikit-learn">scikit-learn 📦</h4>
<p>The <a href="https://scikit-learn.org/">scikit-learn</a> package is an open source machine learning library that supports supervised and unsupervised learning. It also provides various tools for model fitting, data preprocessing, model selection, model evaluation, and many other utilities.</p>
</section>
<section id="your-turn-3" class="level4">
<h4 class="anchored" data-anchor-id="your-turn-3">👉 Your Turn ⤵</h4>
<p>Click the arrow to execute the code in the cell below to load the required packages and functions for this case study.</p>
<div id="c6b8c068" class="cell" data-execution_count="2">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> pandas <span class="im">as</span> pd <span class="co"># for data wrangling</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np <span class="co"># for descriptive statistics</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> matplotlib.pyplot <span class="im">as</span> plt <span class="co"># for data visualization</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> statsmodels.api <span class="im">as</span> sm</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> sklearn.linear_model <span class="im">import</span> LinearRegression <span class="co"># for data modeling</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
</section>
<section id="loading-or-reading-in-data" class="level3">
<h3 class="anchored" data-anchor-id="loading-or-reading-in-data">Loading (or reading in) data</h3>
<p>The data we’ll explore in this case study were originally collected for a research study, which utilized a number of different data sources to understand students’ course-related motivation. These courses were designed and taught by instructors through a state-wide online course provider designed to supplement – but not replace – students’ enrollment in their local school.</p>
<p>The data used in this case study has already been “wrangled” quite a bit, but the original datasets included:</p>
<ol type="1">
<li><p>A self-report survey assessing three aspects of students’ motivation</p></li>
<li><p>Log-trace data, such as data output from the learning management system (LMS)</p></li>
<li><p>Discussion board data</p></li>
<li><p>Academic achievement data</p></li>
</ol>
<p>To know more, see Chapter 7 of <a href="https://colab.research.google.com/corgiredirector?site=https%3A%2F%2Fdatascienceineducation.com%2Fc07.html%23data-sources"><em>Data Science in Education Using R</em></a> <span class="citation" data-cites="estrellado2020e">(<a href="#ref-estrellado2020e" role="doc-biblioref">Estrellado et al. 2020</a>)</span>.</p>
<section id="your-turn-4" class="level4">
<h4 class="anchored" data-anchor-id="your-turn-4">👉 Your Turn ⤵</h4>
<p>Next, we’ll load our data - specifically, a CSV (comma separated value) text file, the kind that you can export from Microsoft Excel or Google Sheets - into pandas, using the <code>pd.read_csv()</code> function in the next chunk.</p>
<div id="9457d131" class="cell" data-execution_count="3">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co">#read sci-online-classes.csv to sci_data and display the output</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>sci_data <span class="op">=</span> pd.read_csv(<span class="st">"data/sci-online-classes.csv"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Nice work! You should now see a new data “object” named <code>sci_data</code> saved in your Environment pane. Try clicking on it and see what happens!</p>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Important
</div>
</div>
<div class="callout-body-container callout-body">
<p>It’s important to note that by manipulating data with pandas we do <strong>not</strong> change the original file. Instead, the data is stored in memory and can be viewed in our <strong>Environment</strong> pane, and can later be exported and saved as a new file is desired.</p>
</div>
</div>
</section>
<section id="viewing-and-inspecting-data" class="level4">
<h4 class="anchored" data-anchor-id="viewing-and-inspecting-data">Viewing and inspecting data</h4>
<p>Now let’s learn another way to inspect our data.</p>
</section>
<section id="your-turn-5" class="level4">
<h4 class="anchored" data-anchor-id="your-turn-5"><strong>👉 Your Turn ⤵</strong></h4>
<p>Run the next chunk and look at the results of the data frame you “assigned” to the <code>sci_data</code> object in the previous code-chunk:</p>
<div id="af9b6378" class="cell" data-execution_count="4">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>sci_data</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="4">
<div>
<div>
<table class="dataframe table table-sm table-striped small" data-quarto-postprocess="true" data-border="1">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">student_id</th>
<th data-quarto-table-cell-role="th">course_id</th>
<th data-quarto-table-cell-role="th">total_points_possible</th>
<th data-quarto-table-cell-role="th">total_points_earned</th>
<th data-quarto-table-cell-role="th">percentage_earned</th>
<th data-quarto-table-cell-role="th">subject</th>
<th data-quarto-table-cell-role="th">semester</th>
<th data-quarto-table-cell-role="th">section</th>
<th data-quarto-table-cell-role="th">Gradebook_Item</th>
<th data-quarto-table-cell-role="th">Grade_Category</th>
<th data-quarto-table-cell-role="th">...</th>
<th data-quarto-table-cell-role="th">q7</th>
<th data-quarto-table-cell-role="th">q8</th>
<th data-quarto-table-cell-role="th">q9</th>
<th data-quarto-table-cell-role="th">q10</th>
<th data-quarto-table-cell-role="th">TimeSpent</th>
<th data-quarto-table-cell-role="th">TimeSpent_hours</th>
<th data-quarto-table-cell-role="th">TimeSpent_std</th>
<th data-quarto-table-cell-role="th">int</th>
<th data-quarto-table-cell-role="th">pc</th>
<th data-quarto-table-cell-role="th">uv</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td data-quarto-table-cell-role="th">0</td>
<td>43146</td>
<td>FrScA-S216-02</td>
<td>3280</td>
<td>2220</td>
<td>0.676829</td>
<td>FrScA</td>
<td>S216</td>
<td>2</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>5.0</td>
<td>5.0</td>
<td>4.0</td>
<td>5.0</td>
<td>1555.1667</td>
<td>25.919445</td>
<td>-0.180515</td>
<td>5.0</td>
<td>4.5</td>
<td>4.333333</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">1</td>
<td>44638</td>
<td>OcnA-S116-01</td>
<td>3531</td>
<td>2672</td>
<td>0.756726</td>
<td>OcnA</td>
<td>S116</td>
<td>1</td>
<td>ATTEMPTED</td>
<td>NaN</td>
<td>...</td>
<td>4.0</td>
<td>5.0</td>
<td>4.0</td>
<td>4.0</td>
<td>1382.7001</td>
<td>23.045002</td>
<td>-0.307803</td>
<td>4.2</td>
<td>3.5</td>
<td>4.000000</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">2</td>
<td>47448</td>
<td>FrScA-S216-01</td>
<td>2870</td>
<td>1897</td>
<td>0.660976</td>
<td>FrScA</td>
<td>S216</td>
<td>1</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>4.0</td>
<td>5.0</td>
<td>3.0</td>
<td>5.0</td>
<td>860.4335</td>
<td>14.340558</td>
<td>-0.693260</td>
<td>5.0</td>
<td>4.0</td>
<td>3.666667</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">3</td>
<td>47979</td>
<td>OcnA-S216-01</td>
<td>4562</td>
<td>3090</td>
<td>0.677335</td>
<td>OcnA</td>
<td>S216</td>
<td>1</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>4.0</td>
<td>5.0</td>
<td>5.0</td>
<td>5.0</td>
<td>1598.6166</td>
<td>26.643610</td>
<td>-0.148447</td>
<td>5.0</td>
<td>3.5</td>
<td>5.000000</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">4</td>
<td>48797</td>
<td>PhysA-S116-01</td>
<td>2207</td>
<td>1910</td>
<td>0.865428</td>
<td>PhysA</td>
<td>S116</td>
<td>1</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>4.0</td>
<td>4.0</td>
<td>NaN</td>
<td>3.0</td>
<td>1481.8000</td>
<td>24.696667</td>
<td>-0.234663</td>
<td>3.8</td>
<td>3.5</td>
<td>3.500000</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">598</td>
<td>97265</td>
<td>PhysA-S216-01</td>
<td>3101</td>
<td>2078</td>
<td>0.670106</td>
<td>PhysA</td>
<td>S216</td>
<td>1</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>4.0</td>
<td>4.0</td>
<td>4.0</td>
<td>4.0</td>
<td>817.4501</td>
<td>13.624168</td>
<td>-0.724983</td>
<td>3.8</td>
<td>3.5</td>
<td>4.000000</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">599</td>
<td>97272</td>
<td>OcnA-S216-01</td>
<td>2872</td>
<td>1733</td>
<td>0.603412</td>
<td>OcnA</td>
<td>S216</td>
<td>1</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>3.0</td>
<td>5.0</td>
<td>5.0</td>
<td>3.0</td>
<td>1638.4500</td>
<td>27.307500</td>
<td>-0.119048</td>
<td>4.4</td>
<td>3.0</td>
<td>5.000000</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">600</td>
<td>97374</td>
<td>BioA-S216-01</td>
<td>8586</td>
<td>6978</td>
<td>0.812718</td>
<td>BioA</td>
<td>S216</td>
<td>1</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>NaN</td>
<td>NaN</td>
<td>NaN</td>
<td>NaN</td>
<td>470.8000</td>
<td>7.846667</td>
<td>-0.980827</td>
<td>NaN</td>
<td>NaN</td>
<td>NaN</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">601</td>
<td>97386</td>
<td>BioA-S216-01</td>
<td>2761</td>
<td>1937</td>
<td>0.701557</td>
<td>BioA</td>
<td>S216</td>
<td>1</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>3.0</td>
<td>4.0</td>
<td>3.0</td>
<td>3.0</td>
<td>71.0166</td>
<td>1.183610</td>
<td>-1.275885</td>
<td>3.8</td>
<td>3.0</td>
<td>3.666667</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">602</td>
<td>97441</td>
<td>FrScA-S216-02</td>
<td>2607</td>
<td>2205</td>
<td>0.845800</td>
<td>FrScA</td>
<td>S216</td>
<td>2</td>
<td>POINTS EARNED & TOTAL COURSE POINTS</td>
<td>NaN</td>
<td>...</td>
<td>5.0</td>
<td>5.0</td>
<td>2.0</td>
<td>4.0</td>
<td>208.6664</td>
<td>3.477773</td>
<td>-1.174293</td>
<td>4.4</td>
<td>4.0</td>
<td>2.000000</td>
</tr>
</tbody>
</table>
<p>603 rows × 30 columns</p>
</div>
</div>
</div>
</div>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Tip
</div>
</div>
<div class="callout-body-container callout-body">
<p>You can also enlarge this output by clicking the “Show in New Window” button located in the top right corner of the output.</p>
</div>
</div>
</section>
<section id="question-1" class="level4">
<h4 class="anchored" data-anchor-id="question-1">❓Question</h4>
<p>What do you notice about this data set? What do you wonder? Add one or two observations in the space below:</p>
<ul>
<li>YOUR RESPONSE HERE</li>
</ul>
</section>
<section id="data-types" class="level4">
<h4 class="anchored" data-anchor-id="data-types">Data Types</h4>
<p>Now, let’s <strong>examine</strong> our data a little more more systematically. The first step in getting to know your data is to discover the different data types it contains.</p>
<p>There are two general types of data:</p>
<ol type="1">
<li><p><strong>Categorical</strong> data represent categories or groups that are distinct and separable. It usually consists of names, labels, or attributes and is represented by words or symbols.</p></li>
<li><p><strong>Numerical</strong> data represents qualities that can be measured and represented as numbers.</p></li>
</ol>
</section>
<section id="your-turn-6" class="level4">
<h4 class="anchored" data-anchor-id="your-turn-6">👉 Your Turn ⤵</h4>
<p>One way to explore the data types is by using <code>info()</code> function. Complete the following code to take a look at the data types for each column in our <code>sci_data</code> data frame.</p>
<p><strong>Hint</strong>: Type the name of the function after the name of the dataset, using <code>.</code> before and <code>()</code> after it.</p>
<div id="693a6544" class="cell" data-execution_count="5">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>sci_data.info()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code><class 'pandas.core.frame.DataFrame'>
RangeIndex: 603 entries, 0 to 602
Data columns (total 30 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 student_id 603 non-null int64
1 course_id 603 non-null object
2 total_points_possible 603 non-null int64
3 total_points_earned 603 non-null int64
4 percentage_earned 603 non-null float64
5 subject 603 non-null object
6 semester 603 non-null object
7 section 603 non-null int64
8 Gradebook_Item 603 non-null object
9 Grade_Category 0 non-null float64
10 FinalGradeCEMS 573 non-null float64
11 Points_Possible 603 non-null int64
12 Points_Earned 511 non-null float64
13 Gender 603 non-null object
14 q1 480 non-null float64
15 q2 477 non-null float64
16 q3 480 non-null float64
17 q4 478 non-null float64
18 q5 476 non-null float64
19 q6 476 non-null float64
20 q7 474 non-null float64
21 q8 474 non-null float64
22 q9 474 non-null float64
23 q10 474 non-null float64
24 TimeSpent 598 non-null float64
25 TimeSpent_hours 598 non-null float64
26 TimeSpent_std 598 non-null float64
27 int 527 non-null float64
28 pc 528 non-null float64
29 uv 528 non-null float64
dtypes: float64(20), int64(5), object(5)
memory usage: 141.5+ KB</code></pre>
</div>
</div>
<p>Nice work!!</p>
</section>
<section id="question-2" class="level4">
<h4 class="anchored" data-anchor-id="question-2">❓Question</h4>
<p>Which of the columns in our dataset contain categorical and which contain numerical data? Name a few.</p>
<ul>
<li>YOUR RESPONSE HERE</li>
</ul>
<p>Which data types do you see? Which ones are numerical and which are categorical? Name a few.</p>
<ul>
<li>YOUR RESPONSE HERE</li>
</ul>
<p>If you look at “Grade_category”, you will notice that all values are NaNs or missing values which means we do not have any information about this variable (or parameter).</p>
<p>What other columns do you think have missing values? Why do you think so?</p>
<ul>
<li>YOUR RESPONSE HERE</li>
</ul>
</section>
</section>
</section>
<section id="wrangle" class="level2">
<h2 class="anchored" data-anchor-id="wrangle">2. WRANGLE</h2>
<p>By wrangle, we refer to the process of cleaning and processing data, and, in some cases, merging (or joining) data from multiple sources. Often, this part of the process is very (surprisingly) time-intensive! Wrangling your data into shape can itself be an important accomplishment! And documenting your code using Python scripts or Quarto files will save yourself and others a great deal of time wrangling data in the future!</p>
<section id="selecting-variables" class="level3">
<h3 class="anchored" data-anchor-id="selecting-variables">Selecting variables</h3>
<p>Recall from our Prepare section that we are interested the relationship between the time students spend on a course and their final course grade. Let’s practice selecting these variables!</p>
<section id="your-turn-7" class="level4">
<h4 class="anchored" data-anchor-id="your-turn-7">👉 Your Turn ⤵</h4>
<p>Run the following code chunk using <code>sci_data[[]]</code> and the names of the columns:</p>
<ul>
<li><p><code>FinalGradeCEMS</code> (i.e., students’ final grades on a 0-100 point scale)</p></li>
<li><p><code>TimeSpent</code> (i.e., the number of minutes they spent in the course’s learning management system)</p></li>
</ul>
<div id="99460a63" class="cell" data-execution_count="6">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>sci_data[[<span class="st">'FinalGradeCEMS'</span>,<span class="st">'TimeSpent'</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="6">
<div>
<div>
<table class="dataframe table table-sm table-striped small" data-quarto-postprocess="true" data-border="1">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">FinalGradeCEMS</th>
<th data-quarto-table-cell-role="th">TimeSpent</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td data-quarto-table-cell-role="th">0</td>
<td>93.453725</td>
<td>1555.1667</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">1</td>
<td>81.701843</td>
<td>1382.7001</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">2</td>
<td>88.487585</td>
<td>860.4335</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">3</td>
<td>81.852596</td>
<td>1598.6166</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">4</td>
<td>84.000000</td>
<td>1481.8000</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">...</td>
<td>...</td>
<td>...</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">598</td>
<td>84.569444</td>
<td>817.4501</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">599</td>
<td>84.239532</td>
<td>1638.4500</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">600</td>
<td>12.352941</td>
<td>470.8000</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">601</td>
<td>54.158289</td>
<td>71.0166</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">602</td>
<td>23.137698</td>
<td>208.6664</td>
</tr>
</tbody>
</table>
<p>603 rows × 2 columns</p>
</div>
</div>
</div>
</div>
<p>Notice how the number of columns (variables) is now different!</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>It’s important to note that since we haven’t “assigned” this filtered data frame to a new object using the <code><-</code> assignment operator, the number of variables in the <code>sci_data</code> data frame in our environment is still 30, not 2.</p>
</div>
</div>
<p>Let’s <em>include one additional variable</em> that you think might be a predictor of students’ final course grade or useful in addressing our research question.</p>
<p>First, we need to figure out what variables exist in our dataset (or be reminded of this - it’s very common in Python to be continually checking and inspecting your data)!</p>
<p>Recall that you can use a function named <code>info()</code> to do this.</p>
<div id="cc12a6b5" class="cell" data-execution_count="7">
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>sci_data.info()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code><class 'pandas.core.frame.DataFrame'>
RangeIndex: 603 entries, 0 to 602
Data columns (total 30 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 student_id 603 non-null int64
1 course_id 603 non-null object
2 total_points_possible 603 non-null int64
3 total_points_earned 603 non-null int64
4 percentage_earned 603 non-null float64
5 subject 603 non-null object
6 semester 603 non-null object
7 section 603 non-null int64
8 Gradebook_Item 603 non-null object
9 Grade_Category 0 non-null float64
10 FinalGradeCEMS 573 non-null float64
11 Points_Possible 603 non-null int64
12 Points_Earned 511 non-null float64
13 Gender 603 non-null object
14 q1 480 non-null float64
15 q2 477 non-null float64
16 q3 480 non-null float64
17 q4 478 non-null float64
18 q5 476 non-null float64
19 q6 476 non-null float64
20 q7 474 non-null float64
21 q8 474 non-null float64
22 q9 474 non-null float64
23 q10 474 non-null float64
24 TimeSpent 598 non-null float64
25 TimeSpent_hours 598 non-null float64
26 TimeSpent_std 598 non-null float64
27 int 527 non-null float64
28 pc 528 non-null float64
29 uv 528 non-null float64
dtypes: float64(20), int64(5), object(5)
memory usage: 141.5+ KB</code></pre>
</div>
</div>
</section>
<section id="your-turn-8" class="level4">
<h4 class="anchored" data-anchor-id="your-turn-8">👉 Your Turn ⤵</h4>
<p>In the code chunk below, add a new variable, being careful to type the new variable name as it appears in the data. We’ve added some code to get you started. Consider how the names of the other variables are separated as you think about how to add an additional variable to this code.</p>
<div id="177d5bd5" class="cell" data-execution_count="8">