1 Latar Belakang

Data ini mendekati prestasi siswa dalam pendidikan menengah atas (SMA) sekolah Gabriel Pereira dan Mousinho da Silveira di Portugis. Atribut data yang digunakan adalah nilai siswa, fitur terkait berupa demografis, sosial dan sekolah. Data ini dikumpulkan dengan menggunakan laporan sekolah dan kuesioner. Data yang disediakan mengenai kinerja dalam mata pelajaran Matematika. Data dimodelkan dengan regresi linear berganda dengan tujuan untuk memprediksi nilai siswa di masa yang akan datang.

2 Persiapan Data

Data diambil dari https://www.kaggle.com/dipam7/student-grade-prediction

2.1 Packages

Berikut ini beberapa packages di r yang digunakan :

library(devtools)
## Loading required package: usethis
devtools::install_github('EdwinTh/paletti')
## WARNING: Rtools is required to build R packages, but is not currently installed.
## 
## Please download and install Rtools 4.0 from https://cran.r-project.org/bin/windows/Rtools/.
## Skipping install of 'paletti' from a github remote, the SHA1 (27e9a278) has not changed since last install.
##   Use `force = TRUE` to force installation
library(paletti)
library(GGally)
## Loading required package: ggplot2
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(gridExtra)
library(grid)
library(knitr)
library(kableExtra)
library(cowplot)
library(formattable)
## 
## Attaching package: 'formattable'
## The following object is masked from 'package:plotly':
## 
##     style
library(e1071) 
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v tibble  3.0.1     v dplyr   1.0.2
## v tidyr   1.0.3     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## v purrr   0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::combine()    masks gridExtra::combine()
## x dplyr::filter()     masks plotly::filter(), stats::filter()
## x dplyr::group_rows() masks kableExtra::group_rows()
## x dplyr::lag()        masks stats::lag()
list.files(path = "../input")
## character(0)
library(ggplot2)
library(gridExtra)
library(RColorBrewer)
library(scales)
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
## The following objects are masked from 'package:formattable':
## 
##     comma, percent, scientific
options(warn=-1)
library(rpart)
library(rpart.plot)
library(party)
## Loading required package: mvtnorm
## Loading required package: modeltools
## Loading required package: stats4
## Loading required package: strucchange
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## 
## Attaching package: 'strucchange'
## The following object is masked from 'package:stringr':
## 
##     boundary
library(dplyr)
library(caret)
## Loading required package: lattice
## 
## Attaching package: 'caret'
## The following object is masked from 'package:purrr':
## 
##     lift
library(ggcorrplot)
library(ggplot2)

2.2 Import Data

Data ini terdiri dari 395 data dengan 33 variabel

setwd("~/uas")
student<- read.csv('student-mat.csv')
head(student)
##   school sex age address famsize Pstatus Medu Fedu     Mjob     Fjob     reason
## 1     GP   F  18       U     GT3       A    4    4  at_home  teacher     course
## 2     GP   F  17       U     GT3       T    1    1  at_home    other     course
## 3     GP   F  15       U     LE3       T    1    1  at_home    other      other
## 4     GP   F  15       U     GT3       T    4    2   health services       home
## 5     GP   F  16       U     GT3       T    3    3    other    other       home
## 6     GP   M  16       U     LE3       T    4    3 services    other reputation
##   guardian traveltime studytime failures schoolsup famsup paid activities
## 1   mother          2         2        0       yes     no   no         no
## 2   father          1         2        0        no    yes   no         no
## 3   mother          1         2        3       yes     no  yes         no
## 4   mother          1         3        0        no    yes  yes        yes
## 5   father          1         2        0        no    yes  yes         no
## 6   mother          1         2        0        no    yes  yes        yes
##   nursery higher internet romantic famrel freetime goout Dalc Walc health
## 1     yes    yes       no       no      4        3     4    1    1      3
## 2      no    yes      yes       no      5        3     3    1    1      3
## 3     yes    yes      yes       no      4        3     2    2    3      3
## 4     yes    yes      yes      yes      3        2     2    1    1      5
## 5     yes    yes       no       no      4        3     2    1    2      5
## 6     yes    yes      yes       no      5        4     2    1    2      5
##   absences G1 G2 G3
## 1        6  5  6  6
## 2        4  5  5  6
## 3       10  7  8 10
## 4        2 15 14 15
## 5        4  6 10 10
## 6       10 15 15 15
data.frame("total.data" = dim(student)[1],
           "total.variabel" = dim(student)[2])
##   total.data total.variabel
## 1        395             33

2.3 Deskripsi Variabel

Berikut ini deskripsi masing-masing variabel dari dataset ini:

\(sex\) : Jenis kelamin pelajar (binary: female or male)

\(age\) : Umur pelajar (numeric: from 15 to 22)

\(school\) : Sekolah (binary: Gabriel Pereira or Mousinho da Silveira)

\(address\) : Alamat rumah pelajar (binary: urban or rural)

\(Pstatus\) : Tempat tinggal keluarga (binary: living together or apart)

\(Medu\) : Pendidikan Ibu (numeric: from 0 to \(4^a\))

\(Mjob\) : Pekerjaan Ibu

\(Fedu\) : Pendidikan Ayah (numeric: from 0 to \(4^a\))

\(Fjob\) : Pekerjaan Ayah

\(guardian\) : Wali murid (nominal: mother, father or other)

\(famsize\) : Banyak anggota keluarga (binary: ≤ 3 or > 3)

\(famrel\) : Hubungan siswa dengan keluarga (numeric: from 1 – very bad to 5 – excellent)

\(reason\) : Alasan memilih sekolah (nominal: close to home, school reputation, course preference or other)

\(traveltime\) : Waktu perjalanan ke sekolah (numeric: 1 – < 15 min., 2 – 15 to 30 min., 3 – 30 min. to 1 hour or 4 – > 1 hour)

\(studytime\) : Waktu belajar mingguan (numeric: 1 – < 2 hours, 2 – 2 to 5 hours, 3 – 5 to 10 hours or 4 – > 10 hours)

\(failures\) : Jumlah kegagalan kelas sebelumnya (numeric: n if 1 ≤ n < 3, else 4)

\(schoolsup\) : Dukungan sekolah terhadap extra pendidikan (binary: yes or no)

\(famsup\) : Dukungan keluarga terhadap extra pendidikan (binary: yes or no)

\(activities\) : Aktifitas ekstrakulikuler (binary: yes or no)

\(paidclass\) : Kelas berbayar tambahan (binary: yes or no)

\(internet\) : Akses internet di rumah (binary: yes or no)

\(nursery\) : Bersekolah di sekolah pembibitan (binary: yes or no)

\(higher\) : Ingin mengambil pendidikan tinggi (binary: yes or no)

\(romantic\) : Dengan hubungan yang baik (binary: yes or no)

\(freetime\) : Waktu bebas setelah sekolah (numeric: from 1 – very low to 5 – very high)

\(goout\) : Pergi bermain bersama teman (numeric: from 1 – very low to 5 – very high)

\(Walc\) : Konsumsi alkohol di akhir pekan (numeric: from 1 – very low to 5 – very high)

\(Dalc\) : Konsumsi alkohol di hari kerja (numeric: from 1 – very low to 5 – very high)

\(health\) : Status kesehatan saat ini (numeric: from 1 – very bad to 5 – very good)

\(absences\) : Jumlah absen di sekolah (numeric: from 0 to 93)

\(G1\) : Nilai periode pertama (numeric: from 0 to 20)

\(G2\) : Nilai periode kedua (numeric: from 0 to 20)

\(G3\) : Nilai akhir (numeric: from 0 to 20)

3 Pembersihan Data

3.1 Struktur Data

glimpse(student)
## Rows: 395
## Columns: 33
## $ school     <chr> "GP", "GP", "GP", "GP", "GP", "GP", "GP", "GP", "GP", "G...
## $ sex        <chr> "F", "F", "F", "F", "F", "M", "M", "F", "M", "M", "F", "...
## $ age        <int> 18, 17, 15, 15, 16, 16, 16, 17, 15, 15, 15, 15, 15, 15, ...
## $ address    <chr> "U", "U", "U", "U", "U", "U", "U", "U", "U", "U", "U", "...
## $ famsize    <chr> "GT3", "GT3", "LE3", "GT3", "GT3", "LE3", "LE3", "GT3", ...
## $ Pstatus    <chr> "A", "T", "T", "T", "T", "T", "T", "A", "A", "T", "T", "...
## $ Medu       <int> 4, 1, 1, 4, 3, 4, 2, 4, 3, 3, 4, 2, 4, 4, 2, 4, 4, 3, 3,...
## $ Fedu       <int> 4, 1, 1, 2, 3, 3, 2, 4, 2, 4, 4, 1, 4, 3, 2, 4, 4, 3, 2,...
## $ Mjob       <chr> "at_home", "at_home", "at_home", "health", "other", "ser...
## $ Fjob       <chr> "teacher", "other", "other", "services", "other", "other...
## $ reason     <chr> "course", "course", "other", "home", "home", "reputation...
## $ guardian   <chr> "mother", "father", "mother", "mother", "father", "mothe...
## $ traveltime <int> 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 2, 1, 1, 1, 3, 1,...
## $ studytime  <int> 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 1, 2, 3, 1, 3, 2, 1,...
## $ failures   <int> 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,...
## $ schoolsup  <chr> "yes", "no", "yes", "no", "no", "no", "no", "yes", "no",...
## $ famsup     <chr> "no", "yes", "no", "yes", "yes", "yes", "no", "yes", "ye...
## $ paid       <chr> "no", "no", "yes", "yes", "yes", "yes", "no", "no", "yes...
## $ activities <chr> "no", "no", "no", "yes", "no", "yes", "no", "no", "no", ...
## $ nursery    <chr> "yes", "no", "yes", "yes", "yes", "yes", "yes", "yes", "...
## $ higher     <chr> "yes", "yes", "yes", "yes", "yes", "yes", "yes", "yes", ...
## $ internet   <chr> "no", "yes", "yes", "yes", "no", "yes", "yes", "no", "ye...
## $ romantic   <chr> "no", "no", "no", "yes", "no", "no", "no", "no", "no", "...
## $ famrel     <int> 4, 5, 4, 3, 4, 5, 4, 4, 4, 5, 3, 5, 4, 5, 4, 4, 3, 5, 5,...
## $ freetime   <int> 3, 3, 3, 2, 3, 4, 4, 1, 2, 5, 3, 2, 3, 4, 5, 4, 2, 3, 5,...
## $ goout      <int> 4, 3, 2, 2, 2, 2, 4, 4, 2, 1, 3, 2, 3, 3, 2, 4, 3, 2, 5,...
## $ Dalc       <int> 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,...
## $ Walc       <int> 1, 1, 3, 1, 2, 2, 1, 1, 1, 1, 2, 1, 3, 2, 1, 2, 2, 1, 4,...
## $ health     <int> 3, 3, 3, 5, 5, 5, 3, 1, 1, 5, 2, 4, 5, 3, 3, 2, 2, 4, 5,...
## $ absences   <int> 6, 4, 10, 2, 4, 10, 0, 6, 0, 0, 0, 4, 2, 2, 0, 4, 6, 4, ...
## $ G1         <int> 5, 5, 7, 15, 6, 15, 12, 6, 16, 14, 10, 10, 14, 10, 14, 1...
## $ G2         <int> 6, 5, 8, 14, 10, 15, 12, 5, 18, 15, 8, 12, 14, 10, 16, 1...
## $ G3         <int> 6, 6, 10, 15, 10, 15, 11, 6, 19, 15, 9, 12, 14, 11, 16, ...

3.2 Periksa Data Hilang

colSums(is.na(student))
##     school        sex        age    address    famsize    Pstatus       Medu 
##          0          0          0          0          0          0          0 
##       Fedu       Mjob       Fjob     reason   guardian traveltime  studytime 
##          0          0          0          0          0          0          0 
##   failures  schoolsup     famsup       paid activities    nursery     higher 
##          0          0          0          0          0          0          0 
##   internet   romantic     famrel   freetime      goout       Dalc       Walc 
##          0          0          0          0          0          0          0 
##     health   absences         G1         G2         G3 
##          0          0          0          0          0

Tidak terdapat missing value pada dataset ini.

3.3 Data Duplikat

data.frame("jumlah.seluruh.data"=nrow(student),
           "jumlah.data.unik" = nrow(distinct(student)))
##   jumlah.seluruh.data jumlah.data.unik
## 1                 395              395

Tidak terdapat data duplikat pada dataset ini sehingga proses pengolahan data dapat dilanjutkan.

4 Analisis Korelasi Data

ggcorr(student,label = T, size=2, label_size = 3, hjust=0.95)+
  labs(
    title="Matriks Korelasi Data set"
  )+
  theme_minimal()+
  theme(
    plot.title = element_text(hjust = 0.5),
    axis.title=element_text(size=8,face="bold"), 
    axis.text.y=element_blank())

Berdasarkan matriks korelasi dari data diatas, setiap variabel mempunyai pengaruh terhadap Nilai akhir(G3), variabel yang memiliki korelasi palinng tinggi yaitu Medu (pendidikan ibu),Dalc (konsumsi alkohol di hari kerja), G1 (nilai periode pertama), dan G2 (nilai periode kedua).

5 Visualisasi

5.1 Histogram umur

table(student$age)
## 
##  15  16  17  18  19  20  21  22 
##  82 104  98  82  24   3   1   1
var(student$age)
## [1] 1.628285
age= ggplot(aes(x=age), data=student)+
  geom_histogram(binwidth = 0.50, fill='darkred', color='black')+
  ggtitle("Age of students")
age

Dari histogram di atas, tampak bahwa sebagian besar siswa berusia antara 15 dan 18, karena sebagian besar siswa mulai Sekolah Menengah Atas (SMA) pada usia 15 dan lulus usia 18, mengingat fakta bahwa umumnya, Sekolah Menengah Atas (SMA) di seluruh dunia hanya 3 tahun terakhir. Namun ada 29 siswa yang berusia lebih dari 18 tahun.

5.2 Kasus

Apakah kemampuan siswa perempuan lebih baik dari siswa laki-laki? saya akan mengeksplorasi perbedaan jenis kelamin di kelas sehubungan dengan G1 (peringkat periode pertama).

Langkah-langkah yang akan dilakukan antara lain :

  1. periksa jumlah siswa perempuan dan laki-laki di sekolah.

  2. Periksa kinerja di kelas berdasarkan jenis kelamin dan usia dengan menjawab pertanyaan-pertanyaan berikut:

  1. Siapa yang lebih baik di sekolah? Apakah anak perempuan berkinerja lebih baik atau apakah anak laki-laki mendapatkan hasil yang lebih baik daripada anak perempuan?

  2. Apakah kinerja siswa menjadi lebih baik seiring bertambahnya usia?

5.2.1 Histogram jenis kelamin

table(student$sex)
## 
##   F   M 
## 208 187
gender= ggplot(data=student,aes(x=sex,fill=sex))+geom_bar()
gender

Terlihat dari histogram di atas bahwa ada lebih banyak siswa perempuan (208) daripada siswa laki-laki (187).

5.2.2 Histogram Kesehatan

table(student$health)
## 
##   1   2   3   4   5 
##  47  45  91  66 146
health= ggplot(data=student,aes(x=health,fill=sex))+geom_histogram(binwidth=0.5, fill='darkgreen')
health

Terlihat bahwa mayoritas siswa dalam kondisi sehat

5.2.3 Histogram Area Tempat Tinggal

area= ggplot(student, aes(x=address)) +
    geom_bar(fill='orchid')
area

seperti yang terlihat sebagian besar siswa tinggal di daerah perkotaan (urban).

5.2.4 Histogram jenis kelamin dan Umur

var(student$G1)
## [1] 11.01705
ages= ggplot(data=student,aes(x=age, fill=sex))+geom_histogram(binwidth=0.50)
ages

Seperti yang ditunjukkan dengan jelas pada grafik di atas, sebagian besar siswa yang berumur lebih dari 18 adalah siswa laki-laki dan tidak ada siswa perempuan yang berumur lebih dari 20 tahun.

5.3 Kasus

5.3.1 G1 sehubungan dengan jenis kelamin dan usia

G1=ggplot(data=student,aes(x=age, y=G1, col=sex, shape=sex))+geom_point()+geom_smooth(method="lm",se=F)+facet_grid(~sex)
G1
## `geom_smooth()` using formula 'y ~ x'

Kita dapat melihat bahwa kinerja anak perempuan menjadi lebih baik seiring bertambahnya usia, namun, penurunan kinerja anak laki-laki dapat dideteksi dalam grafik di atas. Meta-analisis yang diterbitkan oleh American Psychological Association memeriksa perbedaan jenis sekolah-sekolah di 300 negara dan selama hampir seratus tahun. Dan ternyata anak perempuan telah mendapatkan nilai yang lebih baik daripada anak laki-laki selama beberapa dekade.

5.4 Kasus

Mengapa kinerja siswa laki-laki menurun seiring bertambahnya usia?

Dalam bagian ini, saya akan menentukan berbagai faktor yang mempengaruhi kinerja siswa dengan menjawab pertanyaan-pertanyaan berikut:

  1. Apakah kehadiran penting? Apakah kelas yang kosong berdampak negatif pada kinerja akademik siswa?

  2. Apakah waktu perjalanan berdampak pada kinerja siswa? Apakah siswa yang tinggal di dekat sekolah memiliki hasil yang lebih baik daripada mereka yang tinggal jauh dari sekolah?

5.4.1 Histogram absen

absences= ggplot(data=student,aes(x=absences, y=G1, col=sex))+geom_point()+geom_smooth(method="lm",se=F)+facet_grid(~sex)
absences
## `geom_smooth()` using formula 'y ~ x'

Dari grafik di atas, dapat terlihat bagaimana ketidakhadiran mempengaruhi kinerja anak laki-laki secara negatif, namun kelas yang hilang tidak memiliki dampak negatif pada prestasi anak perempuan di kelas.

5.4.2 Histogram waktu perjalanan

table(student$traveltime)
## 
##   1   2   3   4 
## 257 107  23   8
travel=ggplot(data=student,aes(x=traveltime, y=G1, col=sex))+geom_point()+geom_smooth(method="lm",se=F)+facet_grid(~sex)
travel
## `geom_smooth()` using formula 'y ~ x'

Seperti yang ditunjukkan di atas, dampak negatif dari waktu perjalanan dapat mempengaruhi kinerja siswa laki-laki, semakin jauh jarak rumah siswa laki-laki dengan sekolah, semakin sedikit hasil yang dia dapatkan.

Dari hasil yang di dapat disimpulkan bahwa waktu perjalanan dan kehadiran merupakan faktor utama yang mempengaruhi nilai siswa laki-laki. Namun, selain waktu perjalanan apa saja faktor lain yang be mempengaruhi kinerja siswa?

5.5 Kasus

Ini adalah fakta yang diketahui bahwa perilaku pengasuhan dan dukungan pendidikan dari orang tua untuk anak-anak dapat menumbuhkan kebiasaan belajar anak-anak dan mempengaruhi kinerja akademik. Maka:

  1. Apakah tingkat pendidikan orang tua dan pekerjaan mempengaruhi prestasi anak di sekolah?

  2. Bagaimana ukuran keluarga berkontribusi pada kinerja akademik siswa?

  3. Apakah ada pengaruh antara keberadaan keluarga dengan kinerja siswa?

  4. Bagaimana hubungan keluarga mempengaruhi kinerja akademik mahasiswa?

  5. Bagaimana konsumsi alkohol di hari kerja mempengaruhi prestasi siswa?

  6. Apakah tingkat pendidikan orang tua dan pekerjaan mempengaruhi prestasi anak di sekolah?

5.5.1 Histogram Pekerjaan Orang tua

Motherjob= ggplot(student, aes(x=Mjob)) +
    geom_bar(fill='brown')
Motherjob

Fotherjob= ggplot(student, aes(x=Fjob)) +
    geom_bar(fill='blue')
Fotherjob

### G3 sehubungan dengan Pekerjaan orang tua

ggplot(data=student,aes(x=Fjob, y=G3))+geom_point()+geom_smooth(method="lm",se=F)
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=student,aes(x=Mjob, y=G3))+geom_point()+geom_smooth(method="lm",se=F)
## `geom_smooth()` using formula 'y ~ x'

Dari grafik di atas, kita tidak dapat melihat perbedaan yang jelas dalam kinerja siswa sesuai dengan pekerjaan orang tua.

5.5.2 Histogram Pendidikan Orang Tua

Fedu= ggplot(student, aes(x=Fedu)) +
    geom_bar(fill='grey', color="purple")
Fedu

Medu= ggplot(student, aes(x=Medu)) +
    geom_bar(fill='black', color='black')
Medu

my_graph <- ggplot(student, aes(x = Fedu, y = Medu)) +
    geom_point(aes(color = G1)) +
    stat_smooth(method = "lm",
        col = "#C42126",
        se = FALSE,
        size = 1)
my_graph
## `geom_smooth()` using formula 'y ~ x'

Seperti yang diharapkan, semakin tingkat pendidikan orang tua mempengaruhi skor anak di sekolah. siswa yang orang tuanya memiliki tingkat pendidikan yang lebih tinggi menerapkan disiplin dalam belajar, keyakinan kemampuan yang lebih positif, orientasi kerja yang lebih kuat, dan mereka dapat menggunakan strategi pembelajaran yang lebih efektif daripada anak-anak dari orang tua dengan tingkat pendidikan yang lebih rendah.

5.6 Kasus

Selanjutnya bagaimana ukuran keluarga berkontribusi pada kinerja akademik siswa?

table(student$famsize)
## 
## GT3 LE3 
## 281 114
ggplot(student, aes(x=famsize))+
    geom_bar(fill='salmon',color='black')

Seperti yang ditunjukkan di atas, ada lebih banyak siswa dengan jumlah keluarga lebih besar dari 3 dibandingkan dengan siswa dengan jumlah keluarga kurang dari 3.

5.6.1 GI sehubungan Jumlah Anggota Keluarga

ggplot(data=student,aes(x=famsize, y=G1, col=sex))+geom_point()+geom_smooth(method="lm",se=F)+facet_grid(~sex)
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=student,aes(x=famsize, y=G1, col=sex))+geom_point()+geom_smooth(method="lm",se=F)+facet_grid(~sex) -> g1

Menurut banyak artikel, jumlah anggota keluarga berkontribusi pada kegagalan atau keberhasilan seorang siswa di sekolah, dalam arti bahwa ketika keluarga besar, tidak akan ada konsentrasi yang memadai pada anak oleh orang tua mereka berdasarkan kinerja akademik anak. Namun, menurut grafik di atas, ada sedikit peningkatan dalam kinerja anak perempuan.

5.6.2 Histogram Keberadaan keluarga dengan G1

Apakah ada pengaruh antara keberadaan keluarga dengan kinerja siswa?

table(student$Pstatus)
## 
##   A   T 
##  41 354
ggplot(data=student,aes(x=Pstatus, y=G1, fill=sex))+geom_boxplot()

ggplot(data=student,aes(x=Pstatus, y=G1, fill=sex))+geom_boxplot()-> obj1
obj1+labs(title="G1 with respect to Pstatus", x="G1", fill="sex")

obj1+labs(title="G1 with respect to Pstatus", x="G1", fill="sex")->obj2
obj2+theme(panel.background = element_rect(fill="grey"))-> obj3
obj3+theme(plot.title= element_text(hjust=0.5,face="bold", colour="cadetblue"))

Melihat boxplot di atas, kita dapat menyimpulkan bahwa median Siswa perempuan G1 berada di sekitar 10 dan untuk anak laki-laki sekitar 12-13 dan jelas bagaimana anak laki-laki dan perempuan yang orang tuanya T ( Bersama) skor lebih tinggi daripada rekan-rekan mereka yang tidak bersama orang tua.

5.6.3 Histogram Hubungan Keluarga dengan G1

Bagaimana hubungan keluarga mempengaruhi kinerja akademik siswa?

ggplot(data=student,aes(x=famrel, y=G1, col=sex))+geom_point()+geom_smooth(method="lm",se=F)+facet_grid(~sex)
## `geom_smooth()` using formula 'y ~ x'

ggplot(data=student,aes(x=famrel, y=G1, col=sex))+geom_point()+geom_smooth(method="lm",se=F)+facet_grid(~sex) -> g1

Tidak ada keraguan bahwa siswa yang memiliki komunikasi yang baik dan hubungan yang baik dengan keluarga memiliki kinerja yang lebih baik di sekolah, dan bahwa apa yang dijelaskan grafik di atas, prestasi siswa meningkat dengan hubungan keluarga yang baik.

5.6.4 Histogram tingkat Konsumsi alkohol di hari kerja dengan G1

Bagaimana konsumsi alkohol di hari kerja mempengaruhi prestasi siswa?

my_graph <- ggplot(student, aes(x = Dalc, y = G1)) +
    geom_point(aes(color = sex)) +
    stat_smooth(method = "lm",
        col = "#C42126",
        se = FALSE,
        size = 1)
my_graph
## `geom_smooth()` using formula 'y ~ x'

Dari grafik di atas, kinerja Siswa menurun dengan bertambahnya konsumsi alkohol. Penyalahgunaan alkohol menyebabkan sering kebingungan dan gangguan memori. Konsumsi alkohol yang berlebihan menyebabkan ketidakmampuan untuk mengingat dengan baik. Dan siswa yang menyalahgunakan alkohol juga cenderung kehilangan konsentrasi di kelas.

5.7 Scatterplot Goout, Dalc dan G3

#Scatterplot G1 and G3
my_graph +
    theme_dark() +
    labs(
        x = "Dalc",
        y = "goout",
        color = "G3",
        title = "G3 with respect to goout and Dalc",
        subtitle = " goout and Dalc",
        caption = "Dalc and goout")
## `geom_smooth()` using formula 'y ~ x'

Dari scatterplot di atas, kita dapat melihat G3 (nilai akhir) menurun dengan Goout(Pergi bermain bersama teman) dan (Dalc) Konsumsi alkohol harian.

6 Prediksi Nilai Akhir siswa

Pertama, saya akan mengubah struktur data kategoris karena algoritma regresi perlu variabel numeric.

student$age = as.numeric(student$age)
student$Fedu = as.numeric(student$Fedu)
student$Medu = as.numeric(student$Medu)
student$Fjob = as.numeric(student$Fjob)
student$Mjob = as.numeric(student$Fjob)
student$Dalc = as.numeric(student$Dalc)
student$traveltime = as.numeric(student$traveltime)
student$sex = as.numeric(student$sex)
student$absences = as.numeric(student$absences)
student$famsize = as.numeric(student$famsize)
student$famrel = as.numeric(student$famrel)
student$Pstatus = as.numeric(student$Pstatus)

selanjutnya akan memprediksi Nilai akhir (G3) menggunakan regresi. Ini akan melalui 4 langkah:

  1. Partisi Data

  2. Membentuk Model Regresi

  3. Memprediksi data pengujian

  4. Mengevaluasi model

6.1 Pemisahan Data

Kami memulai dengan membagi data kami menjadi data training dan test.

set.seed(1234)
partition = createDataPartition(student[,'G3'], times=1, p=0.80, list=FALSE)
partition
##        Resample1
##   [1,]         1
##   [2,]         2
##   [3,]         4
##   [4,]         5
##   [5,]         6
##   [6,]         7
##   [7,]         8
##   [8,]         9
##   [9,]        10
##  [10,]        11
##  [11,]        13
##  [12,]        15
##  [13,]        16
##  [14,]        18
##  [15,]        19
##  [16,]        20
##  [17,]        21
##  [18,]        24
##  [19,]        25
##  [20,]        26
##  [21,]        27
##  [22,]        29
##  [23,]        30
##  [24,]        31
##  [25,]        32
##  [26,]        35
##  [27,]        36
##  [28,]        37
##  [29,]        38
##  [30,]        39
##  [31,]        40
##  [32,]        41
##  [33,]        43
##  [34,]        45
##  [35,]        46
##  [36,]        47
##  [37,]        49
##  [38,]        50
##  [39,]        51
##  [40,]        52
##  [41,]        53
##  [42,]        54
##  [43,]        55
##  [44,]        56
##  [45,]        57
##  [46,]        58
##  [47,]        59
##  [48,]        60
##  [49,]        61
##  [50,]        62
##  [51,]        63
##  [52,]        64
##  [53,]        65
##  [54,]        66
##  [55,]        67
##  [56,]        68
##  [57,]        70
##  [58,]        71
##  [59,]        72
##  [60,]        73
##  [61,]        74
##  [62,]        75
##  [63,]        77
##  [64,]        78
##  [65,]        79
##  [66,]        82
##  [67,]        83
##  [68,]        84
##  [69,]        85
##  [70,]        87
##  [71,]        90
##  [72,]        92
##  [73,]        93
##  [74,]        95
##  [75,]        96
##  [76,]        98
##  [77,]        99
##  [78,]       100
##  [79,]       101
##  [80,]       102
##  [81,]       103
##  [82,]       104
##  [83,]       105
##  [84,]       106
##  [85,]       107
##  [86,]       108
##  [87,]       109
##  [88,]       110
##  [89,]       111
##  [90,]       112
##  [91,]       113
##  [92,]       114
##  [93,]       117
##  [94,]       118
##  [95,]       120
##  [96,]       121
##  [97,]       124
##  [98,]       125
##  [99,]       126
## [100,]       127
## [101,]       128
## [102,]       129
## [103,]       130
## [104,]       131
## [105,]       132
## [106,]       133
## [107,]       134
## [108,]       135
## [109,]       138
## [110,]       139
## [111,]       140
## [112,]       142
## [113,]       143
## [114,]       144
## [115,]       145
## [116,]       147
## [117,]       148
## [118,]       150
## [119,]       151
## [120,]       152
## [121,]       153
## [122,]       154
## [123,]       155
## [124,]       156
## [125,]       157
## [126,]       158
## [127,]       159
## [128,]       160
## [129,]       161
## [130,]       162
## [131,]       163
## [132,]       164
## [133,]       165
## [134,]       166
## [135,]       168
## [136,]       170
## [137,]       172
## [138,]       174
## [139,]       175
## [140,]       178
## [141,]       180
## [142,]       181
## [143,]       182
## [144,]       183
## [145,]       184
## [146,]       185
## [147,]       186
## [148,]       187
## [149,]       188
## [150,]       189
## [151,]       190
## [152,]       191
## [153,]       192
## [154,]       194
## [155,]       195
## [156,]       196
## [157,]       197
## [158,]       198
## [159,]       199
## [160,]       201
## [161,]       202
## [162,]       203
## [163,]       204
## [164,]       205
## [165,]       206
## [166,]       207
## [167,]       208
## [168,]       209
## [169,]       210
## [170,]       211
## [171,]       212
## [172,]       213
## [173,]       214
## [174,]       215
## [175,]       217
## [176,]       218
## [177,]       219
## [178,]       220
## [179,]       221
## [180,]       222
## [181,]       223
## [182,]       224
## [183,]       225
## [184,]       226
## [185,]       229
## [186,]       231
## [187,]       233
## [188,]       234
## [189,]       235
## [190,]       237
## [191,]       239
## [192,]       240
## [193,]       241
## [194,]       242
## [195,]       243
## [196,]       245
## [197,]       246
## [198,]       247
## [199,]       248
## [200,]       249
## [201,]       250
## [202,]       254
## [203,]       255
## [204,]       256
## [205,]       257
## [206,]       258
## [207,]       259
## [208,]       260
## [209,]       261
## [210,]       262
## [211,]       263
## [212,]       264
## [213,]       265
## [214,]       266
## [215,]       267
## [216,]       269
## [217,]       270
## [218,]       271
## [219,]       272
## [220,]       273
## [221,]       274
## [222,]       275
## [223,]       276
## [224,]       277
## [225,]       278
## [226,]       279
## [227,]       280
## [228,]       282
## [229,]       283
## [230,]       285
## [231,]       287
## [232,]       288
## [233,]       289
## [234,]       290
## [235,]       291
## [236,]       292
## [237,]       293
## [238,]       294
## [239,]       295
## [240,]       296
## [241,]       297
## [242,]       298
## [243,]       299
## [244,]       300
## [245,]       301
## [246,]       302
## [247,]       303
## [248,]       305
## [249,]       306
## [250,]       307
## [251,]       308
## [252,]       310
## [253,]       311
## [254,]       312
## [255,]       313
## [256,]       314
## [257,]       315
## [258,]       316
## [259,]       317
## [260,]       318
## [261,]       320
## [262,]       321
## [263,]       323
## [264,]       325
## [265,]       326
## [266,]       327
## [267,]       328
## [268,]       329
## [269,]       330
## [270,]       331
## [271,]       334
## [272,]       335
## [273,]       336
## [274,]       337
## [275,]       339
## [276,]       340
## [277,]       341
## [278,]       342
## [279,]       346
## [280,]       348
## [281,]       349
## [282,]       350
## [283,]       351
## [284,]       352
## [285,]       353
## [286,]       355
## [287,]       356
## [288,]       358
## [289,]       359
## [290,]       360
## [291,]       363
## [292,]       364
## [293,]       365
## [294,]       366
## [295,]       367
## [296,]       368
## [297,]       369
## [298,]       371
## [299,]       372
## [300,]       373
## [301,]       374
## [302,]       375
## [303,]       376
## [304,]       377
## [305,]       378
## [306,]       379
## [307,]       380
## [308,]       382
## [309,]       384
## [310,]       385
## [311,]       387
## [312,]       388
## [313,]       389
## [314,]       391
## [315,]       392
## [316,]       393
## [317,]       394
## [318,]       395
training=student[partition,]
training
##     school sex age address famsize Pstatus Medu Fedu Mjob Fjob     reason
## 1       GP  NA  18       U      NA      NA    4    4   NA   NA     course
## 2       GP  NA  17       U      NA      NA    1    1   NA   NA     course
## 4       GP  NA  15       U      NA      NA    4    2   NA   NA       home
## 5       GP  NA  16       U      NA      NA    3    3   NA   NA       home
## 6       GP  NA  16       U      NA      NA    4    3   NA   NA reputation
## 7       GP  NA  16       U      NA      NA    2    2   NA   NA       home
## 8       GP  NA  17       U      NA      NA    4    4   NA   NA       home
## 9       GP  NA  15       U      NA      NA    3    2   NA   NA       home
## 10      GP  NA  15       U      NA      NA    3    4   NA   NA       home
## 11      GP  NA  15       U      NA      NA    4    4   NA   NA reputation
## 13      GP  NA  15       U      NA      NA    4    4   NA   NA     course
## 15      GP  NA  15       U      NA      NA    2    2   NA   NA       home
## 16      GP  NA  16       U      NA      NA    4    4   NA   NA       home
## 18      GP  NA  16       U      NA      NA    3    3   NA   NA reputation
## 19      GP  NA  17       U      NA      NA    3    2   NA   NA     course
## 20      GP  NA  16       U      NA      NA    4    3   NA   NA       home
## 21      GP  NA  15       U      NA      NA    4    3   NA   NA reputation
## 24      GP  NA  16       U      NA      NA    2    2   NA   NA reputation
## 25      GP  NA  15       R      NA      NA    2    4   NA   NA     course
## 26      GP  NA  16       U      NA      NA    2    2   NA   NA       home
## 27      GP  NA  15       U      NA      NA    2    2   NA   NA       home
## 29      GP  NA  16       U      NA      NA    3    4   NA   NA       home
## 30      GP  NA  16       U      NA      NA    4    4   NA   NA       home
## 31      GP  NA  15       U      NA      NA    4    4   NA   NA       home
## 32      GP  NA  15       U      NA      NA    4    4   NA   NA reputation
## 35      GP  NA  16       U      NA      NA    3    2   NA   NA       home
## 36      GP  NA  15       U      NA      NA    2    3   NA   NA      other
## 37      GP  NA  15       U      NA      NA    4    3   NA   NA       home
## 38      GP  NA  16       R      NA      NA    4    4   NA   NA reputation
## 39      GP  NA  15       R      NA      NA    3    4   NA   NA     course
## 40      GP  NA  15       R      NA      NA    2    2   NA   NA reputation
## 41      GP  NA  16       U      NA      NA    2    2   NA   NA       home
## 43      GP  NA  15       U      NA      NA    4    4   NA   NA     course
## 45      GP  NA  16       U      NA      NA    2    2   NA   NA     course
## 46      GP  NA  15       U      NA      NA    4    3   NA   NA     course
## 47      GP  NA  16       U      NA      NA    3    3   NA   NA       home
## 49      GP  NA  15       U      NA      NA    4    2   NA   NA       home
## 50      GP  NA  15       U      NA      NA    4    4   NA   NA      other
## 51      GP  NA  16       U      NA      NA    2    2   NA   NA     course
## 52      GP  NA  15       U      NA      NA    4    2   NA   NA      other
## 53      GP  NA  15       U      NA      NA    4    2   NA   NA      other
## 54      GP  NA  15       U      NA      NA    4    4   NA   NA     course
## 55      GP  NA  15       U      NA      NA    3    3   NA   NA      other
## 56      GP  NA  16       U      NA      NA    2    1   NA   NA      other
## 57      GP  NA  15       U      NA      NA    4    3   NA   NA reputation
## 58      GP  NA  15       U      NA      NA    4    4   NA   NA reputation
## 59      GP  NA  15       U      NA      NA    1    2   NA   NA       home
## 60      GP  NA  16       U      NA      NA    4    2   NA   NA     course
## 61      GP  NA  16       R      NA      NA    4    4   NA   NA      other
## 62      GP  NA  16       U      NA      NA    1    1   NA   NA     course
## 63      GP  NA  16       U      NA      NA    1    2   NA   NA reputation
## 64      GP  NA  16       U      NA      NA    4    3   NA   NA       home
## 65      GP  NA  15       U      NA      NA    4    3   NA   NA reputation
## 66      GP  NA  16       U      NA      NA    4    3   NA   NA     course
## 67      GP  NA  15       U      NA      NA    4    4   NA   NA reputation
## 68      GP  NA  16       U      NA      NA    3    1   NA   NA     course
## 70      GP  NA  15       R      NA      NA    3    1   NA   NA reputation
## 71      GP  NA  16       U      NA      NA    3    1   NA   NA reputation
## 72      GP  NA  15       U      NA      NA    4    2   NA   NA     course
## 73      GP  NA  15       R      NA      NA    1    1   NA   NA reputation
## 74      GP  NA  16       U      NA      NA    3    1   NA   NA reputation
## 75      GP  NA  16       U      NA      NA    3    3   NA   NA       home
## 77      GP  NA  15       U      NA      NA    4    0   NA   NA     course
## 78      GP  NA  16       U      NA      NA    2    2   NA   NA reputation
## 79      GP  NA  17       U      NA      NA    2    1   NA   NA       home
## 82      GP  NA  15       U      NA      NA    2    3   NA   NA       home
## 83      GP  NA  15       U      NA      NA    3    2   NA   NA reputation
## 84      GP  NA  15       U      NA      NA    2    2   NA   NA       home
## 85      GP  NA  15       U      NA      NA    1    1   NA   NA       home
## 87      GP  NA  16       U      NA      NA    2    2   NA   NA     course
## 90      GP  NA  16       U      NA      NA    4    4   NA   NA reputation
## 92      GP  NA  15       U      NA      NA    4    3   NA   NA reputation
## 93      GP  NA  16       U      NA      NA    3    1   NA   NA       home
## 95      GP  NA  15       U      NA      NA    2    2   NA   NA reputation
## 96      GP  NA  15       R      NA      NA    1    1   NA   NA       home
## 98      GP  NA  16       U      NA      NA    2    1   NA   NA     course
## 99      GP  NA  16       U      NA      NA    4    4   NA   NA reputation
## 100     GP  NA  16       U      NA      NA    4    3   NA   NA     course
## 101     GP  NA  16       U      NA      NA    4    4   NA   NA      other
## 102     GP  NA  16       U      NA      NA    4    4   NA   NA      other
## 103     GP  NA  15       U      NA      NA    4    4   NA   NA     course
## 104     GP  NA  15       U      NA      NA    3    2   NA   NA       home
## 105     GP  NA  15       U      NA      NA    3    4   NA   NA     course
## 106     GP  NA  15       U      NA      NA    3    3   NA   NA reputation
## 107     GP  NA  15       U      NA      NA    2    2   NA   NA     course
## 108     GP  NA  16       U      NA      NA    3    3   NA   NA       home
## 109     GP  NA  15       R      NA      NA    4    4   NA   NA       home
## 110     GP  NA  16       U      NA      NA    4    4   NA   NA      other
## 111     GP  NA  15       U      NA      NA    4    4   NA   NA     course
## 112     GP  NA  16       R      NA      NA    3    3   NA   NA reputation
## 113     GP  NA  16       U      NA      NA    2    2   NA   NA       home
## 114     GP  NA  15       U      NA      NA    4    2   NA   NA     course
## 117     GP  NA  15       U      NA      NA    4    4   NA   NA reputation
## 118     GP  NA  16       U      NA      NA    3    3   NA   NA       home
## 120     GP  NA  15       U      NA      NA    3    4   NA   NA reputation
## 121     GP  NA  15       U      NA      NA    1    2   NA   NA     course
## 124     GP  NA  16       U      NA      NA    4    4   NA   NA     course
## 125     GP  NA  16       U      NA      NA    2    2   NA   NA       home
## 126     GP  NA  15       U      NA      NA    3    4   NA   NA       home
## 127     GP  NA  15       U      NA      NA    3    4   NA   NA       home
## 128     GP  NA  19       U      NA      NA    0    1   NA   NA     course
## 129     GP  NA  18       R      NA      NA    2    2   NA   NA reputation
## 130     GP  NA  16       R      NA      NA    4    4   NA   NA     course
## 131     GP  NA  15       R      NA      NA    3    4   NA   NA     course
## 132     GP  NA  15       U      NA      NA    1    1   NA   NA     course
## 133     GP  NA  17       U      NA      NA    2    2   NA   NA     course
## 134     GP  NA  16       U      NA      NA    3    4   NA   NA     course
## 135     GP  NA  15       R      NA      NA    3    4   NA   NA     course
## 138     GP  NA  16       U      NA      NA    3    3   NA   NA     course
## 139     GP  NA  16       U      NA      NA    1    1   NA   NA     course
## 140     GP  NA  15       U      NA      NA    4    4   NA   NA     course
## 142     GP  NA  16       U      NA      NA    2    2   NA   NA reputation
## 143     GP  NA  15       U      NA      NA    4    4   NA   NA     course
## 144     GP  NA  16       U      NA      NA    1    1   NA   NA     course
## 145     GP  NA  17       U      NA      NA    2    1   NA   NA       home
## 147     GP  NA  15       U      NA      NA    3    2   NA   NA       home
## 148     GP  NA  15       U      NA      NA    1    2   NA   NA     course
## 150     GP  NA  15       U      NA      NA    2    1   NA   NA     course
## 151     GP  NA  18       U      NA      NA    1    1   NA   NA     course
## 152     GP  NA  16       U      NA      NA    2    1   NA   NA     course
## 153     GP  NA  15       R      NA      NA    3    3   NA   NA reputation
## 154     GP  NA  19       U      NA      NA    3    2   NA   NA       home
## 155     GP  NA  17       U      NA      NA    4    4   NA   NA     course
## 156     GP  NA  15       R      NA      NA    2    3   NA   NA     course
## 157     GP  NA  17       R      NA      NA    1    2   NA   NA reputation
## 158     GP  NA  18       R      NA      NA    1    1   NA   NA     course
## 159     GP  NA  16       R      NA      NA    2    2   NA   NA     course
## 160     GP  NA  16       U      NA      NA    3    3   NA   NA     course
## 161     GP  NA  17       R      NA      NA    2    1   NA   NA     course
## 162     GP  NA  15       R      NA      NA    3    2   NA   NA     course
## 163     GP  NA  16       U      NA      NA    1    2   NA   NA     course
## 164     GP  NA  17       U      NA      NA    1    3   NA   NA     course
## 165     GP  NA  17       R      NA      NA    1    1   NA   NA     course
## 166     GP  NA  16       U      NA      NA    3    2   NA   NA     course
## 168     GP  NA  16       U      NA      NA    4    2   NA   NA       home
## 170     GP  NA  16       U      NA      NA    4    4   NA   NA reputation
## 172     GP  NA  16       U      NA      NA    1    0   NA   NA reputation
## 174     GP  NA  16       U      NA      NA    1    3   NA   NA       home
## 175     GP  NA  16       U      NA      NA    3    3   NA   NA reputation
## 178     GP  NA  17       U      NA      NA    3    3   NA   NA reputation
## 180     GP  NA  17       U      NA      NA    4    3   NA   NA     course
## 181     GP  NA  16       U      NA      NA    4    3   NA   NA       home
## 182     GP  NA  16       U      NA      NA    3    3   NA   NA       home
## 183     GP  NA  17       U      NA      NA    2    4   NA   NA reputation
## 184     GP  NA  17       U      NA      NA    3    3   NA   NA reputation
## 185     GP  NA  16       U      NA      NA    3    2   NA   NA reputation
## 186     GP  NA  17       U      NA      NA    3    3   NA   NA      other
## 187     GP  NA  16       U      NA      NA    1    2   NA   NA      other
## 188     GP  NA  16       U      NA      NA    2    1   NA   NA     course
## 189     GP  NA  17       U      NA      NA    3    3   NA   NA reputation
## 190     GP  NA  17       R      NA      NA    1    2   NA   NA       home
## 191     GP  NA  16       U      NA      NA    2    3   NA   NA     course
## 192     GP  NA  17       U      NA      NA    1    1   NA   NA     course
## 194     GP  NA  16       R      NA      NA    3    3   NA   NA reputation
## 195     GP  NA  16       U      NA      NA    2    3   NA   NA       home
## 196     GP  NA  17       U      NA      NA    2    4   NA   NA     course
## 197     GP  NA  17       U      NA      NA    4    4   NA   NA       home
## 198     GP  NA  16       R      NA      NA    3    3   NA   NA       home
## 199     GP  NA  17       U      NA      NA    4    4   NA   NA       home
## 201     GP  NA  16       U      NA      NA    4    3   NA   NA       home
## 202     GP  NA  16       U      NA      NA    2    3   NA   NA reputation
## 203     GP  NA  17       U      NA      NA    1    1   NA   NA     course
## 204     GP  NA  17       R      NA      NA    2    2   NA   NA reputation
## 205     GP  NA  16       R      NA      NA    2    2   NA   NA reputation
## 206     GP  NA  17       U      NA      NA    3    4   NA   NA       home
## 207     GP  NA  16       U      NA      NA    3    1   NA   NA     course
## 208     GP  NA  16       U      NA      NA    4    3   NA   NA      other
## 209     GP  NA  16       U      NA      NA    1    1   NA   NA       home
## 210     GP  NA  17       R      NA      NA    4    3   NA   NA reputation
## 211     GP  NA  19       U      NA      NA    3    3   NA   NA reputation
## 212     GP  NA  17       U      NA      NA    4    4   NA   NA       home
## 213     GP  NA  16       U      NA      NA    2    2   NA   NA reputation
## 214     GP  NA  18       U      NA      NA    2    2   NA   NA       home
## 215     GP  NA  17       R      NA      NA    4    4   NA   NA      other
## 217     GP  NA  17       U      NA      NA    4    3   NA   NA reputation
## 218     GP  NA  18       U      NA      NA    3    3   NA   NA       home
## 219     GP  NA  17       U      NA      NA    2    3   NA   NA       home
## 220     GP  NA  17       U      NA      NA    2    2   NA   NA     course
## 221     GP  NA  17       R      NA      NA    2    1   NA   NA reputation
## 222     GP  NA  17       U      NA      NA    1    1   NA   NA reputation
## 223     GP  NA  16       U      NA      NA    2    3   NA   NA      other
## 224     GP  NA  18       U      NA      NA    2    2   NA   NA       home
## 225     GP  NA  16       U      NA      NA    4    4   NA   NA       home
## 226     GP  NA  18       R      NA      NA    3    1   NA   NA reputation
## 229     GP  NA  18       U      NA      NA    2    1   NA   NA     course
## 231     GP  NA  17       U      NA      NA    4    3   NA   NA reputation
## 233     GP  NA  17       U      NA      NA    4    4   NA   NA reputation
## 234     GP  NA  16       U      NA      NA    4    4   NA   NA reputation
## 235     GP  NA  16       U      NA      NA    1    1   NA   NA       home
## 237     GP  NA  17       U      NA      NA    2    2   NA   NA       home
## 239     GP  NA  17       R      NA      NA    2    1   NA   NA     course
## 240     GP  NA  18       U      NA      NA    2    2   NA   NA reputation
## 241     GP  NA  17       U      NA      NA    4    3   NA   NA     course
## 242     GP  NA  17       R      NA      NA    4    4   NA   NA     course
## 243     GP  NA  16       U      NA      NA    4    3   NA   NA     course
## 245     GP  NA  18       U      NA      NA    2    1   NA   NA     course
## 246     GP  NA  16       U      NA      NA    2    1   NA   NA     course
## 247     GP  NA  17       U      NA      NA    2    3   NA   NA     course
## 248     GP  NA  22       U      NA      NA    3    1   NA   NA      other
## 249     GP  NA  18       R      NA      NA    3    3   NA   NA     course
## 250     GP  NA  16       U      NA      NA    0    2   NA   NA      other
## 254     GP  NA  16       R      NA      NA    2    1   NA   NA     course
## 255     GP  NA  17       R      NA      NA    2    1   NA   NA     course
## 256     GP  NA  17       U      NA      NA    1    1   NA   NA     course
## 257     GP  NA  17       U      NA      NA    4    2   NA   NA reputation
## 258     GP  NA  19       U      NA      NA    4    3   NA   NA reputation
## 259     GP  NA  18       U      NA      NA    2    1   NA   NA       home
## 260     GP  NA  17       U      NA      NA    2    2   NA   NA     course
## 261     GP  NA  18       U      NA      NA    4    3   NA   NA       home
## 262     GP  NA  18       U      NA      NA    4    3   NA   NA     course
## 263     GP  NA  18       R      NA      NA    3    2   NA   NA     course
## 264     GP  NA  17       U      NA      NA    3    3   NA   NA       home
## 265     GP  NA  18       U      NA      NA    2    2   NA   NA       home
## 266     GP  NA  18       R      NA      NA    3    4   NA   NA reputation
## 267     GP  NA  17       U      NA      NA    3    1   NA   NA      other
## 269     GP  NA  18       U      NA      NA    4    2   NA   NA reputation
## 270     GP  NA  18       R      NA      NA    2    1   NA   NA reputation
## 271     GP  NA  19       U      NA      NA    3    3   NA   NA       home
## 272     GP  NA  18       U      NA      NA    2    3   NA   NA reputation
## 273     GP  NA  18       U      NA      NA    1    1   NA   NA       home
## 274     GP  NA  17       R      NA      NA    1    2   NA   NA       home
## 275     GP  NA  17       U      NA      NA    2    4   NA   NA reputation
## 276     GP  NA  17       U      NA      NA    2    2   NA   NA     course
## 277     GP  NA  18       R      NA      NA    3    2   NA   NA       home
## 278     GP  NA  18       U      NA      NA    4    4   NA   NA       home
## 279     GP  NA  18       U      NA      NA    4    4   NA   NA reputation
## 280     GP  NA  18       U      NA      NA    4    3   NA   NA     course
## 282     GP  NA  17       U      NA      NA    3    2   NA   NA       home
## 283     GP  NA  18       R      NA      NA    1    1   NA   NA reputation
## 285     GP  NA  17       U      NA      NA    2    2   NA   NA     course
## 287     GP  NA  18       U      NA      NA    2    2   NA   NA      other
## 288     GP  NA  17       U      NA      NA    1    1   NA   NA reputation
## 289     GP  NA  18       U      NA      NA    2    1   NA   NA reputation
## 290     GP  NA  18       U      NA      NA    4    4   NA   NA reputation
## 291     GP  NA  18       U      NA      NA    4    2   NA   NA       home
## 292     GP  NA  17       U      NA      NA    4    3   NA   NA reputation
## 293     GP  NA  18       U      NA      NA    2    1   NA   NA reputation
## 294     GP  NA  17       R      NA      NA    3    1   NA   NA reputation
## 295     GP  NA  18       R      NA      NA    3    2   NA   NA reputation
## 296     GP  NA  17       U      NA      NA    3    3   NA   NA       home
## 297     GP  NA  19       U      NA      NA    4    4   NA   NA reputation
## 298     GP  NA  18       U      NA      NA    4    3   NA   NA       home
## 299     GP  NA  18       U      NA      NA    4    3   NA   NA reputation
## 300     GP  NA  18       U      NA      NA    4    4   NA   NA       home
## 301     GP  NA  18       U      NA      NA    4    4   NA   NA       home
## 302     GP  NA  17       U      NA      NA    4    4   NA   NA       home
## 303     GP  NA  17       U      NA      NA    4    2   NA   NA reputation
## 305     GP  NA  19       U      NA      NA    3    3   NA   NA       home
## 306     GP  NA  18       U      NA      NA    2    4   NA   NA reputation
## 307     GP  NA  20       U      NA      NA    3    2   NA   NA     course
## 308     GP  NA  19       U      NA      NA    4    4   NA   NA reputation
## 310     GP  NA  19       U      NA      NA    1    1   NA   NA reputation
## 311     GP  NA  19       U      NA      NA    1    2   NA   NA       home
## 312     GP  NA  19       U      NA      NA    2    1   NA   NA      other
## 313     GP  NA  19       U      NA      NA    1    2   NA   NA     course
## 314     GP  NA  19       U      NA      NA    3    2   NA   NA reputation
## 315     GP  NA  19       U      NA      NA    1    1   NA   NA       home
## 316     GP  NA  19       R      NA      NA    2    3   NA   NA reputation
## 317     GP  NA  18       U      NA      NA    2    1   NA   NA     course
## 318     GP  NA  18       U      NA      NA    4    3   NA   NA     course
## 320     GP  NA  18       U      NA      NA    4    4   NA   NA     course
## 321     GP  NA  17       U      NA      NA    4    3   NA   NA     course
## 323     GP  NA  17       R      NA      NA    2    2   NA   NA     course
## 325     GP  NA  17       U      NA      NA    0    2   NA   NA       home
## 326     GP  NA  18       U      NA      NA    4    4   NA   NA     course
## 327     GP  NA  17       U      NA      NA    3    3   NA   NA reputation
## 328     GP  NA  17       R      NA      NA    2    2   NA   NA     course
## 329     GP  NA  17       U      NA      NA    4    4   NA   NA     course
## 330     GP  NA  17       U      NA      NA    4    4   NA   NA     course
## 331     GP  NA  18       U      NA      NA    2    2   NA   NA     course
## 334     GP  NA  18       U      NA      NA    2    2   NA   NA       home
## 335     GP  NA  18       R      NA      NA    2    2   NA   NA     course
## 336     GP  NA  17       U      NA      NA    3    4   NA   NA     course
## 337     GP  NA  19       R      NA      NA    3    1   NA   NA       home
## 339     GP  NA  18       U      NA      NA    3    3   NA   NA       home
## 340     GP  NA  17       R      NA      NA    3    2   NA   NA       home
## 341     GP  NA  19       U      NA      NA    2    1   NA   NA       home
## 342     GP  NA  18       U      NA      NA    4    4   NA   NA       home
## 346     GP  NA  18       U      NA      NA    3    2   NA   NA      other
## 348     GP  NA  18       U      NA      NA    4    3   NA   NA     course
## 349     GP  NA  17       U      NA      NA    4    3   NA   NA reputation
## 350     MS  NA  18       R      NA      NA    3    2   NA   NA     course
## 351     MS  NA  19       R      NA      NA    1    1   NA   NA       home
## 352     MS  NA  17       U      NA      NA    3    3   NA   NA     course
## 353     MS  NA  18       U      NA      NA    1    3   NA   NA     course
## 355     MS  NA  17       R      NA      NA    4    3   NA   NA       home
## 356     MS  NA  18       U      NA      NA    3    3   NA   NA     course
## 358     MS  NA  17       U      NA      NA    3    2   NA   NA reputation
## 359     MS  NA  18       U      NA      NA    1    1   NA   NA       home
## 360     MS  NA  18       U      NA      NA    1    1   NA   NA     course
## 363     MS  NA  18       U      NA      NA    3    3   NA   NA      other
## 364     MS  NA  17       U      NA      NA    4    4   NA   NA     course
## 365     MS  NA  17       R      NA      NA    1    2   NA   NA     course
## 366     MS  NA  18       R      NA      NA    1    3   NA   NA     course
## 367     MS  NA  18       U      NA      NA    4    4   NA   NA      other
## 368     MS  NA  17       R      NA      NA    1    1   NA   NA reputation
## 369     MS  NA  18       U      NA      NA    2    3   NA   NA     course
## 371     MS  NA  19       U      NA      NA    3    2   NA   NA       home
## 372     MS  NA  18       R      NA      NA    1    2   NA   NA      other
## 373     MS  NA  17       U      NA      NA    2    2   NA   NA       home
## 374     MS  NA  17       R      NA      NA    1    2   NA   NA     course
## 375     MS  NA  18       R      NA      NA    4    4   NA   NA reputation
## 376     MS  NA  18       R      NA      NA    1    1   NA   NA       home
## 377     MS  NA  20       U      NA      NA    4    2   NA   NA     course
## 378     MS  NA  18       R      NA      NA    4    4   NA   NA     course
## 379     MS  NA  18       U      NA      NA    3    3   NA   NA       home
## 380     MS  NA  17       R      NA      NA    3    1   NA   NA reputation
## 382     MS  NA  18       R      NA      NA    2    1   NA   NA      other
## 384     MS  NA  19       R      NA      NA    1    1   NA   NA      other
## 385     MS  NA  18       R      NA      NA    4    2   NA   NA       home
## 387     MS  NA  18       R      NA      NA    4    4   NA   NA reputation
## 388     MS  NA  19       R      NA      NA    2    3   NA   NA     course
## 389     MS  NA  18       U      NA      NA    3    1   NA   NA     course
## 391     MS  NA  20       U      NA      NA    2    2   NA   NA     course
## 392     MS  NA  17       U      NA      NA    3    1   NA   NA     course
## 393     MS  NA  21       R      NA      NA    1    1   NA   NA     course
## 394     MS  NA  18       R      NA      NA    3    2   NA   NA     course
## 395     MS  NA  19       U      NA      NA    1    1   NA   NA     course
##     guardian traveltime studytime failures schoolsup famsup paid activities
## 1     mother          2         2        0       yes     no   no         no
## 2     father          1         2        0        no    yes   no         no
## 4     mother          1         3        0        no    yes  yes        yes
## 5     father          1         2        0        no    yes  yes         no
## 6     mother          1         2        0        no    yes  yes        yes
## 7     mother          1         2        0        no     no   no         no
## 8     mother          2         2        0       yes    yes   no         no
## 9     mother          1         2        0        no    yes  yes         no
## 10    mother          1         2        0        no    yes  yes        yes
## 11    mother          1         2        0        no    yes  yes         no
## 13    father          1         1        0        no    yes  yes        yes
## 15     other          1         3        0        no    yes   no         no
## 16    mother          1         1        0        no    yes   no         no
## 18    mother          3         2        0       yes    yes   no        yes
## 19    mother          1         1        3        no    yes   no        yes
## 20    father          1         1        0        no     no  yes        yes
## 21    mother          1         2        0        no     no   no         no
## 24    mother          2         2        0        no    yes   no        yes
## 25    mother          1         3        0       yes    yes  yes        yes
## 26    mother          1         1        2        no    yes  yes         no
## 27    mother          1         1        0        no    yes  yes         no
## 29    mother          1         2        0       yes    yes   no        yes
## 30    mother          1         2        0        no    yes  yes        yes
## 31    mother          1         2        0        no    yes  yes         no
## 32    mother          2         2        0        no    yes   no        yes
## 35    mother          1         1        0        no    yes  yes         no
## 36    father          2         1        0        no    yes   no        yes
## 37    mother          1         3        0        no    yes   no        yes
## 38    mother          2         3        0        no    yes   no        yes
## 39    mother          1         3        0       yes    yes  yes        yes
## 40    mother          1         1        0       yes    yes  yes        yes
## 41    mother          2         2        1        no    yes   no        yes
## 43    father          1         2        0        no    yes   no        yes
## 45    father          2         2        1       yes     no   no        yes
## 46    mother          1         2        0       yes    yes  yes        yes
## 47    mother          1         2        0        no    yes   no         no
## 49    mother          1         2        0        no    yes  yes         no
## 50    father          1         2        1       yes    yes   no        yes
## 51    mother          3         2        0        no    yes  yes         no
## 52    mother          1         2        0        no    yes  yes         no
## 53    father          2         1        1        no     no   no         no
## 54    mother          1         1        0       yes    yes  yes         no
## 55    mother          1         1        0        no     no  yes         no
## 56    mother          1         2        0        no     no  yes        yes
## 57    mother          1         2        0        no    yes  yes        yes
## 58    mother          1         2        0        no    yes   no        yes
## 59    father          1         2        0       yes    yes   no        yes
## 60    mother          1         2        0        no    yes   no         no
## 61    mother          1         2        0        no    yes   no        yes
## 62    father          4         1        0       yes    yes   no        yes
## 63    father          1         2        0       yes     no   no        yes
## 64    mother          1         3        0       yes    yes  yes        yes
## 65    father          1         2        0       yes     no   no        yes
## 66    mother          3         2        0        no    yes   no        yes
## 67    mother          1         4        0        no    yes   no        yes
## 68    mother          1         4        0       yes    yes  yes         no
## 70    father          2         4        0        no    yes   no         no
## 71    father          2         4        0        no    yes  yes         no
## 72    mother          1         4        0        no     no   no         no
## 73    mother          1         2        2       yes    yes   no         no
## 74    mother          1         1        0        no     no   no        yes
## 75    mother          1         2        0       yes    yes  yes        yes
## 77    mother          2         4        0        no     no   no        yes
## 78    mother          1         4        0        no     no  yes         no
## 79    mother          2         1        3       yes    yes   no        yes
## 82    mother          1         3        0       yes     no  yes         no
## 83    mother          1         2        0        no    yes  yes         no
## 84    mother          2         2        0        no     no  yes        yes
## 85    father          1         2        0        no    yes   no        yes
## 87    mother          1         2        0        no    yes   no         no
## 90    mother          1         2        0        no    yes   no         no
## 92    mother          1         1        0        no     no  yes        yes
## 93    father          1         2        0       yes    yes   no         no
## 95    mother          1         4        0        no    yes   no        yes
## 96    mother          2         4        1       yes    yes  yes        yes
## 98    mother          1         2        0        no    yes  yes         no
## 99    mother          1         1        0        no     no   no        yes
## 100   mother          1         3        0       yes    yes  yes         no
## 101   mother          1         1        0       yes    yes  yes        yes
## 102   father          1         3        0        no    yes   no        yes
## 103   mother          1         1        0        no    yes   no        yes
## 104   mother          2         2        0       yes    yes  yes         no
## 105   mother          1         2        0        no    yes  yes        yes
## 106   father          1         4        0       yes     no   no         no
## 107   mother          1         4        0       yes    yes  yes         no
## 108   father          1         3        0        no    yes   no        yes
## 109   father          4         4        0        no    yes  yes        yes
## 110   mother          1         3        0        no    yes  yes        yes
## 111   mother          1         1        0        no     no   no        yes
## 112   father          1         3        1       yes    yes   no        yes
## 113   mother          1         2        1       yes     no   no        yes
## 114   mother          1         1        0        no     no   no         no
## 117   father          2         2        0        no    yes   no        yes
## 118   father          2         1        0        no     no   no        yes
## 120   father          1         1        0        no     no   no         no
## 121   mother          1         2        0        no     no   no         no
## 124   mother          1         1        0        no    yes   no        yes
## 125   mother          1         2        0        no     no  yes         no
## 126   father          1         1        0       yes     no   no         no
## 127   mother          1         2        0       yes     no   no        yes
## 128    other          1         2        3        no    yes   no         no
## 129   mother          1         1        2        no    yes   no        yes
## 130   mother          1         1        0        no     no  yes        yes
## 131   father          2         3        2        no    yes   no         no
## 132   mother          3         1        0        no    yes   no        yes
## 133   father          1         1        0        no    yes   no         no
## 134   father          1         1        0        no     no   no         no
## 135   mother          4         2        0        no    yes   no         no
## 138    other          2         1        2        no    yes   no        yes
## 139   mother          1         2        1        no     no   no         no
## 140   mother          2         1        0        no     no   no        yes
## 142   father          2         1        2        no    yes   no        yes
## 143   mother          1         3        0        no    yes  yes        yes
## 144   mother          1         1        0        no     no   no         no
## 145   mother          1         1        3        no    yes   no         no
## 147   father          1         2        3        no    yes   no         no
## 148   mother          1         2        0        no    yes  yes         no
## 150   mother          4         1        3        no     no   no         no
## 151   mother          1         1        3        no     no   no         no
## 152   mother          1         1        1        no     no   no        yes
## 153    other          2         3        2        no    yes  yes        yes
## 154   mother          1         1        3        no    yes   no         no
## 155   mother          1         1        0       yes    yes   no         no
## 156   mother          1         2        0       yes     no  yes        yes
## 157   mother          1         1        0        no     no   no         no
## 158   mother          3         1        3        no    yes   no        yes
## 159   mother          3         1        0        no     no   no         no
## 160   father          1         2        1        no    yes  yes         no
## 161   mother          2         1        2        no     no   no        yes
## 162   mother          2         2        2       yes    yes   no         no
## 163   mother          2         1        1        no     no   no        yes
## 164   father          1         1        0        no     no   no         no
## 165   mother          4         2        3        no     no   no        yes
## 166   mother          2         1        1        no    yes   no        yes
## 168   father          1         2        0        no     no  yes         no
## 170   mother          1         2        0        no    yes  yes         no
## 172   mother          2         2        0        no    yes  yes        yes
## 174   mother          1         2        3        no     no   no        yes
## 175   mother          2         2        0        no    yes  yes        yes
## 178   father          1         2        0        no     no   no        yes
## 180   mother          1         2        0        no    yes   no        yes
## 181   mother          1         2        0        no    yes  yes        yes
## 182   mother          1         2        0        no     no  yes        yes
## 183   father          1         2        0        no    yes   no        yes
## 184   mother          1         2        0        no    yes   no        yes
## 185   mother          1         2        0        no    yes  yes         no
## 186   mother          1         2        0        no    yes   no        yes
## 187   mother          1         1        0        no    yes  yes        yes
## 188   mother          1         2        0        no     no  yes        yes
## 189   mother          1         2        0        no    yes   no         no
## 190   mother          1         2        0        no     no   no         no
## 191   mother          1         2        0        no     no   no         no
## 192   mother          1         2        0        no     no   no        yes
## 194   mother          1         1        0        no    yes   no        yes
## 195   father          2         1        0        no     no   no         no
## 196   father          1         2        0        no     no   no        yes
## 197   mother          1         1        0        no     no   no         no
## 198   father          3         1        0        no    yes  yes        yes
## 199   mother          2         1        1        no    yes   no         no
## 201   mother          1         2        0        no    yes   no        yes
## 202   mother          1         2        0       yes    yes  yes        yes
## 203   mother          1         2        0        no    yes  yes         no
## 204   mother          1         1        0        no    yes   no         no
## 205   mother          2         4        0        no    yes  yes        yes
## 206   mother          1         3        1        no    yes  yes         no
## 207   mother          1         2        3        no    yes  yes         no
## 208   mother          1         2        0        no     no  yes        yes
## 209   mother          2         1        0        no    yes  yes         no
## 210   mother          2         3        0        no    yes  yes        yes
## 211    other          1         4        0        no    yes  yes        yes
## 212   mother          1         2        0        no    yes  yes         no
## 213   mother          1         2        0       yes    yes  yes         no
## 214   mother          1         2        1        no    yes  yes        yes
## 215   mother          1         1        0        no    yes  yes         no
## 217   mother          1         2        2        no     no  yes         no
## 218   father          1         2        1        no    yes  yes         no
## 219   father          2         1        0        no    yes  yes         no
## 220   mother          1         3        0        no    yes  yes        yes
## 221   mother          2         2        0        no    yes   no        yes
## 222   mother          1         3        1        no    yes   no        yes
## 223   mother          1         2        0       yes     no   no         no
## 224   mother          2         2        0        no    yes  yes         no
## 225   mother          1         3        0        no    yes   no        yes
## 226   mother          1         2        1        no     no   no        yes
## 229   mother          4         2        0       yes    yes  yes        yes
## 231   father          1         2        0        no     no   no        yes
## 233   mother          1         2        0       yes    yes   no        yes
## 234   father          1         2        0        no    yes  yes        yes
## 235   mother          2         2        0        no    yes  yes         no
## 237   father          1         2        0        no     no  yes        yes
## 239   mother          3         2        0        no     no   no        yes
## 240   father          1         2        1        no     no   no         no
## 241   mother          2         2        0        no     no   no        yes
## 242   mother          2         2        0        no    yes  yes         no
## 243   mother          1         1        0        no     no   no        yes
## 245    other          2         3        0        no    yes  yes         no
## 246   mother          3         1        0        no     no   no         no
## 247   father          2         1        0        no     no   no         no
## 248   mother          1         1        3        no     no   no         no
## 249   mother          1         2        1        no    yes   no         no
## 250   mother          1         1        0        no     no  yes         no
## 254   mother          2         1        0        no     no   no        yes
## 255   mother          1         1        0        no     no   no         no
## 256   mother          2         1        1        no    yes   no        yes
## 257   mother          1         4        0        no    yes  yes        yes
## 258   mother          1         2        0        no    yes   no         no
## 259   mother          1         2        0        no     no   no        yes
## 260   father          1         4        0        no     no  yes        yes
## 261   father          1         2        0        no    yes  yes         no
## 262   mother          1         2        0        no    yes  yes         no
## 263   mother          1         3        0        no     no   no        yes
## 264   mother          1         3        0        no     no   no        yes
## 265   mother          1         3        0        no    yes  yes        yes
## 266   mother          2         2        0        no    yes  yes        yes
## 267   mother          1         2        0        no     no  yes        yes
## 269   father          1         2        0        no    yes  yes        yes
## 270   mother          2         2        0        no    yes   no         no
## 271    other          1         2        2        no    yes  yes        yes
## 272   father          1         4        0        no    yes  yes        yes
## 273   mother          2         2        0        no    yes  yes         no
## 274   mother          1         2        0        no    yes  yes        yes
## 275   mother          2         2        0        no    yes  yes         no
## 276   mother          2         2        0       yes    yes  yes         no
## 277   mother          2         2        0        no     no   no         no
## 278   mother          2         1        0        no     no  yes        yes
## 279   father          1         2        1       yes    yes   no        yes
## 280   mother          2         1        0        no     no  yes        yes
## 282   mother          1         1        1        no     no   no         no
## 283   mother          2         4        0        no    yes  yes        yes
## 285   mother          1         2        0        no    yes   no         no
## 287   mother          1         3        0        no    yes  yes         no
## 288   mother          1         3        0        no    yes  yes         no
## 289   mother          1         3        0        no     no  yes        yes
## 290   mother          1         2        0        no    yes  yes        yes
## 291   mother          1         2        0        no    yes  yes        yes
## 292   mother          1         3        0        no    yes  yes         no
## 293   mother          1         2        1        no     no   no         no
## 294   mother          2         4        0        no    yes  yes         no
## 295   mother          2         3        0        no    yes  yes        yes
## 296   mother          1         1        0        no    yes  yes         no
## 297    other          2         2        0        no    yes  yes        yes
## 298    other          2         2        0        no    yes  yes         no
## 299   father          1         4        0        no    yes  yes         no
## 300   mother          1         1        0        no    yes  yes         no
## 301   mother          1         2        0        no    yes   no         no
## 302   father          2         1        0        no     no  yes         no
## 303   mother          2         3        0        no    yes  yes         no
## 305    other          1         2        1        no    yes   no        yes
## 306    other          1         2        1        no    yes  yes        yes
## 307    other          1         1        0        no     no   no        yes
## 308    other          2         1        1        no    yes  yes         no
## 310    other          1         2        1       yes    yes   no        yes
## 311    other          1         2        1        no     no   no        yes
## 312    other          3         2        0        no    yes   no         no
## 313    other          1         2        1        no     no   no         no
## 314    other          2         2        1        no    yes  yes         no
## 315    other          1         3        2        no     no   no         no
## 316    other          1         3        1        no     no   no         no
## 317   mother          2         2        0        no    yes  yes        yes
## 318   mother          1         3        0        no    yes  yes        yes
## 320   mother          1         2        0        no    yes  yes         no
## 321   mother          1         2        0        no    yes  yes         no
## 323   mother          1         3        0        no    yes  yes        yes
## 325   father          2         3        0        no     no   no         no
## 326   mother          1         3        0        no     no   no        yes
## 327   mother          1         1        0        no     no   no        yes
## 328   mother          4         1        0        no    yes   no         no
## 329   mother          1         3        0        no    yes  yes        yes
## 330   mother          2         3        0        no    yes  yes         no
## 331   mother          1         4        0        no    yes   no        yes
## 334    other          1         2        0        no     no   no        yes
## 335   mother          2         4        0        no     no   no        yes
## 336   mother          1         3        0        no     no   no         no
## 337    other          1         3        1        no     no  yes         no
## 339   mother          1         4        0        no    yes   no         no
## 340   mother          1         2        0        no    yes  yes         no
## 341    other          1         3        1        no     no  yes        yes
## 342   father          1         2        1        no    yes   no        yes
## 346   mother          1         3        0        no     no   no         no
## 348   mother          1         3        0        no    yes  yes         no
## 349   mother          1         3        0        no    yes  yes        yes
## 350   mother          2         1        1        no    yes   no         no
## 351    other          3         2        3        no     no   no         no
## 352   mother          2         2        0        no    yes  yes         no
## 353   mother          1         1        1        no     no   no         no
## 355   mother          2         2        0        no    yes  yes        yes
## 356   father          1         2        0        no    yes   no         no
## 358   mother          2         2        0        no     no   no         no
## 359   father          2         1        0        no     no   no         no
## 360   father          2         3        0        no     no   no         no
## 363   mother          2         2        0        no    yes   no         no
## 364   mother          1         2        0        no    yes  yes        yes
## 365   father          2         2        0        no     no   no         no
## 366   mother          2         2        0        no    yes  yes         no
## 367   mother          2         3        0        no     no  yes         no
## 368   mother          3         1        1        no    yes  yes         no
## 369   father          2         1        0        no    yes  yes         no
## 371    other          2         2        2        no     no   no        yes
## 372   father          3         1        0        no    yes  yes        yes
## 373   mother          1         3        0        no     no   no        yes
## 374   mother          1         1        0        no     no   no        yes
## 375   mother          2         3        0        no     no   no         no
## 376   mother          4         3        0        no     no   no         no
## 377    other          2         3        2        no    yes  yes         no
## 378   mother          1         2        0        no     no  yes        yes
## 379   mother          1         2        0        no     no  yes         no
## 380   mother          1         2        0        no    yes  yes        yes
## 382   mother          2         1        0        no     no   no        yes
## 384   mother          2         1        1        no     no   no         no
## 385   father          2         1        1        no     no  yes         no
## 387   mother          3         1        0        no    yes  yes        yes
## 388   mother          1         3        1        no     no   no        yes
## 389   mother          1         2        0        no    yes  yes         no
## 391    other          1         2        2        no    yes  yes         no
## 392   mother          2         1        0        no     no   no         no
## 393    other          1         1        3        no     no   no         no
## 394   mother          3         1        0        no     no   no         no
## 395   father          1         1        0        no     no   no         no
##     nursery higher internet romantic famrel freetime goout Dalc Walc health
## 1       yes    yes       no       no      4        3     4    1    1      3
## 2        no    yes      yes       no      5        3     3    1    1      3
## 4       yes    yes      yes      yes      3        2     2    1    1      5
## 5       yes    yes       no       no      4        3     2    1    2      5
## 6       yes    yes      yes       no      5        4     2    1    2      5
## 7       yes    yes      yes       no      4        4     4    1    1      3
## 8       yes    yes       no       no      4        1     4    1    1      1
## 9       yes    yes      yes       no      4        2     2    1    1      1
## 10      yes    yes      yes       no      5        5     1    1    1      5
## 11      yes    yes      yes       no      3        3     3    1    2      2
## 13      yes    yes      yes       no      4        3     3    1    3      5
## 15      yes    yes      yes      yes      4        5     2    1    1      3
## 16      yes    yes      yes       no      4        4     4    1    2      2
## 18      yes    yes       no       no      5        3     2    1    1      4
## 19      yes    yes      yes       no      5        5     5    2    4      5
## 20      yes    yes      yes       no      3        1     3    1    3      5
## 21      yes    yes      yes       no      4        4     1    1    1      1
## 24      yes    yes      yes       no      5        4     4    2    4      5
## 25      yes    yes      yes       no      4        3     2    1    1      5
## 26       no    yes      yes       no      1        2     2    1    3      5
## 27      yes    yes      yes       no      4        2     2    1    2      5
## 29      yes    yes      yes       no      5        3     3    1    1      5
## 30      yes    yes      yes      yes      4        4     5    5    5      5
## 31       no    yes      yes       no      5        4     2    3    4      5
## 32      yes    yes      yes       no      4        3     1    1    1      5
## 35       no    yes      yes       no      5        4     3    1    1      5
## 36      yes    yes       no       no      3        5     1    1    1      5
## 37      yes    yes      yes       no      5        4     3    1    1      4
## 38      yes    yes      yes      yes      2        4     3    1    1      5
## 39      yes    yes      yes       no      4        3     2    1    1      5
## 40      yes    yes       no       no      4        3     1    1    1      2
## 41       no    yes      yes      yes      3        3     3    1    2      3
## 43      yes    yes      yes       no      4        3     3    1    1      5
## 45      yes    yes      yes       no      4        3     3    2    2      5
## 46      yes    yes      yes      yes      5        2     2    1    1      5
## 47      yes    yes      yes       no      2        3     5    1    4      3
## 49      yes    yes       no       no      4        3     3    2    2      5
## 50       no    yes      yes       no      4        4     4    1    1      3
## 51      yes    yes      yes       no      4        3     3    2    3      4
## 52      yes    yes      yes       no      4        3     3    1    1      5
## 53      yes    yes       no       no      5        5     5    3    4      5
## 54      yes    yes      yes       no      3        3     4    2    3      5
## 55      yes    yes      yes       no      5        3     4    4    4      1
## 56      yes    yes      yes      yes      5        3     4    1    1      2
## 57      yes    yes      yes       no      4        3     2    1    1      1
## 58      yes    yes       no       no      3        2     2    1    1      5
## 59      yes    yes      yes       no      4        3     2    1    1      5
## 60      yes    yes      yes       no      4        2     3    1    1      5
## 61      yes    yes       no       no      2        4     4    2    3      4
## 62       no    yes      yes      yes      5        5     5    5    5      5
## 63      yes    yes      yes       no      4        4     3    1    1      1
## 64      yes    yes      yes       no      3        4     4    2    4      4
## 65      yes    yes      yes      yes      4        4     4    2    4      2
## 66      yes    yes      yes       no      5        4     3    1    2      1
## 67       no    yes      yes      yes      1        3     3    5    5      3
## 68      yes    yes      yes       no      4        3     3    1    2      5
## 70       no    yes      yes       no      4        4     2    2    3      3
## 71      yes    yes      yes       no      4        3     2    1    1      5
## 72      yes    yes      yes       no      3        3     3    1    1      3
## 73       no    yes      yes      yes      3        3     4    2    4      5
## 74      yes    yes       no       no      5        3     2    2    2      5
## 75      yes    yes      yes       no      4        3     3    2    4      5
## 77      yes    yes      yes       no      3        4     3    1    1      1
## 78      yes    yes      yes      yes      5        2     3    1    3      3
## 79      yes     no      yes       no      4        5     1    1    1      3
## 82       no    yes      yes       no      5        3     2    1    2      5
## 83      yes    yes      yes       no      4        4     4    1    1      5
## 84      yes    yes      yes       no      5        3     3    1    3      4
## 85       no    yes      yes       no      4        3     2    2    3      4
## 87      yes    yes       no       no      4        3     4    1    2      2
## 90      yes    yes       no       no      4        1     3    3    5      5
## 92      yes    yes      yes       no      4        5     5    1    3      1
## 93      yes    yes       no       no      3        3     3    2    3      2
## 95      yes    yes      yes       no      4        3     4    1    1      4
## 96      yes    yes      yes       no      3        1     2    1    1      1
## 98      yes    yes       no      yes      4        3     5    1    1      5
## 99       no    yes      yes       no      5        3     4    1    2      1
## 100     yes    yes      yes       no      5        3     5    1    1      3
## 101     yes    yes      yes       no      4        5     5    5    5      4
## 102     yes    yes      yes      yes      4        4     3    1    1      4
## 103      no    yes      yes       no      5        3     3    1    1      5
## 104     yes    yes      yes       no      4        3     5    1    1      2
## 105     yes    yes      yes       no      5        4     4    1    1      1
## 106     yes    yes       no       no      4        3     3    1    1      4
## 107     yes    yes      yes       no      5        1     2    1    1      3
## 108     yes    yes      yes       no      5        3     3    1    1      5
## 109     yes    yes      yes      yes      1        3     5    3    5      1
## 110     yes    yes      yes      yes      5        4     5    1    1      4
## 111     yes    yes      yes       no      5        5     3    1    1      4
## 112     yes    yes      yes       no      4        1     2    1    1      2
## 113     yes    yes      yes       no      3        1     2    1    1      5
## 114     yes    yes      yes       no      3        5     2    1    1      3
## 117     yes    yes       no       no      4        4     3    1    1      2
## 118     yes    yes      yes       no      5        4     2    1    1      5
## 120     yes    yes      yes       no      3        4     3    1    2      4
## 121      no    yes      yes       no      3        2     3    1    2      1
## 124     yes    yes      yes       no      3        4     4    1    4      5
## 125     yes    yes      yes      yes      5        4     4    1    1      5
## 126     yes    yes      yes       no      5        5     5    3    2      5
## 127     yes    yes      yes      yes      5        3     2    1    1      1
## 128      no     no       no       no      3        4     2    1    1      5
## 129     yes    yes      yes       no      3        3     3    1    2      4
## 130     yes    yes      yes       no      3        5     5    2    5      4
## 131     yes    yes      yes      yes      4        2     2    2    2      5
## 132      no    yes      yes      yes      4        3     3    1    2      4
## 133     yes    yes      yes      yes      3        4     4    1    3      5
## 134     yes    yes      yes       no      3        2     1    1    4      5
## 135     yes    yes       no      yes      5        3     3    1    1      5
## 138      no    yes      yes      yes      4        3     2    1    1      5
## 139     yes    yes       no      yes      4        4     4    1    3      5
## 140     yes    yes      yes       no      4        3     2    1    1      5
## 142     yes    yes      yes       no      2        3     3    2    2      2
## 143     yes    yes      yes       no      4        2     2    1    1      5
## 144     yes    yes      yes       no      3        4     4    3    3      1
## 145     yes    yes      yes       no      5        4     5    1    2      5
## 147     yes    yes      yes       no      3        3     2    1    1      3
## 148      no    yes      yes       no      4        3     2    1    1      5
## 150     yes    yes      yes       no      4        5     5    2    5      5
## 151     yes     no      yes      yes      2        3     5    2    5      4
## 152     yes    yes       no      yes      4        4     4    3    5      5
## 153     yes    yes      yes      yes      4        2     1    2    3      3
## 154     yes     no      yes      yes      4        5     4    1    1      4
## 155     yes    yes       no      yes      4        2     1    1    1      4
## 156     yes    yes       no       no      4        4     4    1    1      1
## 157     yes    yes       no       no      2        2     2    3    3      5
## 158      no    yes       no       no      5        2     5    1    5      4
## 159      no    yes       no       no      4        2     2    1    2      3
## 160     yes    yes      yes      yes      4        5     5    4    4      5
## 161     yes     no      yes      yes      3        3     2    2    2      5
## 162     yes    yes      yes      yes      4        4     4    1    4      3
## 163     yes    yes       no       no      4        4     4    2    4      5
## 164     yes     no      yes       no      5        3     3    1    4      2
## 165     yes     no       no      yes      5        3     5    1    5      5
## 166      no     no       no       no      4        5     2    1    1      2
## 168     yes    yes      yes      yes      4        2     3    1    1      3
## 170     yes    yes      yes      yes      4        4     2    1    1      3
## 172     yes    yes      yes      yes      4        3     2    1    1      3
## 174      no    yes      yes      yes      4        3     5    1    1      3
## 175     yes    yes      yes       no      4        4     5    1    1      4
## 178      no    yes      yes       no      4        3     4    1    4      4
## 180     yes    yes      yes      yes      5        2     3    1    1      2
## 181     yes    yes      yes       no      3        4     3    2    3      3
## 182     yes    yes      yes      yes      4        2     3    1    2      3
## 183     yes    yes       no       no      5        4     2    2    3      5
## 184     yes    yes      yes      yes      5        3     3    2    3      1
## 185     yes    yes      yes       no      1        2     2    1    2      1
## 186     yes    yes      yes      yes      4        3     4    2    3      4
## 187     yes    yes      yes      yes      3        3     3    1    2      3
## 188     yes    yes      yes      yes      4        2     3    1    2      5
## 189      no    yes      yes      yes      3        3     3    1    3      3
## 190     yes    yes       no       no      3        1     3    1    5      3
## 191     yes    yes      yes       no      4        3     3    1    1      2
## 192     yes    yes      yes       no      5        3     3    1    1      3
## 194     yes    yes      yes       no      4        3     2    3    4      5
## 195     yes    yes      yes       no      5        3     3    1    1      3
## 196     yes    yes      yes      yes      4        3     2    1    1      5
## 197     yes    yes      yes       no      5        2     3    1    2      5
## 198     yes    yes      yes       no      3        3     4    3    5      3
## 199     yes    yes      yes       no      4        2     4    2    3      2
## 201     yes    yes      yes       no      4        3     5    1    5      2
## 202     yes    yes       no       no      4        4     3    1    3      4
## 203      no    yes       no       no      4        4     4    1    3      1
## 204     yes    yes      yes       no      5        3     2    1    2      3
## 205      no    yes      yes       no      5        3     5    1    1      5
## 206     yes    yes      yes      yes      4        4     3    3    4      5
## 207     yes    yes      yes       no      2        3     3    2    2      4
## 208     yes    yes      yes      yes      1        3     2    1    1      1
## 209     yes    yes       no       no      4        3     2    1    4      5
## 210     yes    yes      yes      yes      4        4     2    1    1      4
## 211     yes    yes      yes       no      4        3     3    1    2      3
## 212     yes    yes      yes      yes      5        3     5    4    5      3
## 213     yes    yes      yes       no      3        3     4    1    1      4
## 214     yes    yes      yes       no      4        4     4    2    4      5
## 215     yes    yes       no       no      5        2     1    1    2      3
## 217     yes    yes      yes      yes      3        4     5    2    4      1
## 218     yes    yes      yes       no      3        2     4    2    4      4
## 219     yes    yes       no       no      3        3     3    1    4      3
## 220     yes    yes      yes       no      4        3     3    1    1      4
## 221     yes    yes      yes       no      4        2     5    1    2      5
## 222     yes    yes       no      yes      4        3     4    1    1      5
## 223     yes    yes      yes       no      2        3     1    1    1      3
## 224     yes    yes      yes       no      3        3     3    5    5      4
## 225      no    yes      yes       no      5        3     2    1    1      5
## 226     yes    yes      yes      yes      5        3     3    1    1      4
## 229     yes    yes      yes      yes      4        3     2    4    5      3
## 231     yes    yes      yes      yes      3        2     3    1    2      3
## 233     yes    yes      yes      yes      4        5     5    1    3      2
## 234     yes    yes      yes       no      4        2     4    2    4      1
## 235     yes    yes      yes       no      3        4     2    1    1      5
## 237      no    yes      yes      yes      4        4     2    5    5      4
## 239     yes    yes       no       no      2        1     1    1    1      3
## 240     yes     no      yes       no      5        5     4    3    5      2
## 241     yes    yes      yes      yes      2        5     5    1    4      5
## 242     yes    yes      yes       no      3        3     3    2    3      4
## 243      no    yes      yes       no      5        4     5    1    1      3
## 245      no    yes      yes      yes      4        4     4    1    1      3
## 246     yes    yes      yes       no      4        3     3    1    1      4
## 247     yes    yes      yes       no      5        2     2    1    1      2
## 248      no     no      yes      yes      5        4     5    5    5      1
## 249     yes    yes      yes      yes      4        3     3    1    3      5
## 250      no    yes      yes       no      4        3     2    2    4      5
## 254      no    yes       no       no      3        3     2    1    3      3
## 255      no    yes      yes       no      4        4     2    2    4      5
## 256     yes    yes      yes       no      4        4     4    1    2      5
## 257     yes    yes      yes       no      4        2     3    1    1      4
## 258     yes    yes      yes       no      4        3     1    1    1      1
## 259     yes    yes      yes       no      5        2     4    1    2      4
## 260     yes    yes      yes      yes      3        4     1    1    1      2
## 261     yes    yes      yes      yes      3        1     2    1    3      2
## 262      no    yes      yes       no      4        3     2    1    1      3
## 263      no    yes       no       no      5        3     2    1    1      3
## 264      no    yes       no       no      3        2     3    1    1      4
## 265     yes    yes      yes      yes      4        3     3    1    1      3
## 266     yes    yes      yes       no      4        2     5    3    4      1
## 267     yes    yes      yes      yes      5        4     4    3    4      5
## 269     yes    yes      yes      yes      5        4     5    1    3      5
## 270     yes     no      yes      yes      4        3     5    1    2      3
## 271     yes    yes      yes       no      4        3     5    3    3      5
## 272     yes    yes      yes      yes      4        5     5    1    3      2
## 273      no    yes       no       no      4        4     3    1    1      3
## 274      no    yes       no      yes      3        5     2    2    2      1
## 275     yes    yes      yes      yes      4        3     3    1    1      1
## 276     yes    yes      yes      yes      4        4     4    2    3      5
## 277      no     no      yes      yes      4        1     1    1    1      5
## 278     yes    yes      yes       no      3        2     4    1    4      3
## 279     yes    yes      yes      yes      2        4     4    1    1      4
## 280     yes    yes      yes       no      4        2     3    1    2      1
## 282     yes    yes      yes       no      4        4     4    3    4      3
## 283     yes    yes       no       no      5        2     2    1    1      3
## 285      no    yes      yes       no      5        4     5    1    2      5
## 287     yes    yes      yes       no      4        3     3    1    2      2
## 288     yes    yes      yes       no      4        3     3    1    1      3
## 289     yes    yes      yes       no      4        2     4    1    3      2
## 290     yes    yes      yes       no      5        4     3    1    1      2
## 291     yes    yes      yes      yes      4        3     2    1    4      5
## 292     yes    yes      yes       no      4        2     2    1    2      3
## 293     yes    yes      yes      yes      5        4     3    1    1      5
## 294     yes    yes       no       no      3        1     2    1    1      3
## 295     yes    yes      yes       no      5        4     2    1    1      4
## 296     yes    yes      yes       no      4        4     3    1    3      5
## 297     yes    yes      yes       no      2        3     4    2    3      2
## 298     yes    yes      yes      yes      4        4     5    1    2      2
## 299     yes    yes      yes       no      4        3     3    1    1      3
## 300     yes    yes      yes      yes      1        4     2    2    2      1
## 301     yes    yes      yes      yes      4        2     4    1    1      4
## 302     yes    yes      yes       no      4        1     1    2    2      5
## 303     yes    yes      yes       no      4        3     3    1    1      3
## 305     yes    yes      yes      yes      4        4     4    1    1      3
## 306     yes    yes      yes       no      4        4     3    1    1      3
## 307     yes    yes       no       no      5        5     3    1    1      5
## 308     yes    yes      yes      yes      4        3     4    1    1      4
## 310      no    yes      yes       no      4        4     3    1    3      3
## 311      no    yes       no      yes      4        2     4    2    2      3
## 312     yes     no      yes      yes      3        4     1    1    1      2
## 313      no    yes      yes       no      4        5     2    2    2      4
## 314      no    yes      yes      yes      4        2     2    1    2      1
## 315      no    yes      yes      yes      4        1     2    1    1      3
## 316     yes    yes      yes      yes      4        1     2    1    1      3
## 317     yes    yes      yes       no      5        3     3    1    2      1
## 318     yes    yes      yes      yes      4        3     4    1    1      5
## 320     yes    yes      yes       no      4        4     4    3    3      5
## 321     yes    yes      yes      yes      5        2     2    1    2      5
## 323     yes    yes      yes       no      3        3     2    2    2      3
## 325     yes    yes      yes       no      3        3     3    2    3      2
## 326     yes    yes      yes       no      4        3     3    2    2      3
## 327      no    yes      yes       no      4        3     5    3    5      5
## 328     yes    yes      yes       no      4        4     5    5    5      4
## 329     yes    yes      yes       no      5        4     4    1    3      4
## 330      no    yes      yes      yes      4        3     3    1    2      4
## 331     yes    yes      yes       no      4        5     5    2    4      5
## 334      no    yes      yes      yes      4        3     3    1    1      2
## 335     yes    yes       no       no      4        4     4    1    1      4
## 336     yes    yes      yes       no      4        4     5    1    3      5
## 337     yes    yes       no       no      5        4     3    1    2      5
## 339     yes    yes      yes       no      5        3     3    1    1      1
## 340     yes    yes      yes       no      4        3     3    2    3      2
## 341     yes    yes      yes      yes      4        3     4    1    3      3
## 342     yes    yes      yes       no      4        3     3    2    2      2
## 346     yes    yes      yes      yes      5        4     3    2    3      1
## 348     yes    yes      yes      yes      5        4     5    2    3      5
## 349     yes    yes      yes      yes      4        4     3    1    3      4
## 350      no    yes      yes       no      2        5     5    5    5      5
## 351     yes    yes      yes       no      5        4     4    3    3      2
## 352     yes    yes      yes       no      4        5     4    2    3      3
## 353     yes     no      yes      yes      4        3     3    2    3      3
## 355      no    yes      yes      yes      4        5     5    1    3      2
## 356     yes    yes       no      yes      5        3     4    1    1      5
## 358     yes    yes       no      yes      1        2     3    1    2      5
## 359      no    yes      yes      yes      3        3     2    1    2      3
## 360     yes    yes      yes       no      5        3     2    1    1      4
## 363     yes    yes      yes      yes      4        3     2    1    3      3
## 364     yes    yes      yes      yes      2        3     4    1    1      1
## 365      no    yes       no       no      3        2     2    1    2      3
## 366     yes    yes       no       no      3        3     4    2    4      3
## 367     yes    yes      yes      yes      4        2     2    2    2      5
## 368     yes    yes      yes      yes      5        2     1    1    2      1
## 369     yes    yes      yes      yes      5        2     3    1    2      4
## 371     yes    yes       no      yes      3        2     2    1    1      3
## 372     yes     no      yes      yes      4        3     3    2    3      3
## 373     yes    yes       no      yes      3        4     3    1    1      3
## 374     yes    yes      yes       no      3        5     5    1    3      1
## 375     yes    yes      yes       no      5        4     4    1    1      1
## 376     yes    yes      yes       no      4        3     2    1    2      4
## 377      no    yes      yes      yes      5        4     3    1    1      3
## 378     yes    yes      yes       no      5        4     3    3    4      2
## 379     yes    yes      yes      yes      4        1     3    1    2      1
## 380      no    yes      yes       no      4        5     4    2    3      1
## 382      no    yes      yes      yes      4        4     3    1    3      5
## 384     yes    yes       no       no      4        3     2    1    3      5
## 385     yes    yes       no       no      5        4     3    4    3      3
## 387     yes    yes      yes      yes      4        4     3    2    2      5
## 388      no    yes      yes       no      5        4     2    1    2      5
## 389     yes    yes      yes       no      4        3     4    1    1      1
## 391     yes    yes       no       no      5        5     4    4    5      4
## 392      no    yes      yes       no      2        4     5    3    4      2
## 393      no    yes       no       no      5        5     3    3    3      3
## 394      no    yes      yes       no      4        4     1    3    4      5
## 395     yes    yes      yes       no      3        2     3    3    3      5
##     absences G1 G2 G3
## 1          6  5  6  6
## 2          4  5  5  6
## 4          2 15 14 15
## 5          4  6 10 10
## 6         10 15 15 15
## 7          0 12 12 11
## 8          6  6  5  6
## 9          0 16 18 19
## 10         0 14 15 15
## 11         0 10  8  9
## 13         2 14 14 14
## 15         0 14 16 16
## 16         4 14 14 14
## 18         4  8 10 10
## 19        16  6  5  5
## 20         4  8 10 10
## 21         0 13 14 15
## 24         0 13 13 12
## 25         2 10  9  8
## 26        14  6  9  8
## 27         2 12 12 11
## 29         4 11 11 11
## 30        16 10 12 11
## 31         0  9 11 12
## 32         0 17 16 17
## 35         0 12 14 15
## 36         0  8  7  6
## 37         2 15 16 18
## 38         7 15 16 15
## 39         2 12 12 11
## 40         8 14 13 13
## 41        25  7 10 11
## 43         2 19 18 18
## 45        14 10 10  9
## 46         8  8  8  6
## 47        12 11 12 11
## 49         2 15 15 14
## 50         2  7  7  7
## 51         2 12 13 13
## 52         2 11 13 13
## 53         6 11 11 10
## 54         0  8 10 11
## 55         6 10 13 13
## 56         8  8  9 10
## 57         0 14 15 15
## 58         4 14 15 15
## 59         2  9 10  9
## 60         2 15 16 16
## 61         6 10 11 11
## 62         6 10  8 11
## 63         4  8 10  9
## 64         2 10  9  9
## 65         0 10 10 10
## 66         2 16 15 15
## 67         4 13 13 12
## 68         4  7  7  6
## 70        12 16 16 16
## 71         0 13 15 15
## 72         0 10 10 10
## 73         2  8  6  5
## 74         2 12 12 14
## 75        54 11 12 11
## 77         8 11 11 10
## 78         0 11 11 11
## 79         2  8  8 10
## 82         4 11 10 11
## 83        10  7  6  6
## 84         4 15 15 15
## 85         2  9 10 10
## 87         4  8  7  6
## 90        18  8  6  7
## 92         4 16 17 18
## 93         4  7  6  6
## 95         6 11 13 14
## 96         2  7 10 10
## 98         2  8  9 10
## 99         6 11 14 14
## 100        0  7  9  8
## 101       14  7  7  5
## 102        0 16 17 17
## 103        4 10 13 14
## 104       26  7  6  6
## 105        0 16 18 18
## 106       10 10 11 11
## 107        8  7  8  8
## 108        2 16 18 18
## 109        6 10 13 13
## 110        4 14 15 16
## 111        6 18 19 19
## 112        0  7 10 10
## 113        6 10 13 13
## 114       10 18 19 19
## 117        2 11 13 14
## 118        0 13 14 13
## 120        6 14 13 13
## 121        2 16 15 15
## 124       18 14 11 13
## 125        0  8  7  8
## 126        0 13 13 12
## 127        0  7 10 11
## 128        2  7  8  9
## 129        0  7  4  0
## 130        8 18 18 18
## 131        0 12  0  0
## 132        0  8  0  0
## 133       12 10 13 12
## 134       16 12 11 11
## 135        0  9  0  0
## 138        0  4  0  0
## 139        0 14 12 12
## 140        0 16 16 15
## 142        8  9  9  9
## 143        2  9 11 11
## 144        2 14 14 13
## 145        0  5  0  0
## 147        0  6  7  0
## 148        2 10 11 11
## 150        0  8  9 10
## 151        0  6  5  0
## 152        6 12 13 14
## 153        8 10 10 10
## 154        0  5  0  0
## 155        0 11 11 12
## 156        2 11  8  8
## 157        8 16 12 13
## 158        6  9  8 10
## 159        2 17 15 15
## 160        4 10 12 12
## 161        0  7  6  0
## 162        6  5  9  7
## 163        0  7  0  0
## 164        2 10 10 10
## 165        0  5  8  7
## 166       16 12 11 12
## 168        0 14 15 16
## 170        0 14 14 14
## 172        2 13 15 16
## 174        0  8  7  0
## 175        4 10 11  9
## 178        4  6  5  6
## 180        4 10 10 11
## 181       10  9  8  8
## 182        2 12 13 12
## 183        0 16 17 17
## 184       56  9  9  8
## 185       14 12 13 12
## 186       12 12 12 11
## 187        2 11 12 11
## 188        0 15 15 15
## 189        6  8  7  9
## 190        4  8  9 10
## 191       10 11 12 13
## 192        0  8  8  9
## 194        8  8  9 10
## 195        0 13 14 14
## 196        0 14 15 15
## 197        4 17 15 16
## 198        8  9  9 10
## 199       24 18 18 18
## 201        2 16 16 16
## 202        6  8 10 10
## 203        4  9  9 10
## 204       18  7  6  6
## 205        6 10 10 11
## 206       28 10  9  9
## 207        5  7  7  7
## 208       10 11 12 13
## 209        6  9  9 10
## 210        6  7  7  7
## 211       10  8  8  8
## 212       13 12 12 13
## 213        0 12 13 14
## 214       15  6  7  8
## 215       12  8 10 10
## 217       22  6  6  4
## 218       13  6  6  8
## 219        3  7  7  8
## 220        4  9 10 10
## 221        2  6  6  6
## 222        0  6  5  0
## 223        2 16 16 17
## 224        0 12 13 13
## 225        0 13 13 14
## 226       16  9  8  7
## 229       14 10  8  9
## 231       14 13 13 14
## 233       14 11  9  9
## 234        2 14 13 13
## 235       18  9  7  6
## 237        4 14 13 13
## 239        2 13 11 11
## 240        0  7  7  0
## 241       14 12 12 12
## 242        2 10 11 12
## 243        0  6  0  0
## 245        0  7  0  0
## 246        6 18 18 18
## 247        4 12 12 13
## 248       16  6  8  8
## 249        8  3  5  5
## 250        0 13 15 15
## 254        0  8  9  8
## 255        0  8 12 12
## 256        2  7  9  8
## 257        6 14 12 13
## 258       12 11 11 11
## 259        8 15 14 14
## 260        0 10  9  0
## 261       21 17 18 18
## 262        2  8  8  8
## 263        1 13 12 12
## 264        4 10  9  9
## 265        0  9 10  0
## 266       13 17 17 17
## 267        2  9  9 10
## 269       10 10  9 10
## 270        0  6  0  0
## 271       15  9  9  9
## 272        4 15 14 14
## 273        2 11 11 11
## 274        2 15 14 14
## 275        2 10 10 10
## 276        6 12 12 12
## 277       75 10  9  9
## 278       22  9  9  9
## 279       15  9  8  8
## 280        8 10 11 10
## 282       19 11  9 10
## 283        1 12 12 12
## 285        4 10  9 11
## 287        5 18 18 19
## 288        6 13 12 12
## 289        6 15 14 14
## 290        9 15 13 15
## 291       11 12 11 11
## 292        0 15 15 15
## 293       12 12 12 13
## 294        6 18 18 18
## 295        8 14 13 14
## 296        4 14 12 11
## 297        0 10  9  0
## 298       10 10  8  8
## 299        0 14 13 14
## 300        5 16 15 16
## 301       14 12 10 11
## 302        0 11 11 10
## 303        0 15 12 14
## 305       20 15 14 13
## 306        8 14 12 12
## 307        0 17 18 18
## 308       38  8  9  8
## 310       18 12 10 10
## 311        0  9  9  0
## 312       20 14 12 13
## 313        3 13 11 11
## 314       22 13 10 11
## 315       14 15 13 13
## 316       40 13 11 11
## 317        0  8  8  0
## 318        9  9 10  9
## 320        2 11 11 11
## 321       23 13 13 13
## 323        3 11 11 11
## 325        0 16 15 15
## 326        3  9 12 11
## 327        3 14 15 16
## 328        8 11 10 10
## 329        7 10  9  9
## 330        4 14 14 14
## 331        2  9  8  8
## 334        0  8  8  0
## 335        0 10  9  0
## 336       16 16 15 15
## 337       12 14 13 13
## 339        7 16 15 17
## 340        4  9 10 10
## 341        4 11 12 11
## 342        0 10 10  0
## 346        7 13 13 14
## 348        0 10 10  9
## 349        0 13 15 15
## 350       10 11 13 13
## 351        8  8  7  8
## 352        2 13 13 13
## 353        7  8  7  8
## 355        4 13 11 11
## 356        0 10  9  9
## 358        2 12 12 11
## 359        4 10 10 10
## 360        0 18 16 16
## 363        0 11 11 10
## 364        0 16 15 15
## 365        0 12 11 12
## 366        4 10 10 10
## 367        0 13 13 13
## 368        0  7  6  0
## 369        0 11 10 10
## 371        4  7  7  9
## 372        3 14 12 12
## 373        8 13 11 11
## 374       14  6  5  5
## 375        0 19 18 19
## 376        2  8  8 10
## 377        4 15 14 15
## 378        4  8  9 10
## 379        0 15 15 15
## 380       17 10 10 10
## 382        5  7  6  7
## 384        0  6  5  0
## 385       14  6  5  5
## 387        7  6  5  6
## 388        0  7  5  0
## 389        0  7  9  8
## 391       11  9  9  9
## 392        3 14 16 16
## 393        3 10  8  7
## 394        0 11 12 10
## 395        5  8  9  9
dim(training)
## [1] 318  33
test= student[-partition,]
dim(test)
## [1] 77 33
colSums(is.na(training))
##     school        sex        age    address    famsize    Pstatus       Medu 
##          0        318          0          0        318        318          0 
##       Fedu       Mjob       Fjob     reason   guardian traveltime  studytime 
##          0        318        318          0          0          0          0 
##   failures  schoolsup     famsup       paid activities    nursery     higher 
##          0          0          0          0          0          0          0 
##   internet   romantic     famrel   freetime      goout       Dalc       Walc 
##          0          0          0          0          0          0          0 
##     health   absences         G1         G2         G3 
##          0          0          0          0          0
training$sex=ifelse(is.na(training$sex),ave(training$sex,FUN=function(x)mean(x,na.rm=TRUE)),training$sex)

Saya memiliki 318 data training dan 77 untuk data test.

6.2 Membentuk Model Regresi

Saya membentuk model regresi menggunakan data training dengan target untuk memprediksi variabel G3 (nilai akhir) menggunakan variabel independen yang berkorelasi dengan variabel G3.

library(lmtest)

lin_mod=lm(G3~G1+G2+age+Medu+Fedu+traveltime+studytime+famrel+freetime+goout+Dalc+Walc+health+absences ,data=training)
summary(lin_mod)
## 
## Call:
## lm(formula = G3 ~ G1 + G2 + age + Medu + Fedu + traveltime + 
##     studytime + famrel + freetime + goout + Dalc + Walc + health + 
##     absences, data = training)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.9799 -0.3885  0.3229  0.9790  3.4049 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.319688   1.694429   0.189   0.8505    
## G1           0.142247   0.064837   2.194   0.0290 *  
## G2           0.982298   0.058345  16.836   <2e-16 ***
## age         -0.210280   0.086137  -2.441   0.0152 *  
## Medu         0.202523   0.127508   1.588   0.1133    
## Fedu        -0.131879   0.128031  -1.030   0.3038    
## traveltime   0.159337   0.156416   1.019   0.3092    
## studytime   -0.134031   0.129055  -1.039   0.2998    
## famrel       0.232101   0.119714   1.939   0.0535 .  
## freetime    -0.043784   0.115631  -0.379   0.7052    
## goout        0.002702   0.108811   0.025   0.9802    
## Dalc        -0.089969   0.156669  -0.574   0.5662    
## Walc         0.125015   0.119758   1.044   0.2974    
## health       0.075362   0.076823   0.981   0.3274    
## absences     0.032301   0.012905   2.503   0.0128 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.854 on 303 degrees of freedom
## Multiple R-squared:  0.8409, Adjusted R-squared:  0.8336 
## F-statistic: 114.4 on 14 and 303 DF,  p-value: < 2.2e-16

Model yang dibuat menggunakan multiple predictor sehingga nilai yang baik diinterpretasikan adalah nilai Adjusted R-squared. Dari hasi diatas, model ini memiliki nilai Adjusted R-squared : 0.8336 atau 83,36% yang artinya hubungan antara variabel independen dan variabel dependen sangat kuat.

6.3 Memprediksi nilai data test

selanjutnya, saya memprediksi data test dengan model linear dari data training.

pred_test <- predict(lin_mod, test)

6.4 Evaluasi Model Regresi Berganda

Metrik yang akan digunakan dalam evaluasi ini adalah MAE. Kinerja model bagus jika nilai MAE rendah. Jadi kami ingin nilai MAE rendah.

Mean Absolute Error (MAE): MAE mengukur besaran rata-rata kesalahan dalam serangkaian prediksi, tanpa mempertimbangkan arahnya. Ini rata-rata atas sampel uji perbedaan absolut antara prediksi dan pengamatan aktual di mana semua perbedaan individu memiliki berat yang sama.

cat("Test MAE:", round(mean(abs(pred_test-test$G3)),6))
## Test MAE: 1.22893

Selanjutnya akan diperiksa apakah model cocok dengan menghitung pelatihan MAE dan membandingkannya dengan uji MAE.

pred_train <-predict(lin_mod, training)
cat("Train MAE:", round(mean(abs(pred_train-training$G3)),6))
## Train MAE: 1.142971

Data train dan uji MAE hampir serupa, jadi model ini tidak terlalu layak. Dari mengevaluasi model, nilai MAE rendah, sehingga model kami berkinerja baik.

7 Prediksi Nilai Akhir (G3)

dt_prediction = (data.frame((pred_test), (test$G3)))
colnames(dt_prediction) <- c("Predicted G3","Real G3")
head(dt_prediction,10)
##    Predicted G3 Real G3
## 3      7.528172      10
## 12    12.268653      12
## 14    10.320224      11
## 17    13.717834      14
## 22    15.317427      15
## 23    15.699660      16
## 28    16.499722      15
## 33    16.732923      16
## 34     9.449974      12
## 42    12.916717      12

Membandingkan nilai G3 yang diprediksi dengan nilai G3 nyata, sehingga dapat dilihat seberapa dekat prediksi kami dengan persentase kesalahan yang sangat kecil.