-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5-Student-performance-level.html
868 lines (814 loc) · 68.2 KB
/
5-Student-performance-level.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
<!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-0.9.464">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>kaggle - 5 学生成绩水平分类</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
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 { } /* 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 { } /* 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 id="quarto-search-options" type="application/json">{
"location": "sidebar",
"copy-button": false,
"collapse-after": 3,
"panel-placement": "start",
"type": "textbox",
"limit": 20,
"language": {
"search-no-results-text": "No results",
"search-matching-documents-text": "matching documents",
"search-copy-link-title": "Copy link to search",
"search-hide-matches-text": "Hide additional matches",
"search-more-match-text": "more match in this document",
"search-more-matches-text": "more matches in this document",
"search-clear-button-title": "Clear",
"search-detached-cancel-button-title": "Cancel",
"search-submit-button-title": "Submit"
}
}</script>
<script src="site_libs\quarto-nav\quarto-nav.js"></script><script src="site_libs\quarto-nav\headroom.min.js"></script><script src="site_libs\clipboard\clipboard.min.js"></script><script src="site_libs\quarto-search\autocomplete.umd.js"></script><script src="site_libs\quarto-search\fuse.min.js"></script><script src="site_libs\quarto-search\quarto-search.js"></script><meta name="quarto:offset" content="./"><link href="/6-mass-shoot.html" rel="next"><link href="/4-creditcard.html" rel="prev"><script src="site_libs\quarto-html\quarto.js"></script><script src="site_libs\quarto-html\popper.min.js"></script><script src="site_libs\quarto-html\tippy.umd.min.js"></script><script src="site_libs\quarto-html\anchor.min.js"></script><link href="site_libs\quarto-html\tippy.css" rel="stylesheet"><link href="site_libs\quarto-html\quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles"><script src="site_libs\bootstrap\bootstrap.min.js"></script><link href="site_libs\bootstrap\bootstrap-icons.css" rel="stylesheet"><link href="site_libs\bootstrap\bootstrap.min.css" rel="stylesheet"></head>
<body class="nav-sidebar floating">
<div id="quarto-search-results"></div>
<header id="quarto-header" class="headroom fixed-top">
<nav class="quarto-secondary-nav" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<div class="container-fluid d-flex justify-content-between">
<h1 class="quarto-secondary-nav-title"><span class="chapter-number">5</span> <span class="chapter-title">学生成绩水平分类</span></h1>
<button type="button" class="quarto-btn-toggle btn" aria-label="Show secondary navigation">
<i class="bi bi-chevron-right"></i>
</button>
</div>
</nav>
</header>
<!-- content -->
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
<!-- sidebar -->
<nav id="quarto-sidebar" class="sidebar collapse sidebar-navigation floating overflow-auto">
<div class="pt-lg-2 mt-2 text-left sidebar-header">
<div class="sidebar-title mb-0 py-0">
<a href="./">kaggle</a>
</div>
</div>
<div class="mt-2 flex-shrink-0 align-items-center">
<div class="sidebar-search">
<div id="quarto-search" class="" title="Search"></div>
</div>
</div>
<div class="sidebar-menu-container">
<ul class="list-unstyled mt-1">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./index.html" class="sidebar-item-text sidebar-link">简介</a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./1-vgsales.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">1</span> <span class="chapter-title">Video Games Sales</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./2-Olympic-history.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">2</span> <span class="chapter-title">Olympic history</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./3-HR-comma-sep.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">3</span> <span class="chapter-title">员工离职分析</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./4-creditcard.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">4</span> <span class="chapter-title">信用卡欺诈识别</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./5-Student-performance-level.html" class="sidebar-item-text sidebar-link active"><span class="chapter-number">5</span> <span class="chapter-title">学生成绩水平分类</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./6-mass-shoot.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">6</span> <span class="chapter-title">美国大规模枪击案</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./7-hotel-demond.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">7</span> <span class="chapter-title">酒店房间预定预测</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./9990-references.html" class="sidebar-item-text sidebar-link">参考文献</a>
</div>
</li>
</ul>
</div>
</nav>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#sec:data-intro-edu" id="toc-sec:data-intro-edu" class="nav-link active" data-scroll-target="#sec\:data-intro-edu"> <span class="header-section-number">5.1</span> 数据变量说明</a></li>
<li><a href="#sec:descriptive-analysis" id="toc-sec:descriptive-analysis" class="nav-link" data-scroll-target="#sec\:descriptive-analysis"> <span class="header-section-number">5.2</span> 描述性分析</a>
<ul class="collapse">
<li><a href="#封装绘图函数" id="toc-封装绘图函数" class="nav-link" data-scroll-target="#封装绘图函数"> <span class="header-section-number">5.2.1</span> 封装绘图函数</a></li>
<li><a href="#不同教育程度的学生选择课程主题" id="toc-不同教育程度的学生选择课程主题" class="nav-link" data-scroll-target="#不同教育程度的学生选择课程主题"> <span class="header-section-number">5.2.2</span> 不同教育程度的学生选择课程主题</a></li>
<li><a href="#不同课程主题监护人情况" id="toc-不同课程主题监护人情况" class="nav-link" data-scroll-target="#不同课程主题监护人情况"> <span class="header-section-number">5.2.3</span> 不同课程主题监护人情况</a></li>
<li><a href="#不同课程学生学习成绩" id="toc-不同课程学生学习成绩" class="nav-link" data-scroll-target="#不同课程学生学习成绩"> <span class="header-section-number">5.2.4</span> 不同课程学生学习成绩</a></li>
<li><a href="#不同教室学生成绩水平" id="toc-不同教室学生成绩水平" class="nav-link" data-scroll-target="#不同教室学生成绩水平"> <span class="header-section-number">5.2.5</span> 不同教室学生成绩水平</a></li>
<li><a href="#不同学期不同成绩水平与监护人的关系" id="toc-不同学期不同成绩水平与监护人的关系" class="nav-link" data-scroll-target="#不同学期不同成绩水平与监护人的关系"> <span class="header-section-number">5.2.6</span> 不同学期、不同成绩水平与监护人的关系</a></li>
<li><a href="#家长是否回答调查问卷成绩水平与家长对学校是否满意的关系" id="toc-家长是否回答调查问卷成绩水平与家长对学校是否满意的关系" class="nav-link" data-scroll-target="#家长是否回答调查问卷成绩水平与家长对学校是否满意的关系"> <span class="header-section-number">5.2.7</span> 家长是否回答调查问卷、成绩水平与家长对学校是否满意的关系</a></li>
<li><a href="#性别逃课次数与学生成绩水平的关系" id="toc-性别逃课次数与学生成绩水平的关系" class="nav-link" data-scroll-target="#性别逃课次数与学生成绩水平的关系"> <span class="header-section-number">5.2.8</span> 性别、逃课次数与学生成绩水平的关系</a></li>
<li><a href="#举手次数和参加讨论次数与成绩水平关系" id="toc-举手次数和参加讨论次数与成绩水平关系" class="nav-link" data-scroll-target="#举手次数和参加讨论次数与成绩水平关系"> <span class="header-section-number">5.2.9</span> 举手次数和参加讨论次数与成绩水平关系</a></li>
</ul></li>
<li><a href="#模型建立" id="toc-模型建立" class="nav-link" data-scroll-target="#模型建立"> <span class="header-section-number">5.3</span> 模型建立</a>
<ul class="collapse">
<li><a href="#回归树模型建立" id="toc-回归树模型建立" class="nav-link" data-scroll-target="#回归树模型建立"> <span class="header-section-number">5.3.1</span> 回归树模型建立</a></li>
<li><a href="#随机数模型" id="toc-随机数模型" class="nav-link" data-scroll-target="#随机数模型"> <span class="header-section-number">5.3.2</span> 随机数模型</a></li>
<li><a href="#svm建模-支持向量机需要再研究" id="toc-svm建模-支持向量机需要再研究" class="nav-link" data-scroll-target="#svm建模-支持向量机需要再研究"> <span class="header-section-number">5.3.3</span> SVM建模-支持向量机(需要再研究)</a></li>
<li><a href="#模型融合" id="toc-模型融合" class="nav-link" data-scroll-target="#模型融合"> <span class="header-section-number">5.3.4</span> 模型融合</a></li>
</ul></li>
</ul>
</nav>
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title"><span id="scoreClass" class="quarto-section-identifier d-none d-lg-block"><span class="chapter-number">5</span> <span class="chapter-title">学生成绩水平分类</span></span></h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<section id="sec:data-intro-edu" class="level2" data-number="5.1">
<h2 data-number="5.1" class="anchored" data-anchor-id="sec:data-intro-edu"><span class="header-section-number">5.1</span> 数据变量说明</h2>
<p><a href="https://www.kaggle.com/aljarah/xAPI-Edu-Data">变量说明</a>。</p>
<p>变量中最重要的的为<code>Class</code>学生等级变量,是我们建模的目标变量。</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>edudata <span class="ot"><-</span> <span class="fu">read_csv</span>(<span class="st">"data/xAPI-Edu-Data.csv"</span>)</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>edudata<span class="sc">$</span>Class <span class="ot"><-</span> <span class="fu">factor</span>(edudata<span class="sc">$</span>Class, <span class="at">levels =</span> <span class="fu">c</span>(<span class="st">"H"</span>, <span class="st">"M"</span>, <span class="st">"L"</span>))</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>edudata<span class="sc">$</span>gender <span class="ot"><-</span> <span class="fu">factor</span>(edudata<span class="sc">$</span>gender, <span class="at">levels =</span> <span class="fu">c</span>(<span class="st">"M"</span>, <span class="st">"F"</span>))</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="fu">str</span>(edudata)</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>spec_tbl_df [480 × 17] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
$ gender : Factor w/ 2 levels "M","F": 1 1 1 1 1 2 1 1 2 2 ...
$ NationalITy : chr [1:480] "KW" "KW" "KW" "KW" ...
$ PlaceofBirth : chr [1:480] "KuwaIT" "KuwaIT" "KuwaIT" "KuwaIT" ...
$ StageID : chr [1:480] "lowerlevel" "lowerlevel" "lowerlevel" "lowerlevel" ...
$ GradeID : chr [1:480] "G-04" "G-04" "G-04" "G-04" ...
$ SectionID : chr [1:480] "A" "A" "A" "A" ...
$ Topic : chr [1:480] "IT" "IT" "IT" "IT" ...
$ Semester : chr [1:480] "F" "F" "F" "F" ...
$ Relation : chr [1:480] "Father" "Father" "Father" "Father" ...
$ raisedhands : num [1:480] 15 20 10 30 40 42 35 50 12 70 ...
$ VisITedResources : num [1:480] 16 20 7 25 50 30 12 10 21 80 ...
$ AnnouncementsView : num [1:480] 2 3 0 5 12 13 0 15 16 25 ...
$ Discussion : num [1:480] 20 25 30 35 50 70 17 22 50 70 ...
$ ParentAnsweringSurvey : chr [1:480] "Yes" "Yes" "No" "No" ...
$ ParentschoolSatisfaction: chr [1:480] "Good" "Good" "Bad" "Bad" ...
$ StudentAbsenceDays : chr [1:480] "Under-7" "Under-7" "Above-7" "Above-7" ...
$ Class : Factor w/ 3 levels "H","M","L": 2 2 3 3 2 2 3 2 2 2 ...
- attr(*, "spec")=
.. cols(
.. gender = col_character(),
.. NationalITy = col_character(),
.. PlaceofBirth = col_character(),
.. StageID = col_character(),
.. GradeID = col_character(),
.. SectionID = col_character(),
.. Topic = col_character(),
.. Semester = col_character(),
.. Relation = col_character(),
.. raisedhands = col_double(),
.. VisITedResources = col_double(),
.. AnnouncementsView = col_double(),
.. Discussion = col_double(),
.. ParentAnsweringSurvey = col_character(),
.. ParentschoolSatisfaction = col_character(),
.. StudentAbsenceDays = col_character(),
.. Class = col_character()
.. )
- attr(*, "problems")=<externalptr> </code></pre>
</div>
</div>
</section>
<section id="sec:descriptive-analysis" class="level2" data-number="5.2">
<h2 data-number="5.2" class="anchored" data-anchor-id="sec:descriptive-analysis"><span class="header-section-number">5.2</span> 描述性分析</h2>
<section id="封装绘图函数" class="level3" data-number="5.2.1">
<h3 data-number="5.2.1" class="anchored" data-anchor-id="封装绘图函数"><span class="header-section-number">5.2.1</span> 封装绘图函数</h3>
<div class="cell">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>fun_bar <span class="ot"><-</span> <span class="cf">function</span>(data, xlab, fillc, pos, xname, yname, legend){</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> data <span class="sc">%>%</span> </span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>({{xlab}}) <span class="sc">%>%</span> <span class="co"># dplyr中的自定函数参数需要使用{{}}括起来</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">count =</span> <span class="fu">n</span>()) <span class="sc">%>%</span> </span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="fu">reorder</span>({{xlab}}, count), count, <span class="at">fill =</span> {{fillc}})) <span class="sc">+</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="at">position =</span> pos) <span class="sc">+</span> <span class="co">#pos = "stack" or "fill"</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x =</span> xname, <span class="at">y =</span> yname) <span class="sc">+</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">coord_flip</span>() <span class="sc">+</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>() <span class="sc">+</span></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">guides</span>(<span class="at">fill =</span> <span class="fu">guide_legend</span>(<span class="at">title =</span> legend))</span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="不同教育程度的学生选择课程主题" class="level3" data-number="5.2.2">
<h3 data-number="5.2.2" class="anchored" data-anchor-id="不同教育程度的学生选择课程主题"><span class="header-section-number">5.2.2</span> 不同教育程度的学生选择课程主题</h3>
<div class="cell">
<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>p1 <span class="ot"><-</span> <span class="fu">fun_bar</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> Topic, <span class="at">fillc =</span> StageID,</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"stack"</span>, <span class="at">xname =</span> <span class="st">"Topic"</span>, <span class="at">yname =</span> <span class="st">"Student_Count"</span>,</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"教育程度"</span>)</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a>p2 <span class="ot"><-</span> <span class="fu">fun_bar</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> Topic, <span class="at">fillc =</span> StageID,</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"fill"</span>, <span class="at">xname =</span> <span class="st">"Topic"</span>, <span class="at">yname =</span> <span class="st">"Per_Student_Count"</span>,</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"教育程度"</span>)</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a>p1<span class="sc">/</span>p2</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="5-Student-performance-level_files/figure-html/school-level-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption">不同教育程度的学生选择课程主题</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>由图@ref(fig:school-level)可以看出:</p>
<ul>
<li><p>课程主题最多的为IT、French和Arabic,其中选择IT的课程主题的学员远高于其他课。</p></li>
<li><p>无论哪种教育程度,IT、Science、Math和English四种课程都是必修的(三种颜色都有)。</p></li>
</ul>
</section>
<section id="不同课程主题监护人情况" class="level3" data-number="5.2.3">
<h3 data-number="5.2.3" class="anchored" data-anchor-id="不同课程主题监护人情况"><span class="header-section-number">5.2.3</span> 不同课程主题监护人情况</h3>
<p>这部分主要针对家长的情况进行分析,了解父母对学员学习的不同情况。对应在数据集中的变量为<code>Relation</code>。</p>
<div class="cell">
<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>p3 <span class="ot"><-</span> <span class="fu">fun_bar</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> Topic, <span class="at">fillc =</span> Relation,</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"stack"</span>, <span class="at">xname =</span> <span class="st">"Topic"</span>, <span class="at">yname =</span> <span class="st">"Student_count"</span>,</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"监护人情况"</span>)</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>p4 <span class="ot"><-</span> <span class="fu">fun_bar</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> Topic, <span class="at">fillc =</span> Relation,</span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"fill"</span>, <span class="at">xname =</span> <span class="st">"Topic"</span>, <span class="at">yname =</span> <span class="st">"Student_count"</span>,</span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"监护人情况"</span>)</span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a>p3<span class="sc">/</span>p4</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="5-Student-performance-level_files/figure-html/relation-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption">不同课程主题监护人情况</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>由图@ref(fig:relation)可以看出:</p>
<ul>
<li><p>总体而言,监护人为父亲的较多。其中,IT和Math课程中,负责人为父亲的超过75%。</p></li>
<li><p>French课程,监护人大多数为母亲,占70%左右。</p></li>
</ul>
</section>
<section id="不同课程学生学习成绩" class="level3" data-number="5.2.4">
<h3 data-number="5.2.4" class="anchored" data-anchor-id="不同课程学生学习成绩"><span class="header-section-number">5.2.4</span> 不同课程学生学习成绩</h3>
<div class="cell">
<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>p5 <span class="ot"><-</span> <span class="fu">fun_bar</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> Topic, <span class="at">fillc =</span> Class,</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"stack"</span>, <span class="at">xname =</span> <span class="st">"Topic"</span>, <span class="at">yname =</span> <span class="st">"Student_count"</span>,</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"学生成绩"</span>)</span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>p6 <span class="ot"><-</span> <span class="fu">fun_bar</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> Topic, <span class="at">fillc =</span> Class,</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"fill"</span>, <span class="at">xname =</span> <span class="st">"Topic"</span>, <span class="at">yname =</span> <span class="st">"Student_count"</span>,</span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"学生成绩"</span>)</span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>p5<span class="sc">/</span>p6</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="5-Student-performance-level_files/figure-html/class-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption">不同课程学生学习成绩</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>由图@ref(fig:class):</p>
<ul>
<li><p>所有课程中,只有Biology课程中,属于高水平的学生数超过了50%。</p></li>
<li><p>在Geology课程中,没有低水平的学生。</p></li>
</ul>
</section>
<section id="不同教室学生成绩水平" class="level3" data-number="5.2.5">
<h3 data-number="5.2.5" class="anchored" data-anchor-id="不同教室学生成绩水平"><span class="header-section-number">5.2.5</span> 不同教室学生成绩水平</h3>
<div class="cell">
<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>p7 <span class="ot"><-</span> <span class="fu">fun_bar</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> SectionID, <span class="at">fillc =</span> Class,</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"stack"</span>, <span class="at">xname =</span> <span class="st">"Section_ID"</span>, <span class="at">yname =</span> <span class="st">"Student_count"</span>,</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"学生成绩"</span>)</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a>p8 <span class="ot"><-</span> <span class="fu">fun_bar</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> SectionID, <span class="at">fillc =</span> Class,</span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"fill"</span>, <span class="at">xname =</span> <span class="st">"Section_ID"</span>, <span class="at">yname =</span> <span class="st">"Student_count"</span>,</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"学生成绩"</span>)</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a>p7<span class="sc">/</span>p8</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="5-Student-performance-level_files/figure-html/score-section-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption">不同教室学生成绩水平</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>由图@ref(fig:score-section)可以看出:</p>
<ul>
<li><p>在A班的学生最多,C班的学生最少。</p></li>
<li><p>C班的低水平成绩的学生相对较多,其它两个班级的成绩水平基本一致。</p></li>
</ul>
</section>
<section id="不同学期不同成绩水平与监护人的关系" class="level3" data-number="5.2.6">
<h3 data-number="5.2.6" class="anchored" data-anchor-id="不同学期不同成绩水平与监护人的关系"><span class="header-section-number">5.2.6</span> 不同学期、不同成绩水平与监护人的关系</h3>
<div class="cell">
<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><span class="co"># 封装函数,去掉坐标轴翻转</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>fun_bar2 <span class="ot"><-</span> <span class="cf">function</span>(data, xlab, fillc, pos, xname, yname, legend){</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> data <span class="sc">%>%</span> </span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>({{xlab}}) <span class="sc">%>%</span> <span class="co"># dplyr中的自定函数参数需要使用{{}}括起来</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">count =</span> <span class="fu">n</span>()) <span class="sc">%>%</span> </span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="fu">reorder</span>({{xlab}}, count), count, <span class="at">fill =</span> {{fillc}})) <span class="sc">+</span></span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_col</span>(<span class="at">position =</span> pos) <span class="sc">+</span> <span class="co">#pos = "stack" or "fill"</span></span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x =</span> xname, <span class="at">y =</span> yname) <span class="sc">+</span></span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>() <span class="sc">+</span></span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">guides</span>(<span class="at">fill =</span> <span class="fu">guide_legend</span>(<span class="at">title =</span> legend))</span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell">
<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>p9 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, Semester, Relation, <span class="at">pos =</span> <span class="st">"stack"</span>,</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="at">xname =</span> <span class="st">"Semester"</span>, <span class="at">yname =</span> <span class="st">"Student_count"</span>,</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"监护人情况"</span>)</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a>p10 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, Semester, Relation, <span class="at">pos =</span> <span class="st">"fill"</span>,</span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="at">xname =</span> <span class="st">"Semester"</span>, <span class="at">yname =</span> <span class="st">"per_Student_count"</span>,</span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"监护人情况"</span>)</span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a>p11 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, Class, Relation, <span class="at">pos =</span> <span class="st">"stack"</span>,</span>
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="at">xname =</span> <span class="st">"Class"</span>, <span class="at">yname =</span> <span class="st">"Student_count"</span>,</span>
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"监护人情况"</span>)</span>
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a>p12 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, Class, Relation, <span class="at">pos =</span> <span class="st">"fill"</span>,</span>
<span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a> <span class="at">xname =</span> <span class="st">"Class"</span>, <span class="at">yname =</span> <span class="st">"per_Student_count"</span>,</span>
<span id="cb9-15"><a href="#cb9-15" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"监护人情况"</span>)</span>
<span id="cb9-16"><a href="#cb9-16" aria-hidden="true" tabindex="-1"></a>(p9<span class="sc">|</span>p10) <span class="sc">/</span> (p11<span class="sc">|</span>p12)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="5-Student-performance-level_files/figure-html/semester-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption">不同学期、不同成绩水平与监护人的关系</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>由图@ref(fig:semester)可知:</p>
<ul>
<li><p>第一学期父亲作为监护人的学生数比第二学期多。</p></li>
<li><p>总体看,成绩水平较高的学生中,监护人为母亲的比较多;其它水平均是父亲较多。</p></li>
</ul>
</section>
<section id="家长是否回答调查问卷成绩水平与家长对学校是否满意的关系" class="level3" data-number="5.2.7">
<h3 data-number="5.2.7" class="anchored" data-anchor-id="家长是否回答调查问卷成绩水平与家长对学校是否满意的关系"><span class="header-section-number">5.2.7</span> 家长是否回答调查问卷、成绩水平与家长对学校是否满意的关系</h3>
<div class="cell">
<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>p13 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, ParentAnsweringSurvey, ParentschoolSatisfaction, </span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"stack"</span>, <span class="at">xname =</span> <span class="st">"ParentAnsweringSurvey"</span>,</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="at">yname =</span> <span class="st">"Student_count"</span>, <span class="at">legend =</span> <span class="st">"是否满意"</span>)</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a>p14 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, ParentAnsweringSurvey, ParentschoolSatisfaction, </span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"fill"</span>, <span class="at">xname =</span> <span class="st">"ParentAnsweringSurvey"</span>,</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a> <span class="at">yname =</span> <span class="st">"Per_Student_count"</span>, <span class="at">legend =</span> <span class="st">"是否满意"</span>)</span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a>p15 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, Class, ParentschoolSatisfaction, </span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"stack"</span>, <span class="at">xname =</span> <span class="st">"Class"</span>,</span>
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a> <span class="at">yname =</span> <span class="st">"Student_count"</span>, <span class="at">legend =</span> <span class="st">"是否满意"</span>)</span>
<span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a>p16 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, Class, ParentschoolSatisfaction, </span>
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"fill"</span>, <span class="at">xname =</span> <span class="st">"Class"</span>,</span>
<span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a> <span class="at">yname =</span> <span class="st">"Per_Student_count"</span>, <span class="at">legend =</span> <span class="st">"是否满意"</span>)</span>
<span id="cb10-14"><a href="#cb10-14" aria-hidden="true" tabindex="-1"></a>(p13<span class="sc">|</span>p14)<span class="sc">/</span>(p15<span class="sc">|</span>p16)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="5-Student-performance-level_files/figure-html/surey-class-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption">家长是否回答调查问卷、成绩水平与家长对学校是否满意的关系</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>由图@ref(fig:surey-class)可以看出:</p>
<ul>
<li><p>有超过一半的家长回答了问卷,其中,回答问卷的家长大部分对学校满意,而未回答问卷的则大部分对学校不满。</p></li>
<li><p>成绩越高,家长对学校越满意。</p></li>
</ul>
</section>
<section id="性别逃课次数与学生成绩水平的关系" class="level3" data-number="5.2.8">
<h3 data-number="5.2.8" class="anchored" data-anchor-id="性别逃课次数与学生成绩水平的关系"><span class="header-section-number">5.2.8</span> 性别、逃课次数与学生成绩水平的关系</h3>
<div class="cell">
<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>p17 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, gender, Class, </span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"stack"</span>, <span class="at">xname =</span> <span class="st">"Gender"</span>,</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="at">yname =</span> <span class="st">"Student_count"</span>, <span class="at">legend =</span> <span class="st">"成绩水平"</span>)</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a>p18 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, gender, Class, </span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"fill"</span>, <span class="at">xname =</span> <span class="st">"Gender"</span>,</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="at">yname =</span> <span class="st">"Per_Student_count"</span>, <span class="at">legend =</span> <span class="st">"成绩水平"</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>p19 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, StudentAbsenceDays, Class, </span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"stack"</span>, <span class="at">xname =</span> <span class="st">"Class"</span>,</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a> <span class="at">yname =</span> <span class="st">"Student_count"</span>, <span class="at">legend =</span> <span class="st">"成绩水平"</span>)</span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a>p20 <span class="ot"><-</span> <span class="fu">fun_bar2</span>(edudata, StudentAbsenceDays, Class, </span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a> <span class="at">pos =</span> <span class="st">"fill"</span>, <span class="at">xname =</span> <span class="st">"Class"</span>,</span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a> <span class="at">yname =</span> <span class="st">"Per_Student_count"</span>, <span class="at">legend =</span> <span class="st">"成绩水平"</span>)</span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a>(p17<span class="sc">|</span>p18)<span class="sc">/</span>(p19<span class="sc">|</span>p20)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="5-Student-performance-level_files/figure-html/gender-absence-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption">性别、逃课次数与学生成绩水平的关系</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>由图@ref(fig:gender-absence)可知:</p>
<ul>
<li><p>女生比男生数量少很多,但高水平成绩的人数明显比男生多;中水平成绩男女比例基本持平。</p></li>
<li><p>逃课超过7天的的学生基本无法取得好的成绩。</p></li>
</ul>
</section>
<section id="举手次数和参加讨论次数与成绩水平关系" class="level3" data-number="5.2.9">
<h3 data-number="5.2.9" class="anchored" data-anchor-id="举手次数和参加讨论次数与成绩水平关系"><span class="header-section-number">5.2.9</span> 举手次数和参加讨论次数与成绩水平关系</h3>
<div class="cell">
<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>fun_bar3 <span class="ot"><-</span> <span class="cf">function</span>(data, xlab, ylab, fillc, xname, yname){</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> data <span class="sc">%>%</span> </span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>({{xlab}}) <span class="sc">%>%</span> </span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">Mcount =</span> <span class="fu">mean</span>({{ylab}})) <span class="sc">%>%</span> </span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>({{xlab}}, Mcount, <span class="at">fill =</span> {{fillc}})) <span class="sc">+</span></span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_col</span>() <span class="sc">+</span> </span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x =</span> xname, <span class="at">y =</span> yname) <span class="sc">+</span></span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>() <span class="sc">+</span></span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">legend.position =</span> <span class="st">"none"</span>)</span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell">
<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><span class="co"># edudata$Class <- factor(edudata$Class, c("H", "M", "L"), ordered = TRUE)</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>p21 <span class="ot"><-</span> <span class="fu">fun_bar3</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> Class, <span class="at">ylab =</span> raisedhands, </span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a> <span class="at">fillc =</span> Class, <span class="st">"成绩水平"</span>, <span class="st">"平均举手次数"</span> )</span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a>p22 <span class="ot"><-</span> <span class="fu">fun_bar3</span>(<span class="at">data =</span> edudata, <span class="at">xlab =</span> Class, <span class="at">ylab =</span> Discussion, </span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a> <span class="at">fillc =</span> Class, <span class="st">"成绩水平"</span>, <span class="st">"平均参与讨论次数"</span> )</span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a>p21<span class="sc">|</span>p22</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="5-Student-performance-level_files/figure-html/raisedhands-discuss-1.png" class="img-fluid figure-img" width="672"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption">举手次数和参加讨论次数与成绩水平关系</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>由图@ref(fig:raisedhands-discuss)可知: 举手次数和参与讨论次数越多,成绩水平越高。</p>
<hr>
</section>
</section>
<section id="模型建立" class="level2" data-number="5.3">
<h2 data-number="5.3" class="anchored" data-anchor-id="模型建立"><span class="header-section-number">5.3</span> 模型建立</h2>
<section id="回归树模型建立" class="level3" data-number="5.3.1">
<h3 data-number="5.3.1" class="anchored" data-anchor-id="回归树模型建立"><span class="header-section-number">5.3.1</span> 回归树模型建立</h3>
<div class="cell">
<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><span class="fu">set.seed</span>(<span class="dv">1234</span>)</span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="co"># 按照数据目标8:2进行分层抽样,返回矩阵形式的抽样索引</span></span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a>index <span class="ot"><-</span> <span class="fu">createDataPartition</span>(edudata<span class="sc">$</span>Class, <span class="at">p =</span> <span class="fl">0.8</span>, <span class="at">list =</span> F)</span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a>train <span class="ot"><-</span> edudata[index, ]</span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a>test <span class="ot"><-</span> edudata[<span class="sc">-</span>index, ]</span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="co"># 建立回归树模型</span></span>
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a>rpart_model <span class="ot"><-</span> <span class="fu">rpart</span>(Class <span class="sc">~</span>., <span class="at">data =</span> train)</span>
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="co"># type = "class"指定预测结果是具体的某个类别</span></span>
<span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a>pred_rp <span class="ot"><-</span> <span class="fu">predict</span>(rpart_model, test[<span class="sc">-</span><span class="dv">17</span>], <span class="at">type =</span> <span class="st">"class"</span>)</span>
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a><span class="fu">confusionMatrix</span>(pred_rp, test<span class="sc">$</span>Class)</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>Confusion Matrix and Statistics
Reference
Prediction H M L
H 18 3 0
M 9 29 3
L 1 10 22
Overall Statistics
Accuracy : 0.7263
95% CI : (0.6252, 0.8128)
No Information Rate : 0.4421
P-Value [Acc > NIR] : 1.882e-08
Kappa : 0.5806
Mcnemar's Test P-Value : 0.05103
Statistics by Class:
Class: H Class: M Class: L
Sensitivity 0.6429 0.6905 0.8800
Specificity 0.9552 0.7736 0.8429
Pos Pred Value 0.8571 0.7073 0.6667
Neg Pred Value 0.8649 0.7593 0.9516
Prevalence 0.2947 0.4421 0.2632
Detection Rate 0.1895 0.3053 0.2316
Detection Prevalence 0.2211 0.4316 0.3474
Balanced Accuracy 0.7990 0.7320 0.8614</code></pre>
</div>
<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="fu">prp</span>(rpart_model)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="5-Student-performance-level_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid" width="672"></p>
</div>
</div>
</section>
<section id="随机数模型" class="level3" data-number="5.3.2">
<h3 data-number="5.3.2" class="anchored" data-anchor-id="随机数模型"><span class="header-section-number">5.3.2</span> 随机数模型</h3>
<div class="cell">
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">1234</span>)</span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a><span class="co"># importance = T:稍后对变量进行重要性的可视化</span></span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a>rf_model <span class="ot"><-</span> <span class="fu">randomForest</span>(Class<span class="sc">~</span>., <span class="at">data =</span> train, <span class="at">importance =</span> T)</span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a>pred_rf <span class="ot"><-</span> <span class="fu">predict</span>(rf_model, test[<span class="sc">-</span><span class="dv">17</span>], <span class="at">type =</span> <span class="st">"class"</span>)</span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a><span class="fu">confusionMatrix</span>(pred_rf, test<span class="sc">$</span>Class) <span class="co"># 混淆矩阵判断模型准确率</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-stdout">
<pre><code>Confusion Matrix and Statistics
Reference
Prediction H M L
H 20 4 0
M 8 36 4
L 0 2 21
Overall Statistics
Accuracy : 0.8105
95% CI : (0.7172, 0.8837)
No Information Rate : 0.4421
P-Value [Acc > NIR] : 1.886e-13
Kappa : 0.7032
Mcnemar's Test P-Value : NA
Statistics by Class:
Class: H Class: M Class: L
Sensitivity 0.7143 0.8571 0.8400
Specificity 0.9403 0.7736 0.9714
Pos Pred Value 0.8333 0.7500 0.9130
Neg Pred Value 0.8873 0.8723 0.9444
Prevalence 0.2947 0.4421 0.2632
Detection Rate 0.2105 0.3789 0.2211
Detection Prevalence 0.2526 0.5053 0.2421
Balanced Accuracy 0.8273 0.8154 0.9057</code></pre>
</div>
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="fu">varImpPlot</span>(rf_model) <span class="co"># 可视化变量重要性函数</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="5-Student-performance-level_files/figure-html/unnamed-chunk-6-1.png" class="img-fluid" width="672"></p>
</div>
</div>
<p>阅读上图:</p>
<ul>
<li><p>圆点越靠近右侧越重要。</p></li>
<li><p>我们重点观察排名前五的变量。通过左右两图的对比发现,两图中前四个变量相同(交叉),可以判定这四个变量是数据中最重要的变量。</p></li>
</ul>
</section>
<section id="svm建模-支持向量机需要再研究" class="level3" data-number="5.3.3">
<h3 data-number="5.3.3" class="anchored" data-anchor-id="svm建模-支持向量机需要再研究"><span class="header-section-number">5.3.3</span> SVM建模-支持向量机(需要再研究)</h3>
<div class="cell">
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">1234</span>)</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(kernlab) <span class="co"># Kernel-Based Machine Learning Lab</span></span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a>svm_model <span class="ot"><-</span> <span class="fu">ksvm</span>(Class<span class="sc">~</span>., <span class="at">data =</span> test, <span class="at">kernel =</span> <span class="st">"rbfdot"</span>)</span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="co"># type = "response":指定预测结果是具体的某个列别</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a>pred_svm <span class="ot"><-</span> <span class="fu">predict</span>(svm_model, test[<span class="sc">-</span><span class="dv">17</span>], <span class="at">type =</span> <span class="st">"response"</span>)</span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a><span class="fu">confusionMatrix</span>(pred_svm, test<span class="sc">$</span>Class)</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>Confusion Matrix and Statistics
Reference
Prediction H M L
H 23 4 0
M 5 36 1
L 0 2 24
Overall Statistics
Accuracy : 0.8737
95% CI : (0.7897, 0.933)
No Information Rate : 0.4421
P-Value [Acc > NIR] : < 2.2e-16
Kappa : 0.8053
Mcnemar's Test P-Value : NA
Statistics by Class:
Class: H Class: M Class: L
Sensitivity 0.8214 0.8571 0.9600
Specificity 0.9403 0.8868 0.9714
Pos Pred Value 0.8519 0.8571 0.9231
Neg Pred Value 0.9265 0.8868 0.9855
Prevalence 0.2947 0.4421 0.2632
Detection Rate 0.2421 0.3789 0.2526
Detection Prevalence 0.2842 0.4421 0.2737
Balanced Accuracy 0.8809 0.8720 0.9657</code></pre>
</div>
</div>
</section>
<section id="模型融合" class="level3" data-number="5.3.4">
<h3 data-number="5.3.4" class="anchored" data-anchor-id="模型融合"><span class="header-section-number">5.3.4</span> 模型融合</h3>
<p>将各个模型的结果做一个融合(合并至一个数据框)。</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">data.frame</span>(<span class="at">rpart =</span> pred_rp,</span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a> <span class="at">randomForest =</span> pred_rf,</span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a> <span class="at">svm =</span> pred_svm,</span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a> <span class="at">actual_class =</span> test<span class="sc">$</span>Class, </span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a> <span class="at">final_pred =</span> <span class="fu">rep</span>(<span class="st">"-"</span>, <span class="fu">nrow</span>(test)))</span>
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a><span class="fu">head</span>(result)</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> rpart randomForest svm actual_class final_pred
1 M M M M -
2 L L L L -
3 L L L L -
4 M M L M -
5 L L L L -
6 M M M M -</code></pre>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="co"># 封装求众数函数</span></span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a>fun_pred <span class="ot"><-</span> <span class="cf">function</span>(x){</span>
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">names</span>(<span class="fu">which.max</span>(<span class="fu">table</span>(x)))</span>
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb24-5"><a href="#cb24-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb24-6"><a href="#cb24-6" aria-hidden="true" tabindex="-1"></a>result<span class="sc">$</span>final_pred <span class="ot"><-</span> <span class="fu">factor</span>(<span class="fu">apply</span>(result[<span class="dv">1</span><span class="sc">:</span><span class="dv">2</span>], <span class="dv">1</span>, fun_pred))</span>
<span id="cb24-7"><a href="#cb24-7" aria-hidden="true" tabindex="-1"></a><span class="fu">confusionMatrix</span>(result<span class="sc">$</span>actual_class, result<span class="sc">$</span>final_pred)</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>Confusion Matrix and Statistics
Reference
Prediction H L M
H 21 1 6
L 0 23 2
M 7 10 25
Overall Statistics
Accuracy : 0.7263
95% CI : (0.6252, 0.8128)
No Information Rate : 0.3579
P-Value [Acc > NIR] : 3.029e-13
Kappa : 0.5887
Mcnemar's Test P-Value : 0.09327
Statistics by Class:
Class: H Class: L Class: M
Sensitivity 0.7500 0.6765 0.7576
Specificity 0.8955 0.9672 0.7258
Pos Pred Value 0.7500 0.9200 0.5952
Neg Pred Value 0.8955 0.8429 0.8491
Prevalence 0.2947 0.3579 0.3474
Detection Rate 0.2211 0.2421 0.2632
Detection Prevalence 0.2947 0.2632 0.4421
Balanced Accuracy 0.8228 0.8218 0.7417</code></pre>
</div>
<div class="sourceCode cell-code" id="cb26"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="fu">head</span>(result)</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> rpart randomForest svm actual_class final_pred
1 M M M M M
2 L L L L L
3 L L L L L
4 M M L M M
5 L L L L L
6 M M M M M</code></pre>
</div>
</div>
</section>
</section>
</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const clipboard = new window.ClipboardJS('.code-copy-button', {
target: function(trigger) {
return trigger.previousElementSibling;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
setTimeout(function() {
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
function tippyHover(el, contentFn) {
const config = {
allowHTML: true,
content: contentFn,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start'
};
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
let href = ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
return note.innerHTML;
});
}
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const cites = ref.parentNode.getAttribute('data-cites').split(' ');
tippyHover(ref, function() {
var popup = window.document.createElement('div');
cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
});
</script>
<nav class="page-navigation">
<div class="nav-page nav-page-previous">
<a href="./4-creditcard.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">4</span> <span class="chapter-title">信用卡欺诈识别</span></span>
</a>
</div>
<div class="nav-page nav-page-next">
<a href="./6-mass-shoot.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">6</span> <span class="chapter-title">美国大规模枪击案</span></span> <i class="bi bi-arrow-right-short"></i>
</a>
</div>
</nav>
</div> <!-- /content -->
</body></html>