library(tidyverse)
library(kableExtra)
library(ggplot2)
library(ggthemes)
library(stringr)
library(reshape2)
library(mice)
library(nortest)
library(DescTools)
library(caret)
library(rpart)
library(rpart.plot)
library(ROCit)
library(PRROC)
library(ROCR)
library(vip)
df_authors_ok$Level <- as.factor(df_authors_ok$Level)
df_authors_ok$Program_Studi <- as.factor(df_authors_ok$Program_Studi)
df_authors_ok$Status <- as.factor(df_authors_ok$Status)
df_authors_ok$Akreditasi <- as.factor(df_authors_ok$Akreditasi)
#struktur data setelah formating
glimpse(df_authors_ok[,c("Level", "Program_Studi", "Status", "Akreditasi")])
## Rows: 2,342
## Columns: 4
## $ Level <fct> S1, S3, S3, NA, S2, S3, S1, Sp-1, NA, S1, S1, S1, Sp-1, ~
## $ Program_Studi <fct> Fisika, Keperawatan, Keperawatan, NA, Vaksinologi dan Im~
## $ Status <fct> Aktif, Aktif, Aktif, NA, Aktif, Aktif, Aktif, Aktif, NA,~
## $ Akreditasi <fct> Unggul, B, B, NA, Unggul, B, Unggul, A, NA, A, A, A, A, ~
levels(df_authors_ok$Level) #level awal
## [1] "D3" "D4" "Profesi" "S1" "S2" "S3" "Sp-1"
## [8] "Sp-2"
df_authors_ok$Level <- factor(df_authors_ok$Level,levels(df_authors_ok$Level)[c(1,2,5,6,3,4)]) #re-level
levels(df_authors_ok$Level) #setelah re-level
## [1] "D3" "D4" "S2" "S3" "Profesi" "S1"
levels(df_authors_ok$Akreditasi)
## [1] "-" "A" "B" "Baik" "Baik Sekali"
## [6] "Unggul"
#Membentuk rumpun ilmu berdasarkan kode prodi 2 digit
df_rumpun <- df_authors_ok %>%
select(Kode_Prodi,Program_Studi) %>%
group_by(Kode_Prodi,Program_Studi) %>%
summarize() %>%
mutate(Kode_Prodi_2Digit = substr(Kode_Prodi,1,2)) %>%
na.omit()
## `summarise()` has grouped output by 'Kode_Prodi'. You can override using the
## `.groups` argument.
df_rumpun
## # A tibble: 174 x 3
## # Groups: Kode_Prodi [174]
## Kode_Prodi Program_Studi Kode_Prodi_2Digit
## <dbl> <fct> <chr>
## 1 11001 Ilmu Kedokteran 11
## 2 11101 Ilmu Kedokteran Dasar 11
## 3 11103 Ilmu Kedokteran Klinik 11
## 4 11104 Ilmu Kedokteran Tropis 11
## 5 11105 Imunologi 11
## 6 11110 Vaksinologi dan Imunoterapetika 11
## 7 11122 Ilmu Kesehatan Olah Raga 11
## 8 11123 Teknik Biomedis 11
## 9 11124 Ilmu Forensik 11
## 10 11201 Kedokteran 11
## # ... with 164 more rows
#Membentuk rumpun ilmu berdasarkan kode prodi 2 digit
df_rumpun <- df_rumpun %>%
mutate(Rumpun_Ilmu = case_when(Kode_Prodi_2Digit %in% c(11:15,48) ~ "Kesehatan",
Kode_Prodi_2Digit %in% c(20,21,22,25,26,30,31,56) ~ "Teknik",
Kode_Prodi_2Digit %in% c(44,45,46,47,49,51,55,57) ~ "MIPA",
Kode_Prodi_2Digit==54 ~ "Perikanan, Kelautan, Fakultas Kedokteran Hewan",
Kode_Prodi_2Digit %in% c(60:63,93) ~ "Ekonomi",
Kode_Prodi_2Digit %in% c(64,67,68,69,70,71,73) ~ "Ilmu Sosial dan Ilmu Politik",
Kode_Prodi_2Digit==74 ~ "Hukum",
Kode_Prodi_2Digit %in% c(79:82) ~ "Ilmu dan Budaya",
Kode_Prodi_2Digit %in% c(83:90,94) ~ "Pendidikan",
Kode_Prodi_2Digit==93 ~ "Pariwisata",
Kode_Prodi_2Digit==95 ~ "Lingkungan"
))
df_rumpun
## # A tibble: 174 x 4
## # Groups: Kode_Prodi [174]
## Kode_Prodi Program_Studi Kode_Prodi_2Digit Rumpun_Ilmu
## <dbl> <fct> <chr> <chr>
## 1 11001 Ilmu Kedokteran 11 Kesehatan
## 2 11101 Ilmu Kedokteran Dasar 11 Kesehatan
## 3 11103 Ilmu Kedokteran Klinik 11 Kesehatan
## 4 11104 Ilmu Kedokteran Tropis 11 Kesehatan
## 5 11105 Imunologi 11 Kesehatan
## 6 11110 Vaksinologi dan Imunoterapetika 11 Kesehatan
## 7 11122 Ilmu Kesehatan Olah Raga 11 Kesehatan
## 8 11123 Teknik Biomedis 11 Kesehatan
## 9 11124 Ilmu Forensik 11 Kesehatan
## 10 11201 Kedokteran 11 Kesehatan
## # ... with 164 more rows
#dataframe rumpun ilmu yang akan digunakan untuk di merge dengan data awal
df_rumpun_oke <- df_rumpun %>% select(Kode_Prodi,Rumpun_Ilmu)
#struktur data
glimpse(df_authors_ok)
## Rows: 2,342
## Columns: 30
## $ SINTA_ID <dbl> 5976435, 256055, 257455, 6733821, 599210~
## $ Nama <chr> "MOH. YASIN", "FERRY EFENDI", "AH. YUSUF~
## $ Universitas <chr> "Universitas Airlangga", "Universitas Ai~
## $ Kode_Prodi <dbl> 45201, 14001, 14001, NA, 11110, 14001, 4~
## $ Departemen <chr> "S1 - Fisika", "S3 - Keperawatan", "S3 -~
## $ Jenjang.x <chr> "S1", "S3", "S3", "Unknown", "S2", "S3",~
## $ Program_Studi.x <chr> "Fisika", "Keperawatan", "Keperawatan", ~
## $ SINTA_Score_Overall <dbl> 5142, 4277, 2859, 1994, 3028, 2748, 2573~
## $ SINTA_Score_3Yr <dbl> 2278, 2172, 2037, 1709, 1684, 1673, 1663~
## $ Affil_Score <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Affil_Score_3Yr <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Scopus_Artikel <dbl> 236, 122, 71, 105, 137, 116, 87, 110, 93~
## $ Scopus_Citation <dbl> 1376, 702, 194, 656, 873, 359, 660, 966,~
## $ Scopus_H_Index <dbl> 18, 15, 7, 15, 17, 10, 14, 19, 19, 15, 1~
## $ GScholar_Artikel <dbl> 326, 257, 443, 151, 0, 425, 142, 208, 12~
## $ GScholar_Citation <dbl> 1933, 4269, 1982, 980, 0, 3592, 833, 151~
## $ GScholar_H_Index <dbl> 22, 25, 20, 16, 0, 21, 15, 22, 15, 19, 1~
## $ WOS_Artikel <dbl> 0, 55, 12, 0, 0, 0, 17, 76, 0, 0, 18, 36~
## $ WOS_Citation <dbl> 0, 344, 50, 0, 0, 0, 129, 849, 0, 0, 60,~
## $ WOS_H_Index <dbl> NA, 11, 4, NA, 0, NA, 6, 17, NA, NA, 4, ~
## $ index <dbl> 45, 196, 196, NA, 177, 196, 67, 107, NA,~
## $ Program_Studi <fct> Fisika, Keperawatan, Keperawatan, NA, Va~
## $ Status <fct> Aktif, Aktif, Aktif, NA, Aktif, Aktif, A~
## $ Level <fct> S1, S3, S3, NA, S2, S3, S1, NA, NA, S1, ~
## $ Akreditasi <fct> Unggul, B, B, NA, Unggul, B, Unggul, A, ~
## $ Jumlah_Dosen_Penghitung_Rasio <dbl> 65, 14, 14, NA, 13, 14, 55, 82, NA, 55, ~
## $ Jumlah_Dosen_NIDN <dbl> 21, 7, 7, NA, 6, 7, 20, 9, NA, 11, 13, 1~
## $ Jumlah_Dosen_NIDK <dbl> 0, 0, 0, NA, 0, 0, 0, 22, NA, 0, 0, 0, 0~
## $ Jumlah_Dosen_Total <dbl> 21, 7, 7, NA, 6, 7, 20, 31, NA, 11, 13, ~
## $ Jumlah_Mahasiswa <dbl> 360, 97, 97, NA, 20, 97, 442, 181, NA, 3~
Unit Observasi = Authors
y = SINTA_Score_3Yr yang dikategorisasi menjadi tinggi dan rendah
x1 = Rumpun Ilmu (Ganjil 2021)
x2 = Level (Ganjil 2021)
x3 = Akreditasi (Ganjil 2021)
x4 = Total Jumlah Dosen (Ganjil 2021)
x5 = Jumlah Mahasiswa (Ganjil 2021)
x6 = Rasio Dosen per Mahasiswa (Ganjil 2021)
data_1 <- df_authors_ok %>%
left_join(df_rumpun_oke, by="Kode_Prodi") %>%
select(SINTA_Score_3Yr,Program_Studi,Rumpun_Ilmu,Level,Akreditasi,Jumlah_Dosen_Total,Jumlah_Mahasiswa) %>%
mutate(Rasio_Dosen_per_Mahasiswa = df_authors_ok$Jumlah_Dosen_Penghitung_Rasio/df_authors_ok$Jumlah_Mahasiswa,
y = ifelse(SINTA_Score_3Yr>=219,"1","0")) #kelas 1:SINTA_Score_3Yr yang tinggi
data_1$y <- as.factor(data_1$y)
data_1$Rumpun_Ilmu <- as.factor(data_1$Rumpun_Ilmu)
str(data_1)
## tibble [2,342 x 9] (S3: tbl_df/tbl/data.frame)
## $ SINTA_Score_3Yr : num [1:2342] 2278 2172 2037 1709 1684 ...
## $ Program_Studi : Factor w/ 151 levels "Administrasi Dan Kebijakan Kesehatan",..: 30 83 83 NA 151 83 96 62 NA 143 ...
## $ Rumpun_Ilmu : Factor w/ 9 levels "Ekonomi","Hukum",..: 7 5 5 NA 5 5 7 5 NA 9 ...
## $ Level : Factor w/ 6 levels "D3","D4","S2",..: 6 4 4 NA 3 4 6 NA NA 6 ...
## $ Akreditasi : Factor w/ 6 levels "-","A","B","Baik",..: 6 3 3 NA 6 3 6 2 NA 2 ...
## $ Jumlah_Dosen_Total : num [1:2342] 21 7 7 NA 6 7 20 31 NA 11 ...
## $ Jumlah_Mahasiswa : num [1:2342] 360 97 97 NA 20 97 442 181 NA 334 ...
## $ Rasio_Dosen_per_Mahasiswa: num [1:2342] 0.181 0.144 0.144 NA 0.65 ...
## $ y : Factor w/ 2 levels "0","1": 2 2 2 2 2 2 2 2 2 2 ...
#Cek missing values
md.pattern(data_1,rotate.names = TRUE)
## SINTA_Score_3Yr y Program_Studi Rumpun_Ilmu Akreditasi Jumlah_Dosen_Total
## 1481 1 1 1 1 1 1
## 347 1 1 1 1 1 1
## 9 1 1 1 1 1 1
## 3 1 1 1 1 1 1
## 502 1 1 0 0 0 0
## 0 0 502 502 502 502
## Jumlah_Mahasiswa Rasio_Dosen_per_Mahasiswa Level
## 1481 1 1 1 0
## 347 1 1 0 1
## 9 1 0 1 1
## 3 1 0 0 2
## 502 0 0 0 7
## 502 514 852 3876
data_1 <- data_1 %>% filter(!is.na(Program_Studi),!is.na(Level),!is.na(Akreditasi),!is.na(Jumlah_Mahasiswa),!is.na(Jumlah_Dosen_Total),
Rasio_Dosen_per_Mahasiswa!=Inf)
head(data_1) #data yang akan digunakan
## # A tibble: 6 x 9
## SINTA_Score_3Yr Program_~1 Rumpu~2 Level Akred~3 Jumla~4 Jumla~5 Rasio~6 y
## <dbl> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <fct>
## 1 2278 Fisika MIPA S1 Unggul 21 360 0.181 1
## 2 2172 Keperawat~ Keseha~ S3 B 7 97 0.144 1
## 3 2037 Keperawat~ Keseha~ S3 B 7 97 0.144 1
## 4 1684 Vaksinolo~ Keseha~ S2 Unggul 6 20 0.65 1
## 5 1673 Keperawat~ Keseha~ S3 B 7 97 0.144 1
## 6 1663 Matematika MIPA S1 Unggul 20 442 0.124 1
## # ... with abbreviated variable names 1: Program_Studi, 2: Rumpun_Ilmu,
## # 3: Akreditasi, 4: Jumlah_Dosen_Total, 5: Jumlah_Mahasiswa,
## # 6: Rasio_Dosen_per_Mahasiswa
#format data yang dibutuhkan
data_chart <- data_1 %>%
group_by(y) %>%
summarize(value=n()) %>%
mutate(prop = round(value / sum(value) *100, digits = 2))
#pie chart: Sebaran Authors Berdasarkan Kategori SINTA_Score_3Yr
library(dplyr)
library(ggplot2)
library(scales)
## Warning: package 'scales' was built under R version 4.1.3
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
mycols <- c("#0073C2FF", "#EFC000FF")
ggplot(data_chart, aes(x="", y=prop, fill=y)) +
geom_bar(stat="identity", width=1, color="orange") +
coord_polar("y", start=0) +
labs(title= "Proporsi Authors Menurut Kategori SINTA_Score_3Yr",
subtitle = "Universitas Airlangga") +
theme_void()
#Density Jumlah_Dosen_Total
ggplot(data_1, aes(x=Jumlah_Dosen_Total)) +
geom_histogram(fill="orange", color="#e9ecef", alpha=0.8, bins=15)+
theme_light() +
labs(x="Jumlah_Dosen_Total",
y="Density",
title= "Sebaran Jumlah_Dosen_Total",
subtitle = "Universitas Airlangga")
#Density Jumlah_Mahasiswa
ggplot(data_1, aes(x=Jumlah_Mahasiswa)) +
geom_histogram(fill="orange", color="#e9ecef", alpha=0.8, bins=15)+
theme_light() +
labs(x="Jumlah_Mahasiswa",
y="Density",
title= "Sebaran Jumlah_Mahasiswa",
subtitle = "Universitas Airlangga")
#Density Rasio_Dosen_per_Mahasiswa
ggplot(data_1, aes(x=Rasio_Dosen_per_Mahasiswa)) +
geom_histogram(fill="orange", color="#e9ecef", alpha=0.8, bins=20)+
theme_light() +
labs(x="Rasio_Dosen_per_Mahasiswa",
y="Density",
title= "Sebaran Rasio_Dosen_per_Mahasiswa",
subtitle = "Universitas Airlangga")
### Peubah Prediktor (X) Kategorik
# Akreditasi
data_bar_chart = data_1 %>%
group_by(Akreditasi)%>%
summarize(Jumlah=n())
ggplot(data_bar_chart, aes(x=Akreditasi, y=Jumlah)) +
geom_bar(stat = "identity",fill = "orange",color="black") +
theme_light() +
labs(x="",
y="",
title= "",
subtitle = "Akreditasi Prodi Universitas Airlangga") +
coord_flip()
# Level
data_bar_chart = data_1 %>%
group_by(Level)%>%
summarize(Jumlah=n())
ggplot(data_bar_chart, aes(x=Level, y=Jumlah)) +
geom_bar(stat = "identity",fill ="orange",color="steelblue") +
theme_light() +
labs(x="",
y="",
title= "",
subtitle = "Level Prodi Universitas Airlangga") +
coord_flip()
# Rumpun Ilmu
data_bar_chart = data_1 %>%
group_by(Rumpun_Ilmu)%>%
summarize(Jumlah=n())
ggplot(data_bar_chart, aes(x=(Rumpun_Ilmu), y=Jumlah)) +
geom_bar(stat = "identity",fill = "orange",color="steelblue") +
theme_light() +
labs(x="",
y="",
title= "",
subtitle = "Rumpun Ilmu Jurusan Universitas Airlangga") +
coord_flip()
# Akreditasi & y
percentData <- data_1 %>%
group_by(Akreditasi) %>%
count(y) %>%
mutate(ratio=scales::percent(n/sum(n)))
ggplot(data_1,aes(x=factor(Akreditasi),fill=y,))+
geom_bar(position="fill")+
scale_fill_manual(values=c("orange", "chocolate"))+
geom_text(data=percentData, aes(y=n,label=ratio), color="white",position=position_fill(vjust=0.5))+
labs(
y = "Sinta Score",
x = "Akreditasi",
subtitle = "UNAIR",
title = "Proporsi Peubah Respon Menurut Akreditasi")
# Level & y
percentData <- data_1 %>%
group_by(Level) %>%
count(y) %>%
mutate(ratio=scales::percent(n/sum(n)))
ggplot(data_1,aes(x=factor(Level),fill=y,))+
geom_bar(position="fill")+
scale_fill_manual(values=c("orange", "chocolate"))+
geom_text(data=percentData, aes(y=n,label=ratio), color="white",position=position_fill(vjust=0.5))+
labs(
y = "Sinta Score",
x = "Level",
subtitle = "UNAIR",
title = "Proporsi Peubah Respon Menurut Level")
# Rumpun_Ilmu & y
percentData <- data_1 %>%
group_by(Rumpun_Ilmu) %>%
count(y) %>%
mutate(ratio=scales::percent(n/sum(n)))
ggplot(data_1,aes(x=factor(Rumpun_Ilmu),fill=y,))+
geom_bar(position="fill")+
scale_fill_manual(values=c("orange", "chocolate"))+
geom_text(data=percentData, aes(y=n,label=ratio), color="white",position=position_fill(vjust=0.5))+
labs(
y = "",
x = "Rumpun_Ilmu",
subtitle = "UNAIR",
title = "Proporsi Peubah Respon Menurut Rumpun Ilmu")
# Jumlah_Mahasiswa & y
#Boxplot by kategori
ggplot(data_1, aes(y=y,x=Jumlah_Mahasiswa,fill=Jumlah_Mahasiswa,alpha=Jumlah_Mahasiswa)) +
geom_boxplot(fill="darkorange1", alpha=0.8) +
theme_light() +
labs(x="Jumlah_Mahasiswa",
y="y",
title= "Sebaran Jumlah Mahasiswa Menurut Peubah Respon",
subtitle = "Universitas Airlangga")
# Jumlah_Dosen_Total & y
#Boxplot by kategori
ggplot(data_1, aes(y=y,x=Jumlah_Dosen_Total,fill=Jumlah_Dosen_Total,alpha=Jumlah_Dosen_Total)) +
geom_boxplot(fill="darkorange1", alpha=0.8) +
theme_light() +
labs(x="Jumlah_Dosen_Total",
y="y",
title= "Sebaran Jumlah Dosen Total Menurut Peubah Respon",
subtitle = "Universitas Airlangga")
# Rasio_Dosen_per_Mahasiswa & y
#Boxplot by kategori
ggplot(data_1, aes(y=y,x=Rasio_Dosen_per_Mahasiswa,fill=Rasio_Dosen_per_Mahasiswa,alpha=Rasio_Dosen_per_Mahasiswa)) +
geom_boxplot(fill="darkorange1", alpha=0.8) +
theme_light() +
labs(x="Rasio_Dosen_per_Mahasiswa",
y="y",
title= "Sebaran Rasio Dosen per Mahasiswa Menurut Peubah Respon",
subtitle = "Universitas Airlangga")
#data yang akan digunakan untuk model
data_sinta <- data_1 %>% select(-c(SINTA_Score_3Yr,Program_Studi))
str(data_sinta)
## tibble [1,481 x 7] (S3: tbl_df/tbl/data.frame)
## $ Rumpun_Ilmu : Factor w/ 9 levels "Ekonomi","Hukum",..: 7 5 5 5 5 7 9 7 9 1 ...
## $ Level : Factor w/ 6 levels "D3","D4","S2",..: 6 4 4 3 4 6 6 6 6 6 ...
## $ Akreditasi : Factor w/ 6 levels "-","A","B","Baik",..: 6 3 3 6 3 6 2 2 2 2 ...
## $ Jumlah_Dosen_Total : num [1:1481] 21 7 7 6 7 20 11 13 11 18 ...
## $ Jumlah_Mahasiswa : num [1:1481] 360 97 97 20 97 ...
## $ Rasio_Dosen_per_Mahasiswa: num [1:1481] 0.181 0.144 0.144 0.65 0.144 ...
## $ y : Factor w/ 2 levels "0","1": 2 2 2 2 2 2 2 2 2 2 ...
set.seed(478)
in.train <- createDataPartition(as.factor(data_sinta$y),p=0.7,list=F) #partisi data
data_sinta_train <- data_sinta[in.train,] #data training utk modelling
data_sinta_test<- data_sinta[-in.train,] #data testing utk evaluasi model
#proporsi kelas peubah respon pada data
round(prop.table(table(data_sinta_train$y)), digits = 4)
##
## 0 1
## 0.7351 0.2649
round(prop.table(table(data_sinta_test$y)), digits = 4)
##
## 0 1
## 0.7359 0.2641
model_reglog_1 <- glm(y~., data_sinta_train, family=binomial())
summary(model_reglog_1)
##
## Call:
## glm(formula = y ~ ., family = binomial(), data = data_sinta_train)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.8781 -0.7597 -0.5122 0.7744 2.9265
##
## Coefficients:
## Estimate Std. Error
## (Intercept) -3.062e+00 6.574e-01
## Rumpun_IlmuHukum -2.453e+00 8.072e-01
## Rumpun_IlmuIlmu dan Budaya -2.126e+00 1.047e+00
## Rumpun_IlmuIlmu Sosial dan Ilmu Politik -3.977e-01 4.130e-01
## Rumpun_IlmuKesehatan 1.279e+00 3.029e-01
## Rumpun_IlmuLingkungan -1.675e+01 1.297e+03
## Rumpun_IlmuMIPA 1.847e+00 4.068e-01
## Rumpun_IlmuPerikanan, Kelautan, Fakultas Kedokteran Hewan 1.320e+00 3.258e-01
## Rumpun_IlmuTeknik 2.285e+00 7.108e-01
## LevelD4 -1.551e+01 6.477e+02
## LevelS2 2.131e+00 4.612e-01
## LevelS3 3.094e+00 5.352e-01
## LevelProfesi 9.088e-01 5.218e-01
## LevelS1 9.360e-01 4.935e-01
## AkreditasiA -2.728e-01 4.966e-01
## AkreditasiB 1.213e-01 5.818e-01
## AkreditasiBaik 4.915e-01 8.063e-01
## AkreditasiBaik Sekali -2.636e-01 9.298e-01
## AkreditasiUnggul 1.289e-01 5.004e-01
## Jumlah_Dosen_Total -1.706e-02 7.936e-03
## Jumlah_Mahasiswa 8.198e-04 5.377e-04
## Rasio_Dosen_per_Mahasiswa 4.912e-02 4.566e-01
## z value Pr(>|z|)
## (Intercept) -4.658 3.19e-06 ***
## Rumpun_IlmuHukum -3.039 0.00237 **
## Rumpun_IlmuIlmu dan Budaya -2.030 0.04231 *
## Rumpun_IlmuIlmu Sosial dan Ilmu Politik -0.963 0.33557
## Rumpun_IlmuKesehatan 4.224 2.40e-05 ***
## Rumpun_IlmuLingkungan -0.013 0.98970
## Rumpun_IlmuMIPA 4.542 5.58e-06 ***
## Rumpun_IlmuPerikanan, Kelautan, Fakultas Kedokteran Hewan 4.053 5.06e-05 ***
## Rumpun_IlmuTeknik 3.214 0.00131 **
## LevelD4 -0.024 0.98089
## LevelS2 4.620 3.84e-06 ***
## LevelS3 5.781 7.41e-09 ***
## LevelProfesi 1.742 0.08155 .
## LevelS1 1.897 0.05788 .
## AkreditasiA -0.549 0.58282
## AkreditasiB 0.208 0.83486
## AkreditasiBaik 0.610 0.54218
## AkreditasiBaik Sekali -0.283 0.77682
## AkreditasiUnggul 0.258 0.79668
## Jumlah_Dosen_Total -2.150 0.03153 *
## Jumlah_Mahasiswa 1.525 0.12736
## Rasio_Dosen_per_Mahasiswa 0.108 0.91435
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 1200.25 on 1037 degrees of freedom
## Residual deviance: 966.89 on 1016 degrees of freedom
## AIC: 1010.9
##
## Number of Fisher Scoring iterations: 16
# Prediksi pada Data Training
prediksi_prob_data_train <- predict(model_reglog_1, data_sinta_train, type = "response")
prediksi_data_train <- as.factor(ifelse(prediksi_prob_data_train > 0.5,"1","0"))
prediksi_data_train
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
## 1 1 1 0 0 0 0 0 1 0 0 0 0 1 1 1
## 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
## 1 0 1 1 1 0 0 1 1 1 0 1 0 1 1 0
## 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
## 1 1 0 1 0 0 1 1 0 0 1 1 0 1 0 0
## 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
## 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 0
## 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
## 1 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0
## 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
## 1 0 0 1 0 1 1 1 0 0 0 0 1 1 0 1
## 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
## 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0
## 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
## 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0
## 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
## 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0
## 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
## 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1
## 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
## 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0
## 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
## 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0
## 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
## 0 1 0 0 0 0 1 0 0 0 0 0 1 0 1 1
## 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
## 0 1 0 1 0 0 0 1 0 0 0 1 0 0 1 0
## 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
## 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0
## 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
## 1 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0
## 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
## 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0
## 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
## 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0
## 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
## 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0
## 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
## 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0
## 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
## 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
## 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1
## 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
## 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0
## 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
## 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1
## 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
## 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0
## 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
## 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
## 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0
## 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
## 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
## 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1
## 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
## 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
## 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
## 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0
## 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
## 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
## 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
## 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
## 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
## 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0
## 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
## 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
## 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
## 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
## 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
## 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
## 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656
## 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
## 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
## 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
## 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0
## 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
## 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
## 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
## 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
## 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768
## 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
## 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784
## 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
## 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800
## 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
## 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
## 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880
## 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
## 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
## 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
## 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038
## 0 0 0 0 0 0 0 0 0 0 1 0 0 0
## Levels: 0 1
eval_reglog_1_train <- caret::confusionMatrix(prediksi_data_train, data_sinta_train$y, positive="1")
eval_reglog_1_train
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 702 184
## 1 61 91
##
## Accuracy : 0.764
## 95% CI : (0.7369, 0.7895)
## No Information Rate : 0.7351
## P-Value [Acc > NIR] : 0.01812
##
## Kappa : 0.2928
##
## Mcnemar's Test P-Value : 6.477e-15
##
## Sensitivity : 0.33091
## Specificity : 0.92005
## Pos Pred Value : 0.59868
## Neg Pred Value : 0.79233
## Prevalence : 0.26493
## Detection Rate : 0.08767
## Detection Prevalence : 0.14644
## Balanced Accuracy : 0.62548
##
## 'Positive' Class : 1
##
Sensitivity: kemampuan model dalam memprediksi kelaspositif
Specificity: kemampuan model dalam memprediksi kelasnegatif
# Prediksi pada Data Testing
prediksi_prob_data_test <- predict(model_reglog_1, data_sinta_test, type = "response")
prediksi_data_test <- as.factor(ifelse(prediksi_prob_data_test > 0.5,"1","0"))
prediksi_data_test
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0
## 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
## 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 0
## 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
## 1 0 0 0 1 0 1 1 0 1 0 1 0 0 1 0 0 0 1 0
## 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
## 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 0 1 0
## 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
## 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0
## 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
## 0 1 0 0 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0
## 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
## 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0
## 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
## 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 0
## 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
## 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
## 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
## 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
## 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
## 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0
## 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
## 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0
## 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
## 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
## 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
## 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 441 442 443
## 0 0 0
## Levels: 0 1
eval_reglog_1 <- caret::confusionMatrix(prediksi_data_test, data_sinta_test$y, positive="1")
eval_reglog_1
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 296 84
## 1 30 33
##
## Accuracy : 0.7427
## 95% CI : (0.6993, 0.7828)
## No Information Rate : 0.7359
## P-Value [Acc > NIR] : 0.3969
##
## Kappa : 0.223
##
## Mcnemar's Test P-Value : 6.909e-07
##
## Sensitivity : 0.28205
## Specificity : 0.90798
## Pos Pred Value : 0.52381
## Neg Pred Value : 0.77895
## Prevalence : 0.26411
## Detection Rate : 0.07449
## Detection Prevalence : 0.14221
## Balanced Accuracy : 0.59501
##
## 'Positive' Class : 1
##
Performa model pada data training dan data testing perlu diperhatikan untuk mengetahui adanya overfiting/underfiting
Overfiting terjadi ketika performa model pada data training jauh lebih tinggi jika dibandingkan dengan performa model pada data testing (mempelajari data terlalu baik)
Underfiting terjadi ketika performa model pada data testing jauh lebih tinggi jika dibandingkan dengan performa model pada data training (tidak mempelajari data dengan baik)
#fungsi utk membentuk plot ROC
rocplot=function(pred,truth, ...){
predob=ROCR::prediction(pred,truth)
perf=ROCR::performance(predob,"tpr","fpr")
auc=ROCR::performance(predob,"auc")@y.values
plot(perf,main = auc)
}
#ROC data training
rocplot(prediksi_prob_data_train,data_sinta_train$y)
#ROC data testing
rocplot(prediksi_prob_data_test,data_sinta_test$y)
#variable importance
vip(model_reglog_1,num_features = 50,)
model_reglog_2 <- glm(y~Level+Jumlah_Mahasiswa , data_sinta, family=binomial())
summary(model_reglog_2)
##
## Call:
## glm(formula = y ~ Level + Jumlah_Mahasiswa, family = binomial(),
## data = data_sinta)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.2297 -0.8519 -0.6143 1.1454 2.8187
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -1.7618942 0.3258366 -5.407 6.40e-08 ***
## LevelD4 -1.8610915 1.0609162 -1.754 0.079391 .
## LevelS2 1.3125667 0.3435387 3.821 0.000133 ***
## LevelS3 1.9160774 0.3746660 5.114 3.15e-07 ***
## LevelProfesi 0.7439566 0.4006039 1.857 0.063299 .
## LevelS1 1.4455213 0.3527444 4.098 4.17e-05 ***
## Jumlah_Mahasiswa -0.0011051 0.0002356 -4.691 2.72e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 1711.7 on 1480 degrees of freedom
## Residual deviance: 1604.5 on 1474 degrees of freedom
## AIC: 1618.5
##
## Number of Fisher Scoring iterations: 6
# Prediksi pada Data Training
prediksi_prob_data_train <- predict(model_reglog_2, data_sinta_train, type = "response")
prediksi_data_train <- as.factor(ifelse(prediksi_prob_data_train > 0.5,"1","0"))
eval_reglog_2_train <- caret::confusionMatrix(prediksi_data_train, data_sinta_train$y, positive="1")
eval_reglog_2_train
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 748 253
## 1 15 22
##
## Accuracy : 0.7418
## 95% CI : (0.714, 0.7682)
## No Information Rate : 0.7351
## P-Value [Acc > NIR] : 0.3254
##
## Kappa : 0.0834
##
## Mcnemar's Test P-Value : <2e-16
##
## Sensitivity : 0.08000
## Specificity : 0.98034
## Pos Pred Value : 0.59459
## Neg Pred Value : 0.74725
## Prevalence : 0.26493
## Detection Rate : 0.02119
## Detection Prevalence : 0.03565
## Balanced Accuracy : 0.53017
##
## 'Positive' Class : 1
##
rocplot(prediksi_prob_data_train,data_sinta_train$y)
# Prediksi pada Data Testing
prediksi_prob_data_test <- predict(model_reglog_2, data_sinta_test, type = "response")
prediksi_data_test <- as.factor(ifelse(prediksi_prob_data_test > 0.5,"1","0"))
eval_reglog_2 <- caret::confusionMatrix(prediksi_data_test, data_sinta_test$y, positive="1")
eval_reglog_2
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 318 108
## 1 8 9
##
## Accuracy : 0.7381
## 95% CI : (0.6946, 0.7785)
## No Information Rate : 0.7359
## P-Value [Acc > NIR] : 0.4819
##
## Kappa : 0.0722
##
## Mcnemar's Test P-Value : <2e-16
##
## Sensitivity : 0.07692
## Specificity : 0.97546
## Pos Pred Value : 0.52941
## Neg Pred Value : 0.74648
## Prevalence : 0.26411
## Detection Rate : 0.02032
## Detection Prevalence : 0.03837
## Balanced Accuracy : 0.52619
##
## 'Positive' Class : 1
##
rocplot(prediksi_prob_data_test,data_sinta_test$y)
vip(model_reglog_2, num_features = 100)
Model dengan hyperparameter
minsplitdancpdefault
model_tree_1 <- rpart(y ~., data = data_sinta_train, method = "class",
control=rpart.control(minsplit = 20, cp=0))
rpart.plot(model_tree_1, extra = 4)
# Prediksi pada Data Training
prediksi_prob_data_train <- predict(model_tree_1, data_sinta_train, type = "prob")
prediksi_data_train <- predict(model_tree_1, newdata=data_sinta_train, type = "class")
eval_tree_1_train <- caret::confusionMatrix(prediksi_data_train, data_sinta_train$y, positive="1")
eval_tree_1_train
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 718 159
## 1 45 116
##
## Accuracy : 0.8035
## 95% CI : (0.778, 0.8272)
## No Information Rate : 0.7351
## P-Value [Acc > NIR] : 1.610e-07
##
## Kappa : 0.4183
##
## Mcnemar's Test P-Value : 2.541e-15
##
## Sensitivity : 0.4218
## Specificity : 0.9410
## Pos Pred Value : 0.7205
## Neg Pred Value : 0.8187
## Prevalence : 0.2649
## Detection Rate : 0.1118
## Detection Prevalence : 0.1551
## Balanced Accuracy : 0.6814
##
## 'Positive' Class : 1
##
rocplot(prediksi_prob_data_train[,2],data_sinta_train$y)
# Prediksi pada Data Testing
prediksi_prob_data_test <- predict(model_tree_1, data_sinta_test, type = "prob")
prediksi_data_test <- predict(model_tree_1, newdata=data_sinta_test, type = "class")
eval_tree_1 <- caret::confusionMatrix(prediksi_data_test, data_sinta_test$y, positive="1")
eval_tree_1
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 295 82
## 1 31 35
##
## Accuracy : 0.7449
## 95% CI : (0.7016, 0.7849)
## No Information Rate : 0.7359
## P-Value [Acc > NIR] : 0.3558
##
## Kappa : 0.2372
##
## Mcnemar's Test P-Value : 2.556e-06
##
## Sensitivity : 0.29915
## Specificity : 0.90491
## Pos Pred Value : 0.53030
## Neg Pred Value : 0.78249
## Prevalence : 0.26411
## Detection Rate : 0.07901
## Detection Prevalence : 0.14898
## Balanced Accuracy : 0.60203
##
## 'Positive' Class : 1
##
rocplot(prediksi_prob_data_test[,2],data_sinta_test$y)
vip(model_tree_1, num_features = 50)
Model dengan hyperparameter
minsplitdancpyang ditentukan sendiri (minsplit=10dancp=0)
model_tree_2 <- rpart(y ~., data = data_sinta_train, method = "class",
control=rpart.control(minsplit = 100, cp=0))
rpart.plot(model_tree_2)
# Prediksi pada Data Training
prediksi_prob_data_train <- predict(model_tree_2, data_sinta_train, type = "prob")
prediksi_data_train <- predict(model_tree_2, newdata=data_sinta_train, type = "class")
eval_tree_2_train <- caret::confusionMatrix(prediksi_data_train, data_sinta_train$y, positive="1")
eval_tree_2_train
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 720 156
## 1 43 119
##
## Accuracy : 0.8083
## 95% CI : (0.783, 0.8318)
## No Information Rate : 0.7351
## P-Value [Acc > NIR] : 2.045e-08
##
## Kappa : 0.4333
##
## Mcnemar's Test P-Value : 2.030e-15
##
## Sensitivity : 0.4327
## Specificity : 0.9436
## Pos Pred Value : 0.7346
## Neg Pred Value : 0.8219
## Prevalence : 0.2649
## Detection Rate : 0.1146
## Detection Prevalence : 0.1561
## Balanced Accuracy : 0.6882
##
## 'Positive' Class : 1
##
ROC_model_tree_2_train <- rocit(score=prediksi_prob_data_train[,2], class=data_sinta_train$y)
plot(ROC_model_tree_2_train)
ROC_model_tree_2_train$AUC
## [1] 0.818127
# Prediksi pada Data Testing
prediksi_prob_data_test <- predict(model_tree_2, data_sinta_test, type = "prob")
prediksi_data_test <- predict(model_tree_2, newdata=data_sinta_test, type = "class")
eval_tree_2 <- caret::confusionMatrix(prediksi_data_test, data_sinta_test$y, positive="1")
eval_tree_2
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 296 81
## 1 30 36
##
## Accuracy : 0.7494
## 95% CI : (0.7064, 0.7891)
## No Information Rate : 0.7359
## P-Value [Acc > NIR] : 0.2786
##
## Kappa : 0.2507
##
## Mcnemar's Test P-Value : 2.077e-06
##
## Sensitivity : 0.30769
## Specificity : 0.90798
## Pos Pred Value : 0.54545
## Neg Pred Value : 0.78515
## Prevalence : 0.26411
## Detection Rate : 0.08126
## Detection Prevalence : 0.14898
## Balanced Accuracy : 0.60783
##
## 'Positive' Class : 1
##
ROC_model_tree_2 <- rocit(score=prediksi_prob_data_test[,2], class=data_sinta_test$y)
plot(ROC_model_tree_2)
ROC_model_tree_2$AUC
## [1] 0.755899
vip(model_tree_2, num_features = 50)
Model dengan hyperparameter
minsplitoptimum
#mencari minsplit optimum
set.seed(478)
akurasi.semua <- NULL
for(ulangan in 1:100){
acak <- createDataPartition(data_sinta$y, p=0.7, list=FALSE)
data_sinta_train <- data_sinta[acak,]
data_sinta_test <- data_sinta[-acak,]
for (k in 1:30){
pohon <- rpart(y ~ .,
data=data_sinta_train,
method='class',
control=rpart.control(minsplit = k, cp=0))
prediksi.prob <- predict(pohon, data_sinta_test)
prediksi <- ifelse(prediksi.prob > 0.5, "1", "0")[,2]
akurasi <- mean(prediksi == data_sinta_test$y)
akurasi.semua <- rbind(akurasi.semua, c(k, akurasi))
}
}
mean.akurasi <- tapply(akurasi.semua[,2], akurasi.semua[,1], mean)
plot(names(mean.akurasi),mean.akurasi, type="b", xlab="minsplit", ylab="rata-rata akurasi data testing")
model_tree_3 <- rpart(y ~., data = data_sinta_train, method = "class",
control=rpart.control(minsplit = 21, cp=0))
rpart.plot(model_tree_3, extra=4)
# Prediksi pada Data Training
prediksi_prob_data_train <- predict(model_tree_3, data_sinta_train, type = "prob")
prediksi_data_train <- predict(model_tree_3, newdata=data_sinta_train, type = "class")
eval_tree_3_train <- caret::confusionMatrix(prediksi_data_train, data_sinta_train$y, positive="1")
eval_tree_3_train
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 708 150
## 1 55 125
##
## Accuracy : 0.8025
## 95% CI : (0.777, 0.8263)
## No Information Rate : 0.7351
## P-Value [Acc > NIR] : 2.390e-07
##
## Kappa : 0.43
##
## Mcnemar's Test P-Value : 5.195e-11
##
## Sensitivity : 0.4545
## Specificity : 0.9279
## Pos Pred Value : 0.6944
## Neg Pred Value : 0.8252
## Prevalence : 0.2649
## Detection Rate : 0.1204
## Detection Prevalence : 0.1734
## Balanced Accuracy : 0.6912
##
## 'Positive' Class : 1
##
# Prediksi pada Data Testing
prediksi_prob_data_test <- predict(model_tree_3, data_sinta_test, type = "prob")
prediksi_data_test <- predict(model_tree_3, newdata=data_sinta_test, type = "class")
eval_tree_3 <- caret::confusionMatrix(prediksi_data_test, data_sinta_test$y, positive="1")
eval_tree_3
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 290 67
## 1 36 50
##
## Accuracy : 0.7675
## 95% CI : (0.7253, 0.8061)
## No Information Rate : 0.7359
## P-Value [Acc > NIR] : 0.071438
##
## Kappa : 0.3463
##
## Mcnemar's Test P-Value : 0.003117
##
## Sensitivity : 0.4274
## Specificity : 0.8896
## Pos Pred Value : 0.5814
## Neg Pred Value : 0.8123
## Prevalence : 0.2641
## Detection Rate : 0.1129
## Detection Prevalence : 0.1941
## Balanced Accuracy : 0.6585
##
## 'Positive' Class : 1
##
vip(model_tree_3, num_features = 50)
Model dengan hyperparameter
cpoptimum
set.seed(478)
model_tree_4 <- rpart(y ~ ., data=data_sinta_train,
method='class',
control=rpart.control(minsplit = 20, cp=0))
printcp(model_tree_4)
##
## Classification tree:
## rpart(formula = y ~ ., data = data_sinta_train, method = "class",
## control = rpart.control(minsplit = 20, cp = 0))
##
## Variables actually used in tree construction:
## [1] Akreditasi Jumlah_Dosen_Total
## [3] Jumlah_Mahasiswa Level
## [5] Rasio_Dosen_per_Mahasiswa Rumpun_Ilmu
##
## Root node error: 275/1038 = 0.26493
##
## n= 1038
##
## CP nsplit rel error xerror xstd
## 1 0.0254545 0 1.00000 1.00000 0.051701
## 2 0.0109091 6 0.84364 1.00727 0.051820
## 3 0.0090909 8 0.82182 0.91273 0.050164
## 4 0.0084848 10 0.80364 0.90545 0.050027
## 5 0.0054545 13 0.77818 0.93818 0.050632
## 6 0.0036364 18 0.74909 0.93455 0.050566
## 7 0.0000000 19 0.74545 0.96727 0.051147
model_tree_4 <- rpart(y ~ ., data=data_sinta_train,
method='class',
control=rpart.control(minsplit = 20, cp=0.0084848))
rpart.plot(model_tree_4)
# Prediksi pada Data Training
prediksi_prob_data_train <- predict(model_tree_4, data_sinta_train, type = "prob")
prediksi_data_train <- predict(model_tree_4, newdata=data_sinta_train, type = "class")
eval_tree_4_train <- caret::confusionMatrix(prediksi_data_train, data_sinta_train$y, positive="1")
eval_tree_4_train
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 718 169
## 1 45 106
##
## Accuracy : 0.7938
## 95% CI : (0.7679, 0.8181)
## No Information Rate : 0.7351
## P-Value [Acc > NIR] : 6.425e-06
##
## Kappa : 0.3815
##
## Mcnemar's Test P-Value : < 2.2e-16
##
## Sensitivity : 0.3855
## Specificity : 0.9410
## Pos Pred Value : 0.7020
## Neg Pred Value : 0.8095
## Prevalence : 0.2649
## Detection Rate : 0.1021
## Detection Prevalence : 0.1455
## Balanced Accuracy : 0.6632
##
## 'Positive' Class : 1
##
ROC_model_tree_4_train <- rocit(score=prediksi_prob_data_train[,2], class=data_sinta_train$y)
plot(ROC_model_tree_4_train)
ROC_model_tree_4_train$AUC
## [1] 0.7814536
# Prediksi pada Data Testing
prediksi_prob_data_test <- predict(model_tree_4, data_sinta_test, type = "prob")
prediksi_data_test <- predict(model_tree_4, newdata=data_sinta_test, type = "class")
eval_tree_4 <- caret::confusionMatrix(prediksi_data_test, data_sinta_test$y, positive="1")
eval_tree_4
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 292 73
## 1 34 44
##
## Accuracy : 0.7585
## 95% CI : (0.7158, 0.7976)
## No Information Rate : 0.7359
## P-Value [Acc > NIR] : 0.1528340
##
## Kappa : 0.3043
##
## Mcnemar's Test P-Value : 0.0002392
##
## Sensitivity : 0.37607
## Specificity : 0.89571
## Pos Pred Value : 0.56410
## Neg Pred Value : 0.80000
## Prevalence : 0.26411
## Detection Rate : 0.09932
## Detection Prevalence : 0.17607
## Balanced Accuracy : 0.63589
##
## 'Positive' Class : 1
##
ROC_model_tree_4 <- rocit(score=prediksi_prob_data_test[,2], class=data_sinta_test$y)
plot(ROC_model_tree_4)
ROC_model_tree_4$AUC
## [1] 0.7596482
vip(model_tree_4, num_features = 50)
Model dengan hyperparameter
nbaggdefault dantreedefault
model_bag_1 <- ipred::bagging(y ~ ., data=data_sinta_train, coob = TRUE,
nbagg=25,
control= rpart.control(minsplit=2, cp=0))
model_bag_1
##
## Bagging classification trees with 25 bootstrap replications
##
## Call: bagging.data.frame(formula = y ~ ., data = data_sinta_train,
## coob = TRUE, nbagg = 25, control = rpart.control(minsplit = 2,
## cp = 0))
##
## Out-of-bag estimate of misclassification error: 0.2505
# Prediksi pada Data Training
prediksi_prob_data_train <- predict(model_bag_1, data_sinta_train, type = "prob")
prediksi_data_train <- predict(model_bag_1, data_sinta_train,type="class")
eval_model_bag_1_train <- caret::confusionMatrix(prediksi_data_train, data_sinta_train$y, positive="1")
eval_model_bag_1_train
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 696 133
## 1 67 142
##
## Accuracy : 0.8073
## 95% CI : (0.782, 0.8309)
## No Information Rate : 0.7351
## P-Value [Acc > NIR] : 3.127e-08
##
## Kappa : 0.4642
##
## Mcnemar's Test P-Value : 4.303e-06
##
## Sensitivity : 0.5164
## Specificity : 0.9122
## Pos Pred Value : 0.6794
## Neg Pred Value : 0.8396
## Prevalence : 0.2649
## Detection Rate : 0.1368
## Detection Prevalence : 0.2013
## Balanced Accuracy : 0.7143
##
## 'Positive' Class : 1
##
ROC_model_bag_1_train <- rocit(score=prediksi_prob_data_train[,2], class=data_sinta_train$y)
plot(ROC_model_bag_1_train)
ROC_model_bag_1_train$AUC
## [1] 0.798413
# Prediksi pada Data Testing
prediksi_prob_data_test <- predict(model_bag_1, data_sinta_test, type = "prob")
prediksi_data_test <- predict(model_bag_1, data_sinta_test,type="class")
eval_model_bag_1<- caret::confusionMatrix(prediksi_data_test, data_sinta_test$y, positive="1")
eval_model_bag_1
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 278 65
## 1 48 52
##
## Accuracy : 0.7449
## 95% CI : (0.7016, 0.7849)
## No Information Rate : 0.7359
## P-Value [Acc > NIR] : 0.3558
##
## Kappa : 0.3117
##
## Mcnemar's Test P-Value : 0.1323
##
## Sensitivity : 0.4444
## Specificity : 0.8528
## Pos Pred Value : 0.5200
## Neg Pred Value : 0.8105
## Prevalence : 0.2641
## Detection Rate : 0.1174
## Detection Prevalence : 0.2257
## Balanced Accuracy : 0.6486
##
## 'Positive' Class : 1
##
ROC_model_bag_1 <- rocit(score=prediksi_prob_data_test[,2], class=data_sinta_test$y)
plot(ROC_model_bag_1)
ROC_model_bag_1$AUC
## [1] 0.7079859
Model dengan hyperparameter
ntree,mtrydefault
model_rf_1 <- randomForest::randomForest(y ~ ., ntree=500,
data=data_sinta_train)
model_rf_1
##
## Call:
## randomForest(formula = y ~ ., data = data_sinta_train, ntree = 500)
## Type of random forest: classification
## Number of trees: 500
## No. of variables tried at each split: 2
##
## OOB estimate of error rate: 23.89%
## Confusion matrix:
## 0 1 class.error
## 0 687 76 0.09960682
## 1 172 103 0.62545455
# Prediksi pada Data Training
prediksi_prob_data_train <- predict(model_rf_1, data_sinta_train, type = "prob")
prediksi_data_train <- predict(model_rf_1, data_sinta_train,type="class")
eval_model_rf_1_train <- caret::confusionMatrix(prediksi_data_train, data_sinta_train$y, positive="1")
eval_model_rf_1_train
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 714 149
## 1 49 126
##
## Accuracy : 0.8092
## 95% CI : (0.784, 0.8327)
## No Information Rate : 0.7351
## P-Value [Acc > NIR] : 1.329e-08
##
## Kappa : 0.4458
##
## Mcnemar's Test P-Value : 1.984e-12
##
## Sensitivity : 0.4582
## Specificity : 0.9358
## Pos Pred Value : 0.7200
## Neg Pred Value : 0.8273
## Prevalence : 0.2649
## Detection Rate : 0.1214
## Detection Prevalence : 0.1686
## Balanced Accuracy : 0.6970
##
## 'Positive' Class : 1
##
ROC_model_rf_1_train <- rocit(score=prediksi_prob_data_train[,2], class=data_sinta_train$y)
plot(ROC_model_rf_1_train)
ROC_model_rf_1_train$AUC
## [1] 0.8058835
# Prediksi pada Data Testing
prediksi_prob_data_test <- predict(model_rf_1, data_sinta_test, type = "prob")
prediksi_data_test <- predict(model_rf_1, data_sinta_test,type="class")
eval_model_rf_1<- caret::confusionMatrix(prediksi_data_test, data_sinta_test$y, positive="1")
eval_model_rf_1
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 291 70
## 1 35 47
##
## Accuracy : 0.763
## 95% CI : (0.7206, 0.8018)
## No Information Rate : 0.7359
## P-Value [Acc > NIR] : 0.1066955
##
## Kappa : 0.3256
##
## Mcnemar's Test P-Value : 0.0009064
##
## Sensitivity : 0.4017
## Specificity : 0.8926
## Pos Pred Value : 0.5732
## Neg Pred Value : 0.8061
## Prevalence : 0.2641
## Detection Rate : 0.1061
## Detection Prevalence : 0.1851
## Balanced Accuracy : 0.6472
##
## 'Positive' Class : 1
##
ROC_model_rf_1 <- rocit(score=prediksi_prob_data_test[,2], class=data_sinta_test$y)
plot(ROC_model_rf_1)
ROC_model_rf_1$AUC
## [1] 0.7082088
vip(model_rf_1, num_features = 50)
hasil_eval <- rbind(
c(eval_reglog_1$overall[1], eval_reglog_1$byClass[1], eval_reglog_1$byClass[2]),
c(eval_reglog_2$overall[1], eval_reglog_2$byClass[1], eval_reglog_2$byClass[2]),
c(eval_tree_1$overall[1], eval_tree_1$byClass[1], eval_tree_1$byClass[2]),
c(eval_tree_2$overall[1], eval_tree_2$byClass[1], eval_tree_2$byClass[2]),
c(eval_tree_3$overall[1], eval_tree_3$byClass[1], eval_tree_3$byClass[2]),
c(eval_tree_4$overall[1], eval_tree_4$byClass[1], eval_tree_4$byClass[2]),
c(eval_model_bag_1$overall[1], eval_model_bag_1$byClass[1], eval_model_bag_1$byClass[2]),
c(eval_model_rf_1$overall[1], eval_model_rf_1$byClass[1], eval_model_rf_1$byClass[2]))
row.names(hasil_eval) <-
c("RegLog Semua Peubah","RegLog Seleksi Peubah",
"ClassTree 1","ClassTree 2","ClassTree 3","ClassTree 4",
"Bagging 1", "RandomForest 1")
hasil_eval <- as.data.frame(hasil_eval)
dplyr::arrange(.data = hasil_eval, desc(Accuracy))
## Accuracy Sensitivity Specificity
## ClassTree 3 0.7674944 0.42735043 0.8895706
## RandomForest 1 0.7629797 0.40170940 0.8926380
## ClassTree 4 0.7584650 0.37606838 0.8957055
## ClassTree 2 0.7494357 0.30769231 0.9079755
## ClassTree 1 0.7449210 0.29914530 0.9049080
## Bagging 1 0.7449210 0.44444444 0.8527607
## RegLog Semua Peubah 0.7426637 0.28205128 0.9079755
## RegLog Seleksi Peubah 0.7381490 0.07692308 0.9754601