library(foreign)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(caret)
## Loading required package: lattice
## 
## Attaching package: 'caret'
## 
## The following object is masked from 'package:purrr':
## 
##     lift
library(mlr)
## Loading required package: ParamHelpers
## 
## Attaching package: 'mlr'
## 
## The following object is masked from 'package:caret':
## 
##     train
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
library(rattle)
## Loading required package: bitops
## Rattle: A free graphical interface for data science with R.
## Version 5.5.1 Copyright (c) 2006-2021 Togaware Pty Ltd.
## Type 'rattle()' to shake, rattle, and roll your data.
library(rpart.plot)
## Loading required package: rpart

Data

sent <- as.data.frame(readxl::read_excel("/Users/User/Library/CloudStorage/OneDrive-apps.ipb.ac.id/Kuliah/Data/data tugas text analytics.xlsx"))
head(sent)
##   TRIP_ID ac ac_dingin ac_panas acara accessible_strategis air air_hangat
## 1    ID_1  0         0        1     0                    0   0          0
## 2    ID_2  0         0        0     0                    0   0          0
## 3    ID_3  0         0        0     0                    0   0          0
## 4    ID_4  0         0        0     0                    0   0          0
## 5    ID_5  0         0        0     0                    0   0          0
## 6    ID_8  0         0        0     0                    1   0          0
##   air_panas akses alasan aman amenities anak area asri bagus baik balkon
## 1         0     0      0    0         1    0    0    0     0    0      0
## 2         0     0      0    0         2    0    0    0     0    0      0
## 3         0     0      0    0         0    0    0    0     0    0      0
## 4         0     0      0    0         0    0    0    0     0    0      0
## 5         0     0      0    0         3    0    0    0     0    0      0
## 6         0     0      0    0         0    0    0    0     0    0      0
##   bandara bangunan barang bathtub bau bayar bed bedtype bekas bepergian
## 1       0        0      0       0   0     0   0       0     0         0
## 2       0        0      0       2   0     0   0       0     0         0
## 3       0        0      0       0   0     0   0       0     0         0
## 4       0        0      0       0   0     1   0       0     0         0
## 5       0        0      0       0   0     0   0       0     0         0
## 6       0        0      0       0   0     0   0       0     0         0
##   berenang berharap berisik berjalan berkesan bermain bersahabat bersih best
## 1        0        0       0        0        0       0          0      0    0
## 2        0        0       0        0        0       0          0      0    0
## 3        0        0       0        0        0       0          0      0    0
## 4        0        0       0        0        0       0          0      1    0
## 5        0        0       0        0        1       0          0      0    0
## 6        0        0       0        0        0       0          0      0    0
##   betah bisnis bocor booking breakfast budget buka buruk butuh cabin cafe
## 1     0      0     0       0         0      0    0     0     0     0    0
## 2     0      0     0       0         0      0    0     0     0     0    0
## 3     0      0     0       0         0      0    0     0     0     0    0
## 4     0      0     0       0         0      0    0     0     0     0    0
## 5     0      0     0       0         0      0    0     0     0     0    0
## 6     0      0     0       0         0      0    0     0     0     0    0
##   cepat_tanggap chanel checkin checkout cocok dekat desain dibersihkan diganti
## 1             0      0       0        0     0     0      0           0       0
## 2             0      0       0        0     0     0      0           0       0
## 3             0      0       0        0     0     0      0           0       0
## 4             0      0       0        0     0     0      0           0       0
## 5             0      0       0        0     0     0      0           0       0
## 6             0      0       0        0     0     0      0           0       0
##   dilengkapi dingin diperhatikan disayangkan disediakan diskon ditawarkan empuk
## 1          0      0            0           0          0      0          0     0
## 2          0      0            0           0          0      0          0     0
## 3          0      0            0           0          0      0          0     0
## 4          0      0            0           0          0      0          0     0
## 5          0      0            0           0          1      0          0     0
## 6          0      0            0           0          0      0          0     0
##   enak excellent fasilitas favorit foto ganti gedung good gratis gym habis
## 1    0         0         0       0    0     0      0    0      0   0     0
## 2    0         0         0       0    0     0      0    0      0   0     0
## 3    0         0         0       0    0     0      0    0      0   0     0
## 4    0         0         0       0    0     0      0    0      0   0     0
## 5    0         0         0       0    0     0      0    0      0   0     2
## 6    0         0         0       0    0     0      0    0      0   0     0
##   harga helpful hiburan indah interior istirahat istri jalan jauh jendela kaca
## 1     0       0       0     0        0         0     0     0    0       0    0
## 2     1       0       0     0        0         0     0     0    0       0    0
## 3     1       0       0     0        0         0     0     0    0       0    0
## 4     0       1       0     0        0         0     0     0    0       0    0
## 5     1       0       0     0        0         0     0     0    0       0    0
## 6     1       0       0     0        0         0     0     0    0       0    0
##   kamar_mandi kasih keamanan kebersihan kecewa kelas keluarga kembali kendaraan
## 1           0     0        0          0      0     0        0       0         0
## 2           0     0        0          0      0     0        0       0         0
## 3           0     0        0          0      0     0        0       0         0
## 4           0     0        0          0      0     0        0       0         0
## 5           0     0        0          0      0     0        0       0         0
## 6           0     0        0          0      0     0        0       0         0
##   keramahan keramaian keren khusus kolam kolam_renang komplain kondisi kopi_teh
## 1         0         0     0      0     0            0        0       0        0
## 2         0         0     0      0     0            0        0       0        0
## 3         0         0     0      0     0            0        0       0        0
## 4         0         0     0      0     0            0        0       0        0
## 5         0         0     0      0     0            0        0       0        0
## 6         0         0     0      0     0            0        0       0        0
##   kota kotor kualitas kuliner kunci lambat lampu lancar lantai layak lengkap
## 1    0     0        0       0     0      0     0      0      0     0       0
## 2    0     0        0       0     0      0     0      0      0     0       0
## 3    0     0        0       0     0      0     0      0      0     0       0
## 4    0     0        0       0     0      0     0      0      0     0       1
## 5    0     0        0       0     0      0     0      0      0     0       0
## 6    0     0        0       0     0      0     0      0      0     0       0
##   liburan lift lingkungan lobby lokasi lorong luas lumayan macet mahal makan
## 1       0    0          0     0      0      0    0       0     0     0     0
## 2       0    0          0     0      0      0    0       0     0     0     0
## 3       0    0          0     0      0      0    0       0     0     0     0
## 4       0    0          0     0      0      0    0       0     0     0     0
## 5       0    0          0     0      0      0    0       0     0     0     0
## 6       0    0          0     0      1      0    0       0     0     0     0
##   makanan mall mandi mantab mati memadai memesan memilih memudahkan menarik
## 1       0    0     0      0    0       0       0       0          0       0
## 2       0    0     1      1    0       0       0       0          0       0
## 3       0    0     0      0    0       0       0       0          0       0
## 4       0    0     0      0    0       0       0       0          0       0
## 5       0    0     0      0    0       0       0       0          0       0
## 6       0    0     0      0    0       0       0       0          0       0
##   mencari mengganggu menghadap menikmati menu menunggu mewah mini minimalis
## 1       0          0         0         0    0        0     0    0         0
## 2       0          0         0         0    0        0     0    0         0
## 3       0          0         0         0    0        0     0    0         0
## 4       0          0         0         0    0        0     0    0         0
## 5       0          0         0         0    0        0     0    0         0
## 6       0          0         0         0    0        0     0    0         0
##   mobil modern mudah murah next nice nilai no_smoking nyaman oke panas pantai
## 1     0      0     0     0    0    0     0          0      0   0     0      0
## 2     0      0     0     1    0    0     0          0      0   0     0      0
## 3     0      0     0     1    0    0     0          0      0   0     0      0
## 4     0      0     0     0    0    0     0          0      1   0     0      0
## 5     0      0     0     1    0    0     0          0      0   0     0      0
## 6     0      0     0     1    0    0     0          0      1   0     0      0
##   parkir parkir_mudah parkir_sulit pasangan pelayanan pengalaman pengunjung
## 1      0            0            0        0         0          0          0
## 2      0            0            0        0         0          0          0
## 3      0            0            0        0         0          0          0
## 4      0            0            0        0         0          0          0
## 5      0            0            0        0         0          0          0
## 6      0            0            0        0         0          0          0
##   penuh peralatan perbaikan perjalanan perlengkapan permintaan pesan petugas
## 1     0         0         0          0            0          0     0       0
## 2     0         0         0          0            0          0     0       0
## 3     0         0         0          0            0          0     0       0
## 4     0         0         0          0            0          0     0       1
## 5     0         0         0          0            0          0     0       0
## 6     0         0         0          0            0          0     0       0
##   pilih pilihan pindah pintu playground plus posisi puas ramah ramai rapi
## 1     0       0      0     0          0    0      0    0     0     0    0
## 2     0       0      0     0          0    0      0    0     0     0    0
## 3     0       0      0     0          0    0      0    1     0     0    0
## 4     0       0      0     0          0    0      0    0     1     0    0
## 5     0       0      0     0          0    0      0    0     0     0    0
## 6     0       0      1     0          0    0      0    0     0     0    0
##   recommended renang request resepsionis resto rokok ruangan rumah rusak
## 1           0      0       0           0     0     0       1     0     0
## 2           1      0       0           0     0     0       0     0     0
## 3           0      0       0           0     0     0       0     0     0
## 4           0      0       0           0     0     0       0     0     0
## 5           0      0       0           0     0     0       0     0     0
## 6           1      0       0           0     0     0       0     0     0
##   saluran saran satpam sejuk sekelas sempit senang service sesuai shower
## 1       0     0      0     0       0      1      0       0      0      0
## 2       0     0      0     0       0      0      0       0      0      0
## 3       0     0      0     0       0      0      0       0      0      0
## 4       0     0      0     0       0      0      0       0      0      0
## 5       0     0      0     0       0      0      0       0      0      0
## 6       0     0      0     0       0      0      0       0      0      0
##   smoking sopan sprei staff standard stasiun stay suasana suka super susah
## 1       0     0     0     0        0       0    0       0    0     0     0
## 2       0     0     0     0        0       0    0       0    0     0     0
## 3       0     0     0     0        0       0    0       0    0     0     0
## 4       0     0     0     0        0       0    0       0    0     0     0
## 5       0     0     0     0        0       0    0       0    0     0     0
## 6       0     0     0     0        0       0    0       0    0     0     0
##   taman tambahan tamu telepon teman tenang terbaik terbatas terimakasih terjaga
## 1     0        0    0       0     0      0       0        0           0       0
## 2     0        0    0       0     0      0       0        0           0       0
## 3     0        0    0       0     0      0       0        0           0       0
## 4     0        0    0       0     0      0       0        0           0       0
## 5     0        0    0       0     0      0       0        0           0       0
## 6     0        0    0       0     0      0       0        0           0       0
##   tidak_ada tidak_enak tidak_ramah tidak_sesuai tidak_variatif tidur tinggal
## 1         0          0           0            0              0     0       0
## 2         0          0           0            0              0     0       0
## 3         0          0           0            0              0     0       0
## 4         0          0           0            0              0     0       0
## 5         0          0           0            0              0     0       0
## 6         0          0           0            0              0     0       0
##   tolong top tua turun tv udara ukuran unik upgrade variasi variatif view wangi
## 1      0   0   0     0  0     0      0    0       0       0        0    0     0
## 2      0   0   0     0  0     0      0    0       0       0        0    0     0
## 3      0   0   0     0  0     0      0    0       0       0        0    0     0
## 4      0   0   0     0  0     0      0    0       0       0        0    0     0
## 5      0   0   0     0  0     0      0    0       0       0        0    0     0
## 6      0   0   0     0  0     0      0    0       0       0        0    0     0
##   wastafel wc weekend wifi wisata worthit            Trip Type Rating Class
## 1        0  0       0    0      0       0          Family Trip            0
## 2        0  0       0    0      0       0 Solo/Non-Family Trip            1
## 3        0  0       0    0      0       0 Solo/Non-Family Trip            1
## 4        0  0       0    0      0       0        Business Trip            1
## 5        0  0       0    0      0       0          Family Trip            0
## 6        0  0       0    0      0       0        Business Trip            1
colnames(sent) <- make.names(colnames(sent),unique = T)
sent <- sent[, -1]
sent$Rating.Class[sent$Rating.Class==1] <- "pos"
sent$Rating.Class[sent$Rating.Class==0] <- "neg"
sent$Rating.Class <- as.factor(sent$Rating.Class)
sent$Trip.Type <- as.factor(sent$Trip.Type)
head(sent)
##   ac ac_dingin ac_panas acara accessible_strategis air air_hangat air_panas
## 1  0         0        1     0                    0   0          0         0
## 2  0         0        0     0                    0   0          0         0
## 3  0         0        0     0                    0   0          0         0
## 4  0         0        0     0                    0   0          0         0
## 5  0         0        0     0                    0   0          0         0
## 6  0         0        0     0                    1   0          0         0
##   akses alasan aman amenities anak area asri bagus baik balkon bandara bangunan
## 1     0      0    0         1    0    0    0     0    0      0       0        0
## 2     0      0    0         2    0    0    0     0    0      0       0        0
## 3     0      0    0         0    0    0    0     0    0      0       0        0
## 4     0      0    0         0    0    0    0     0    0      0       0        0
## 5     0      0    0         3    0    0    0     0    0      0       0        0
## 6     0      0    0         0    0    0    0     0    0      0       0        0
##   barang bathtub bau bayar bed bedtype bekas bepergian berenang berharap
## 1      0       0   0     0   0       0     0         0        0        0
## 2      0       2   0     0   0       0     0         0        0        0
## 3      0       0   0     0   0       0     0         0        0        0
## 4      0       0   0     1   0       0     0         0        0        0
## 5      0       0   0     0   0       0     0         0        0        0
## 6      0       0   0     0   0       0     0         0        0        0
##   berisik berjalan berkesan bermain bersahabat bersih best betah bisnis bocor
## 1       0        0        0       0          0      0    0     0      0     0
## 2       0        0        0       0          0      0    0     0      0     0
## 3       0        0        0       0          0      0    0     0      0     0
## 4       0        0        0       0          0      1    0     0      0     0
## 5       0        0        1       0          0      0    0     0      0     0
## 6       0        0        0       0          0      0    0     0      0     0
##   booking breakfast budget buka buruk butuh cabin cafe cepat_tanggap chanel
## 1       0         0      0    0     0     0     0    0             0      0
## 2       0         0      0    0     0     0     0    0             0      0
## 3       0         0      0    0     0     0     0    0             0      0
## 4       0         0      0    0     0     0     0    0             0      0
## 5       0         0      0    0     0     0     0    0             0      0
## 6       0         0      0    0     0     0     0    0             0      0
##   checkin checkout cocok dekat desain dibersihkan diganti dilengkapi dingin
## 1       0        0     0     0      0           0       0          0      0
## 2       0        0     0     0      0           0       0          0      0
## 3       0        0     0     0      0           0       0          0      0
## 4       0        0     0     0      0           0       0          0      0
## 5       0        0     0     0      0           0       0          0      0
## 6       0        0     0     0      0           0       0          0      0
##   diperhatikan disayangkan disediakan diskon ditawarkan empuk enak excellent
## 1            0           0          0      0          0     0    0         0
## 2            0           0          0      0          0     0    0         0
## 3            0           0          0      0          0     0    0         0
## 4            0           0          0      0          0     0    0         0
## 5            0           0          1      0          0     0    0         0
## 6            0           0          0      0          0     0    0         0
##   fasilitas favorit foto ganti gedung good gratis gym habis harga helpful
## 1         0       0    0     0      0    0      0   0     0     0       0
## 2         0       0    0     0      0    0      0   0     0     1       0
## 3         0       0    0     0      0    0      0   0     0     1       0
## 4         0       0    0     0      0    0      0   0     0     0       1
## 5         0       0    0     0      0    0      0   0     2     1       0
## 6         0       0    0     0      0    0      0   0     0     1       0
##   hiburan indah interior istirahat istri jalan jauh jendela kaca kamar_mandi
## 1       0     0        0         0     0     0    0       0    0           0
## 2       0     0        0         0     0     0    0       0    0           0
## 3       0     0        0         0     0     0    0       0    0           0
## 4       0     0        0         0     0     0    0       0    0           0
## 5       0     0        0         0     0     0    0       0    0           0
## 6       0     0        0         0     0     0    0       0    0           0
##   kasih keamanan kebersihan kecewa kelas keluarga kembali kendaraan keramahan
## 1     0        0          0      0     0        0       0         0         0
## 2     0        0          0      0     0        0       0         0         0
## 3     0        0          0      0     0        0       0         0         0
## 4     0        0          0      0     0        0       0         0         0
## 5     0        0          0      0     0        0       0         0         0
## 6     0        0          0      0     0        0       0         0         0
##   keramaian keren khusus kolam kolam_renang komplain kondisi kopi_teh kota
## 1         0     0      0     0            0        0       0        0    0
## 2         0     0      0     0            0        0       0        0    0
## 3         0     0      0     0            0        0       0        0    0
## 4         0     0      0     0            0        0       0        0    0
## 5         0     0      0     0            0        0       0        0    0
## 6         0     0      0     0            0        0       0        0    0
##   kotor kualitas kuliner kunci lambat lampu lancar lantai layak lengkap liburan
## 1     0        0       0     0      0     0      0      0     0       0       0
## 2     0        0       0     0      0     0      0      0     0       0       0
## 3     0        0       0     0      0     0      0      0     0       0       0
## 4     0        0       0     0      0     0      0      0     0       1       0
## 5     0        0       0     0      0     0      0      0     0       0       0
## 6     0        0       0     0      0     0      0      0     0       0       0
##   lift lingkungan lobby lokasi lorong luas lumayan macet mahal makan makanan
## 1    0          0     0      0      0    0       0     0     0     0       0
## 2    0          0     0      0      0    0       0     0     0     0       0
## 3    0          0     0      0      0    0       0     0     0     0       0
## 4    0          0     0      0      0    0       0     0     0     0       0
## 5    0          0     0      0      0    0       0     0     0     0       0
## 6    0          0     0      1      0    0       0     0     0     0       0
##   mall mandi mantab mati memadai memesan memilih memudahkan menarik mencari
## 1    0     0      0    0       0       0       0          0       0       0
## 2    0     1      1    0       0       0       0          0       0       0
## 3    0     0      0    0       0       0       0          0       0       0
## 4    0     0      0    0       0       0       0          0       0       0
## 5    0     0      0    0       0       0       0          0       0       0
## 6    0     0      0    0       0       0       0          0       0       0
##   mengganggu menghadap menikmati menu menunggu mewah mini minimalis mobil
## 1          0         0         0    0        0     0    0         0     0
## 2          0         0         0    0        0     0    0         0     0
## 3          0         0         0    0        0     0    0         0     0
## 4          0         0         0    0        0     0    0         0     0
## 5          0         0         0    0        0     0    0         0     0
## 6          0         0         0    0        0     0    0         0     0
##   modern mudah murah next. nice nilai no_smoking nyaman oke panas pantai parkir
## 1      0     0     0     0    0     0          0      0   0     0      0      0
## 2      0     0     1     0    0     0          0      0   0     0      0      0
## 3      0     0     1     0    0     0          0      0   0     0      0      0
## 4      0     0     0     0    0     0          0      1   0     0      0      0
## 5      0     0     1     0    0     0          0      0   0     0      0      0
## 6      0     0     1     0    0     0          0      1   0     0      0      0
##   parkir_mudah parkir_sulit pasangan pelayanan pengalaman pengunjung penuh
## 1            0            0        0         0          0          0     0
## 2            0            0        0         0          0          0     0
## 3            0            0        0         0          0          0     0
## 4            0            0        0         0          0          0     0
## 5            0            0        0         0          0          0     0
## 6            0            0        0         0          0          0     0
##   peralatan perbaikan perjalanan perlengkapan permintaan pesan petugas pilih
## 1         0         0          0            0          0     0       0     0
## 2         0         0          0            0          0     0       0     0
## 3         0         0          0            0          0     0       0     0
## 4         0         0          0            0          0     0       1     0
## 5         0         0          0            0          0     0       0     0
## 6         0         0          0            0          0     0       0     0
##   pilihan pindah pintu playground plus posisi puas ramah ramai rapi recommended
## 1       0      0     0          0    0      0    0     0     0    0           0
## 2       0      0     0          0    0      0    0     0     0    0           1
## 3       0      0     0          0    0      0    1     0     0    0           0
## 4       0      0     0          0    0      0    0     1     0    0           0
## 5       0      0     0          0    0      0    0     0     0    0           0
## 6       0      1     0          0    0      0    0     0     0    0           1
##   renang request resepsionis resto rokok ruangan rumah rusak saluran saran
## 1      0       0           0     0     0       1     0     0       0     0
## 2      0       0           0     0     0       0     0     0       0     0
## 3      0       0           0     0     0       0     0     0       0     0
## 4      0       0           0     0     0       0     0     0       0     0
## 5      0       0           0     0     0       0     0     0       0     0
## 6      0       0           0     0     0       0     0     0       0     0
##   satpam sejuk sekelas sempit senang service sesuai shower smoking sopan sprei
## 1      0     0       0      1      0       0      0      0       0     0     0
## 2      0     0       0      0      0       0      0      0       0     0     0
## 3      0     0       0      0      0       0      0      0       0     0     0
## 4      0     0       0      0      0       0      0      0       0     0     0
## 5      0     0       0      0      0       0      0      0       0     0     0
## 6      0     0       0      0      0       0      0      0       0     0     0
##   staff standard stasiun stay suasana suka super susah taman tambahan tamu
## 1     0        0       0    0       0    0     0     0     0        0    0
## 2     0        0       0    0       0    0     0     0     0        0    0
## 3     0        0       0    0       0    0     0     0     0        0    0
## 4     0        0       0    0       0    0     0     0     0        0    0
## 5     0        0       0    0       0    0     0     0     0        0    0
## 6     0        0       0    0       0    0     0     0     0        0    0
##   telepon teman tenang terbaik terbatas terimakasih terjaga tidak_ada
## 1       0     0      0       0        0           0       0         0
## 2       0     0      0       0        0           0       0         0
## 3       0     0      0       0        0           0       0         0
## 4       0     0      0       0        0           0       0         0
## 5       0     0      0       0        0           0       0         0
## 6       0     0      0       0        0           0       0         0
##   tidak_enak tidak_ramah tidak_sesuai tidak_variatif tidur tinggal tolong top
## 1          0           0            0              0     0       0      0   0
## 2          0           0            0              0     0       0      0   0
## 3          0           0            0              0     0       0      0   0
## 4          0           0            0              0     0       0      0   0
## 5          0           0            0              0     0       0      0   0
## 6          0           0            0              0     0       0      0   0
##   tua turun tv udara ukuran unik upgrade variasi variatif view wangi wastafel
## 1   0     0  0     0      0    0       0       0        0    0     0        0
## 2   0     0  0     0      0    0       0       0        0    0     0        0
## 3   0     0  0     0      0    0       0       0        0    0     0        0
## 4   0     0  0     0      0    0       0       0        0    0     0        0
## 5   0     0  0     0      0    0       0       0        0    0     0        0
## 6   0     0  0     0      0    0       0       0        0    0     0        0
##   wc weekend wifi wisata worthit            Trip.Type Rating.Class
## 1  0       0    0      0       0          Family Trip          neg
## 2  0       0    0      0       0 Solo/Non-Family Trip          pos
## 3  0       0    0      0       0 Solo/Non-Family Trip          pos
## 4  0       0    0      0       0        Business Trip          pos
## 5  0       0    0      0       0          Family Trip          neg
## 6  0       0    0      0       0        Business Trip          pos
my_theme <- function(base_size =8, base_family = "sans"){
  theme_minimal(base_size = base_size, base_family = base_family) +
    theme(
      axis.text = element_text(size =8),
      axis.text.x = element_text(angle = 0, vjust = 0.5, hjust = 0.5),
      axis.title = element_text(size =8),
      panel.grid.major = element_line(color = "gray"),
      panel.grid.minor = element_blank(),
      panel.background = element_rect(fill = "#fef5f9"),
      strip.background = element_rect(fill = "#290029", color = "#290029", size =0.5),
      strip.text = element_text(face = "bold", size = 8, color = "white"),
      legend.position = "bottom",
      legend.justification = "center",
      legend.background = element_blank(),
      panel.border = element_rect(color = "grey5", fill = NA, linewidth = 0.5)
    )
}

theme_set(my_theme())
## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
myfillcolors=c("#ff0033","#330033", "#cc0033" , "#660033", "#990033","#630063")
lattice::barchart(as.factor(sent$Rating.Class), col=myfillcolors)

library(ggplot2)
library(dplyr)
df <- sent %>%
  group_by(Rating.Class) %>%
  summarise(count = n()) %>%
  group_by(Rating.Class) %>%
  mutate(per=count/sum(count)) %>% 
  ungroup()
ggplot(data=sent, aes(x="", fill=Rating.Class)) +
  geom_bar(position="fill") +
  geom_text(
    stat='count', 
    aes(y=after_stat(..count..),
        label=after_stat(scales::percent(..count../sum(..count..),2))),
    position=position_fill(0.5),
  ) +
  coord_polar(theta="y") +
  labs(x=NULL, y=NULL) +
  scale_fill_brewer(palette="Pastel1") +
  theme_void()

ggplot(data=sent, aes(x="", fill=Trip.Type)) +
  geom_bar(position="fill") +
  geom_text(
    stat='count', 
    aes(y=after_stat(..count..),
        label=after_stat(scales::percent(..count../sum(..count..),2))),
    position=position_fill(0.5),
  ) +
  coord_polar(theta="y") +
  labs(x=NULL, y=NULL) +
  scale_fill_brewer(palette="Pastel2") +
  theme_void()

lattice::barchart(as.factor(sent$Trip.Type), col=myfillcolors,
                  panel=function(...) { 
                      args <- list(...)
                      panel.text(args$x, pos=3, offset=1)
                      panel.barchart(...)
                    })

WordCloud

library(RColorBrewer)
library(wordcloud2)
library(wordcloud)
sent_pos <- sent[sent["Rating.Class"] == "pos",]
pos_frequency <- colSums(sent_pos[, -c(251, 252)])
pos_frequency <- sort(pos_frequency, decreasing = TRUE)
barplot(pos_frequency[1:10], col = myfillcolors, las = 2)

pos_words <- data.frame(word = names(pos_frequency),
                        freq = pos_frequency)

wordcloud2(data=data.frame(word = names(pos_frequency),
                        freq = pos_frequency))
wordcloud(words = names(pos_frequency), freq = pos_frequency,  
          max.words=100, random.order=FALSE, 
          colors=brewer.pal(8, "Dark2"))

sent_neg <- sent[sent["Rating.Class"] == "neg",]
neg_frequency <- colSums(sent_neg[, -c(251, 252)])
neg_frequency <- sort(neg_frequency, decreasing = TRUE)
neg_frequency[1:10]
##               lokasi               nyaman               bersih 
##                 3135                 2196                 2187 
##            pelayanan                bagus            breakfast 
##                 2147                 1957                 1486 
##              makanan                harga accessible_strategis 
##                 1477                 1458                 1396 
##                  oke 
##                 1362
barplot(neg_frequency[1:10], col = myfillcolors, las = 2)

neg_words <- data.frame(word = names(neg_frequency),
                        freq = neg_frequency)

wordcloud2(data=data.frame(word = names(neg_frequency),
                        freq = neg_frequency))
wordcloud(words = names(neg_frequency), freq = neg_frequency,  
          max.words=100, random.order=FALSE, 
          colors=brewer.pal(8, "Dark2"))

Tuning Parameter

set.seed(2023)
idTrain <- createDataPartition(y = sent$Rating.Class, p = 0.8, list = FALSE)
trainset <- sent[idTrain,]
testset <- sent[-idTrain,]
nrow(trainset); nrow(testset)
## [1] 23535
## [1] 5883
makeatree <- makeLearner("classif.rpart", predict.type = "response")
set_cv <- makeResampleDesc("CV", iters = 10L)
gs <- makeParamSet(
  makeIntegerParam("minsplit", lower = 30, upper = 50),
  makeIntegerParam("minbucket", lower = 20, upper = 25),
  makeNumericParam("cp", lower = 0.0001, upper = 0.0002)
)
gscontrol <- makeTuneControlRandom(maxit = 35)
trainTask <- makeClassifTask(data = trainset,target = "Rating.Class", positive = "pos")
stune <- tuneParams(learner = makeatree, resampling = set_cv, task = trainTask, par.set = gs, control = gscontrol, measures = acc)
## [Tune] Started tuning learner classif.rpart for parameter set:
##              Type len Def           Constr Req Tunable Trafo
## minsplit  integer   -   -         30 to 50   -    TRUE     -
## minbucket integer   -   -         20 to 25   -    TRUE     -
## cp        numeric   -   - 0.0001 to 0.0002   -    TRUE     -
## With control class: TuneControlRandom
## Imputation value: -0
## [Tune-x] 1: minsplit=43; minbucket=25; cp=0.000183
## [Tune-y] 1: acc.test.mean=0.7521142; time: 0.6 min
## [Tune-x] 2: minsplit=36; minbucket=23; cp=0.000182
## [Tune-y] 2: acc.test.mean=0.7519442; time: 0.6 min
## [Tune-x] 3: minsplit=39; minbucket=24; cp=0.000134
## [Tune-y] 3: acc.test.mean=0.7518168; time: 0.6 min
## [Tune-x] 4: minsplit=37; minbucket=22; cp=0.000179
## [Tune-y] 4: acc.test.mean=0.7516042; time: 0.6 min
## [Tune-x] 5: minsplit=50; minbucket=21; cp=0.000149
## [Tune-y] 5: acc.test.mean=0.7510094; time: 0.6 min
## [Tune-x] 6: minsplit=36; minbucket=23; cp=0.000108
## [Tune-y] 6: acc.test.mean=0.7509245; time: 0.6 min
## [Tune-x] 7: minsplit=36; minbucket=22; cp=0.000177
## [Tune-y] 7: acc.test.mean=0.7516042; time: 0.6 min
## [Tune-x] 8: minsplit=42; minbucket=20; cp=0.000105
## [Tune-y] 8: acc.test.mean=0.7483325; time: 0.6 min
## [Tune-x] 9: minsplit=39; minbucket=21; cp=0.000155
## [Tune-y] 9: acc.test.mean=0.7498198; time: 0.6 min
## [Tune-x] 10: minsplit=49; minbucket=24; cp=0.000113
## [Tune-y] 10: acc.test.mean=0.7518168; time: 0.6 min
## [Tune-x] 11: minsplit=31; minbucket=25; cp=0.00017
## [Tune-y] 11: acc.test.mean=0.7521142; time: 0.6 min
## [Tune-x] 12: minsplit=46; minbucket=22; cp=0.000138
## [Tune-y] 12: acc.test.mean=0.7507120; time: 0.6 min
## [Tune-x] 13: minsplit=46; minbucket=22; cp=0.000184
## [Tune-y] 13: acc.test.mean=0.7511792; time: 0.6 min
## [Tune-x] 14: minsplit=44; minbucket=25; cp=0.00013
## [Tune-y] 14: acc.test.mean=0.7520293; time: 0.6 min
## [Tune-x] 15: minsplit=48; minbucket=21; cp=0.000151
## [Tune-y] 15: acc.test.mean=0.7507969; time: 0.6 min
## [Tune-x] 16: minsplit=45; minbucket=23; cp=0.000171
## [Tune-y] 16: acc.test.mean=0.7519442; time: 0.6 min
## [Tune-x] 17: minsplit=30; minbucket=23; cp=0.000157
## [Tune-y] 17: acc.test.mean=0.7517742; time: 0.6 min
## [Tune-x] 18: minsplit=39; minbucket=23; cp=0.000108
## [Tune-y] 18: acc.test.mean=0.7509245; time: 0.6 min
## [Tune-x] 19: minsplit=49; minbucket=20; cp=0.000107
## [Tune-y] 19: acc.test.mean=0.7489699; time: 0.6 min
## [Tune-x] 20: minsplit=35; minbucket=20; cp=0.000165
## [Tune-y] 20: acc.test.mean=0.7499048; time: 0.6 min
## [Tune-x] 21: minsplit=50; minbucket=25; cp=0.000193
## [Tune-y] 21: acc.test.mean=0.7522841; time: 0.5 min
## [Tune-x] 22: minsplit=49; minbucket=25; cp=0.000157
## [Tune-y] 22: acc.test.mean=0.7521142; time: 0.5 min
## [Tune-x] 23: minsplit=45; minbucket=20; cp=0.000166
## [Tune-y] 23: acc.test.mean=0.7501172; time: 0.6 min
## [Tune-x] 24: minsplit=30; minbucket=22; cp=0.000106
## [Tune-y] 24: acc.test.mean=0.7500320; time: 0.6 min
## [Tune-x] 25: minsplit=30; minbucket=25; cp=0.000172
## [Tune-y] 25: acc.test.mean=0.7521142; time: 0.5 min
## [Tune-x] 26: minsplit=47; minbucket=20; cp=0.000173
## [Tune-y] 26: acc.test.mean=0.7510094; time: 0.6 min
## [Tune-x] 27: minsplit=34; minbucket=25; cp=0.000158
## [Tune-y] 27: acc.test.mean=0.7521142; time: 0.5 min
## [Tune-x] 28: minsplit=45; minbucket=24; cp=0.000192
## [Tune-y] 28: acc.test.mean=0.7522841; time: 0.5 min
## [Tune-x] 29: minsplit=37; minbucket=24; cp=0.00016
## [Tune-y] 29: acc.test.mean=0.7519017; time: 0.5 min
## [Tune-x] 30: minsplit=45; minbucket=22; cp=0.000152
## [Tune-y] 30: acc.test.mean=0.7506695; time: 0.6 min
## [Tune-x] 31: minsplit=47; minbucket=21; cp=0.000129
## [Tune-y] 31: acc.test.mean=0.7499897; time: 0.6 min
## [Tune-x] 32: minsplit=41; minbucket=24; cp=0.000138
## [Tune-y] 32: acc.test.mean=0.7518168; time: 0.5 min
## [Tune-x] 33: minsplit=39; minbucket=20; cp=0.000154
## [Tune-y] 33: acc.test.mean=0.7494799; time: 0.6 min
## [Tune-x] 34: minsplit=37; minbucket=20; cp=0.000159
## [Tune-y] 34: acc.test.mean=0.7499048; time: 0.6 min
## [Tune-x] 35: minsplit=47; minbucket=25; cp=0.000121
## [Tune-y] 35: acc.test.mean=0.7520293; time: 0.5 min
## [Tune] Result: minsplit=50; minbucket=25; cp=0.000193 : acc.test.mean=0.7522841
stune
## Tune result:
## Op. pars: minsplit=50; minbucket=25; cp=0.000193
## acc.test.mean=0.7522841
clas_tree <- rpart(data = trainset, Rating.Class~., control = rpart.control(cp = 0.000193, minsplit = 50, minbucket = 25),
                   method = 'class')

rpart.plot(clas_tree, extra = 'auto', box.palette="RdBu", shadow.col="gray", nn=TRUE)

fancyRpartPlot(clas_tree, palettes="RdPu")

clas_pred <- predict(clas_tree, trainset)
clas_predict <- ifelse(clas_pred[,2] > 0.5, "pos", "neg")
clas_conf <- confusionMatrix(as.factor(clas_predict), as.factor(trainset$Rating.Class), positive = "pos", mode = 'everything')
clas_conf
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction   neg   pos
##        neg    18    13
##        pos  5811 17693
##                                         
##                Accuracy : 0.7525        
##                  95% CI : (0.747, 0.758)
##     No Information Rate : 0.7523        
##     P-Value [Acc > NIR] : 0.4734        
##                                         
##                   Kappa : 0.0035        
##                                         
##  Mcnemar's Test P-Value : <2e-16        
##                                         
##             Sensitivity : 0.999266      
##             Specificity : 0.003088      
##          Pos Pred Value : 0.752765      
##          Neg Pred Value : 0.580645      
##               Precision : 0.752765      
##                  Recall : 0.999266      
##                      F1 : 0.858675      
##              Prevalence : 0.752326      
##          Detection Rate : 0.751774      
##    Detection Prevalence : 0.998683      
##       Balanced Accuracy : 0.501177      
##                                         
##        'Positive' Class : pos           
## 
clas_pred <- predict(clas_tree, testset)
clas_predict <- ifelse(clas_pred[,2] > 0.5, "pos", "neg")
clas_conf <- confusionMatrix(as.factor(clas_predict), as.factor(testset$Rating.Class), positive = "pos", mode = 'everything')
clas_conf
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  neg  pos
##        neg    2    6
##        pos 1455 4420
##                                           
##                Accuracy : 0.7517          
##                  95% CI : (0.7404, 0.7627)
##     No Information Rate : 0.7523          
##     P-Value [Acc > NIR] : 0.555           
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.998644        
##             Specificity : 0.001373        
##          Pos Pred Value : 0.752340        
##          Neg Pred Value : 0.250000        
##               Precision : 0.752340        
##                  Recall : 0.998644        
##                      F1 : 0.858169        
##              Prevalence : 0.752337        
##          Detection Rate : 0.751317        
##    Detection Prevalence : 0.998640        
##       Balanced Accuracy : 0.500009        
##                                           
##        'Positive' Class : pos             
## 

Tuning 2

clas_hyper <- expand.grid(
  cp = seq(0.0001, 0.0002, 0.00002), 
  minsplit = seq(30, 50, 5),
  minbucket = seq(30, 50, 5),
  sensitivity = 0,
  specificity = 0,
  f1 = 0,
  accuracy = 0)
nrow(clas_hyper)
## [1] 150
for(i in 1:nrow(clas_hyper)) {
  set.seed(i*250)
  id <- createDataPartition(y = trainset$Rating.Class, p = 0.8, list = FALSE)
  tr <- trainset[id,]
  ts <- trainset[-id,]
  clas.tune <- rpart(data = tr, Rating.Class~., 
                     control = rpart.control(cp = clas_hyper$cp[i], 
                                             minsplit = clas_hyper$minsplit[i], 
                                             minbucket = clas_hyper$minbucket[i]),
                   method = 'class')
    
  clas_pred <- predict(clas.tune, ts)
  clas_predict <- ifelse(clas_pred[,2] > 0.5, "pos", "neg")
  clas_conf <- confusionMatrix(as.factor(clas_predict), as.factor(ts$Rating.Class), positive = "pos", mode = 'everything')
  clas_hyper$sensitivity[i] <- clas_conf$byClass["Sensitivity"]
  clas_hyper$specificity[i] <- clas_conf$byClass["Specificity"]
  clas_hyper$f1[i] <- clas_conf$byClass["F1"]
  clas_hyper$accuracy[i] <- clas_conf$overall["Accuracy"]
  print(i)
}
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 1
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 2
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 3
## [1] 4
## [1] 5
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 6
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 7
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 8
## [1] 9
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 10
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 11
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 12
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 13
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 14
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 15
## [1] 16
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 17
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 18
## [1] 19
## [1] 20
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 21
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 22
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 23
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 24
## [1] 25
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 26
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 27
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 28
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 29
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 30
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 31
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 32
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 33
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 34
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 35
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 36
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 37
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 38
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 39
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 40
## [1] 41
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 42
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 43
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 44
## [1] 45
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 46
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 47
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 48
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 49
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 50
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 51
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 52
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 53
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 54
## [1] 55
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 56
## [1] 57
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 58
## [1] 59
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 60
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 61
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 62
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 63
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 64
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 65
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 66
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 67
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 68
## [1] 69
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 70
## [1] 71
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 72
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 73
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 74
## [1] 75
## [1] 76
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 77
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 78
## [1] 79
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 80
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 81
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 82
## [1] 83
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 84
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 85
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 86
## [1] 87
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 88
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 89
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 90
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 91
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 92
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 93
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 94
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 95
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 96
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 97
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 98
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 99
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 100
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 101
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 102
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 103
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 104
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 105
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 106
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 107
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 108
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 109
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 110
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 111
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 112
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 113
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 114
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 115
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 116
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 117
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 118
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 119
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 120
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 121
## [1] 122
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 123
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 124
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 125
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 126
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 127
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 128
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 129
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 130
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 131
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 132
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 133
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 134
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 135
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 136
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 137
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 138
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 139
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 140
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 141
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 142
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 143
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 144
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 145
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 146
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 147
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 148
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 149
## Warning in confusionMatrix.default(as.factor(clas_predict),
## as.factor(ts$Rating.Class), : Levels are not in the same order for reference
## and data. Refactoring data to match.
## [1] 150
clas_hyper
##          cp minsplit minbucket sensitivity  specificity        f1  accuracy
## 1   0.00010       30        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 2   0.00012       30        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 3   0.00014       30        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 4   0.00016       30        30   0.9937871 0.0051502146 0.8563086 0.7490438
## 5   0.00018       30        30   0.9966111 0.0034334764 0.8574900 0.7507437
## 6   0.00020       30        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 7   0.00010       35        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 8   0.00012       35        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 9   0.00014       35        30   0.9980232 0.0008583691 0.8578711 0.7511687
## 10  0.00016       35        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 11  0.00018       35        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 12  0.00020       35        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 13  0.00010       40        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 14  0.00012       40        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 15  0.00014       40        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 16  0.00016       40        30   0.9977408 0.0025751073 0.8579407 0.7513812
## 17  0.00018       40        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 18  0.00020       40        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 19  0.00010       45        30   0.9977408 0.0017167382 0.8578366 0.7511687
## 20  0.00012       45        30   0.9974583 0.0000000000 0.8574897 0.7505312
## 21  0.00014       45        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 22  0.00016       45        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 23  0.00018       45        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 24  0.00020       45        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 25  0.00010       50        30   0.9977408 0.0008583691 0.8577325 0.7509562
## 26  0.00012       50        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 27  0.00014       50        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 28  0.00016       50        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 29  0.00018       50        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 30  0.00020       50        30   1.0000000 0.0000000000 0.8587365 0.7524437
## 31  0.00010       30        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 32  0.00012       30        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 33  0.00014       30        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 34  0.00016       30        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 35  0.00018       30        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 36  0.00020       30        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 37  0.00010       35        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 38  0.00012       35        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 39  0.00014       35        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 40  0.00016       35        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 41  0.00018       35        35   0.9977408 0.0008583691 0.8577325 0.7509562
## 42  0.00020       35        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 43  0.00010       40        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 44  0.00012       40        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 45  0.00014       40        35   0.9974583 0.0008583691 0.8575938 0.7507437
## 46  0.00016       40        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 47  0.00018       40        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 48  0.00020       40        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 49  0.00010       45        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 50  0.00012       45        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 51  0.00014       45        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 52  0.00016       45        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 53  0.00018       45        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 54  0.00020       45        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 55  0.00010       50        35   0.9946343 0.0025751073 0.8564134 0.7490438
## 56  0.00012       50        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 57  0.00014       50        35   0.9974583 0.0017167382 0.8576979 0.7509562
## 58  0.00016       50        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 59  0.00018       50        35   0.9988704 0.0008583691 0.8582868 0.7518062
## 60  0.00020       50        35   1.0000000 0.0000000000 0.8587365 0.7524437
## 61  0.00010       30        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 62  0.00012       30        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 63  0.00014       30        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 64  0.00016       30        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 65  0.00018       30        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 66  0.00020       30        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 67  0.00010       35        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 68  0.00012       35        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 69  0.00014       35        40   0.9974583 0.0017167382 0.8576979 0.7509562
## 70  0.00016       35        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 71  0.00018       35        40   0.9983056 0.0017167382 0.8581138 0.7515937
## 72  0.00020       35        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 73  0.00010       40        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 74  0.00012       40        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 75  0.00014       40        40   0.9974583 0.0008583691 0.8575938 0.7507437
## 76  0.00016       40        40   0.9971759 0.0000000000 0.8573510 0.7503187
## 77  0.00018       40        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 78  0.00020       40        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 79  0.00010       45        40   0.9974583 0.0008583691 0.8575938 0.7507437
## 80  0.00012       45        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 81  0.00014       45        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 82  0.00016       45        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 83  0.00018       45        40   0.9977408 0.0008583691 0.8577325 0.7509562
## 84  0.00020       45        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 85  0.00010       50        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 86  0.00012       50        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 87  0.00014       50        40   0.9968935 0.0034334764 0.8576288 0.7509562
## 88  0.00016       50        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 89  0.00018       50        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 90  0.00020       50        40   1.0000000 0.0000000000 0.8587365 0.7524437
## 91  0.00010       30        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 92  0.00012       30        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 93  0.00014       30        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 94  0.00016       30        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 95  0.00018       30        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 96  0.00020       30        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 97  0.00010       35        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 98  0.00012       35        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 99  0.00014       35        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 100 0.00016       35        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 101 0.00018       35        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 102 0.00020       35        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 103 0.00010       40        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 104 0.00012       40        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 105 0.00014       40        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 106 0.00016       40        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 107 0.00018       40        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 108 0.00020       40        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 109 0.00010       45        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 110 0.00012       45        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 111 0.00014       45        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 112 0.00016       45        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 113 0.00018       45        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 114 0.00020       45        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 115 0.00010       50        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 116 0.00012       50        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 117 0.00014       50        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 118 0.00016       50        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 119 0.00018       50        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 120 0.00020       50        45   1.0000000 0.0000000000 0.8587365 0.7524437
## 121 0.00010       30        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 122 0.00012       30        50   0.9963287 0.0042918455 0.8574553 0.7507437
## 123 0.00014       30        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 124 0.00016       30        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 125 0.00018       30        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 126 0.00020       30        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 127 0.00010       35        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 128 0.00012       35        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 129 0.00014       35        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 130 0.00016       35        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 131 0.00018       35        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 132 0.00020       35        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 133 0.00010       40        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 134 0.00012       40        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 135 0.00014       40        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 136 0.00016       40        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 137 0.00018       40        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 138 0.00020       40        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 139 0.00010       45        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 140 0.00012       45        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 141 0.00014       45        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 142 0.00016       45        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 143 0.00018       45        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 144 0.00020       45        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 145 0.00010       50        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 146 0.00012       50        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 147 0.00014       50        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 148 0.00016       50        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 149 0.00018       50        50   1.0000000 0.0000000000 0.8587365 0.7524437
## 150 0.00020       50        50   1.0000000 0.0000000000 0.8587365 0.7524437
library(dplyr)
clas_hyper %>% 
  arrange(desc(accuracy)) %>% 
  head(10)
##         cp minsplit minbucket sensitivity specificity        f1  accuracy
## 1  0.00010       30        30           1           0 0.8587365 0.7524437
## 2  0.00012       30        30           1           0 0.8587365 0.7524437
## 3  0.00014       30        30           1           0 0.8587365 0.7524437
## 4  0.00020       30        30           1           0 0.8587365 0.7524437
## 5  0.00010       35        30           1           0 0.8587365 0.7524437
## 6  0.00012       35        30           1           0 0.8587365 0.7524437
## 7  0.00016       35        30           1           0 0.8587365 0.7524437
## 8  0.00018       35        30           1           0 0.8587365 0.7524437
## 9  0.00020       35        30           1           0 0.8587365 0.7524437
## 10 0.00010       40        30           1           0 0.8587365 0.7524437
clas_tree <- rpart(data = trainset, Rating.Class~., control = rpart.control(cp = 0.0001, minsplit = 30, minbucket = 30),
                   method = 'class')

rpart.plot(clas_tree, extra = 'auto', box.palette="RdBu", shadow.col="gray", nn=TRUE)

lattice::barchart(sort(clas_tree$variable.importance[1:10]), col = myfillcolors)

data.frame(nama = c("Akmarina", "Fula", "Tari", "Sofy", "Mida"),
           urutan = sample(seq(1, 5, 1)))
##       nama urutan
## 1 Akmarina      4
## 2     Fula      1
## 3     Tari      3
## 4     Sofy      5
## 5     Mida      2