getwd()
## [1] "C:/abc"
setwd('c:/abc')
getwd()
## [1] "c:/abc"
ls()
## character(0)
rm(list=ls())
ls()
## character(0)
library(dplyr)
## 
## 다음의 패키지를 부착합니다: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(caret)
## 필요한 패키지를 로딩중입니다: ggplot2
## 필요한 패키지를 로딩중입니다: lattice
rm(list=ls())
ls()
## character(0)
data(iris)
library(caret)
idx<-createDataPartition(iris$Species,p=0.8)

idx$Resample1
##   [1]   1   2   3   4   5   7   8   9  10  11  12  13  14  15  16  17  18  19
##  [19]  20  21  22  26  27  28  30  31  32  35  36  37  38  39  40  43  44  45
##  [37]  46  47  48  50  53  54  55  56  57  59  60  61  63  64  65  66  67  68
##  [55]  69  70  71  72  73  74  76  79  80  82  83  84  85  87  88  89  90  91
##  [73]  92  93  95  96  97  98  99 100 101 102 104 105 106 107 108 109 110 111
##  [91] 112 113 115 118 119 120 121 122 124 125 126 127 128 129 130 131 132 134
## [109] 135 137 138 139 143 144 145 146 147 148 149 150
table(iris[idx$Resample1,"Species"])
## 
##     setosa versicolor  virginica 
##         40         40         40
table(iris[-idx$Resample1,"Species"])
## 
##     setosa versicolor  virginica 
##         10         10         10
idx<-createDataPartition(iris$Species,p=0.8,list=FALSE)
train<-iris[idx,]
test<-iris[-idx,]
nrow(train)
## [1] 120
nrow(test)
## [1] 30
library(caret)
set.seed(2)
data(iris)
idx<-createDataPartition(iris$Species,p=0.6,list=FALSE)
train<-iris[idx,]
valid_test<-iris[-idx,]
idx2<-createDataPartition(iris$Species,p=0.5,list=FALSE)
valid<-valid_test[idx2,]
test<-valid_test[-idx2,]
nrow(train)/nrow(iris)
## [1] 0.6
nrow(valid)/nrow(iris)
## [1] 0.5
nrow(test)/nrow(iris)
## [1] 0.2066667
library(caret)
data(iris)
zs_iris<-preProcess(iris,method=c("center","scale"))
zs_iris
## Created from 150 samples and 5 variables
## 
## Pre-processing:
##   - centered (4)
##   - ignored (1)
##   - scaled (4)
zs_iris_p<-predict(zs_iris,iris)


library(psych)
## 
## 다음의 패키지를 부착합니다: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
describe(zs_iris_p[,1:4])
##              vars   n mean sd median trimmed  mad   min  max range  skew
## Sepal.Length    1 150    0  1  -0.05   -0.04 1.25 -1.86 2.48  4.35  0.31
## Sepal.Width     2 150    0  1  -0.13   -0.03 1.02 -2.43 3.08  5.51  0.31
## Petal.Length    3 150    0  1   0.34    0.00 1.05 -1.56 1.78  3.34 -0.27
## Petal.Width     4 150    0  1   0.13   -0.02 1.36 -1.44 1.71  3.15 -0.10
##              kurtosis   se
## Sepal.Length    -0.61 0.08
## Sepal.Width      0.14 0.08
## Petal.Length    -1.42 0.08
## Petal.Width     -1.36 0.08
data(iris)
sca_iris<-preProcess(iris,method="range")
sca_iris
## Created from 150 samples and 5 variables
## 
## Pre-processing:
##   - ignored (1)
##   - re-scaling to [0, 1] (4)
sca_iris_p<-predict(sca_iris,iris)
head(sca_iris_p)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1   0.22222222   0.6250000   0.06779661  0.04166667  setosa
## 2   0.16666667   0.4166667   0.06779661  0.04166667  setosa
## 3   0.11111111   0.5000000   0.05084746  0.04166667  setosa
## 4   0.08333333   0.4583333   0.08474576  0.04166667  setosa
## 5   0.19444444   0.6666667   0.06779661  0.04166667  setosa
## 6   0.30555556   0.7916667   0.11864407  0.12500000  setosa
library(psych)
describe(sca_iris_p)
##              vars   n mean   sd median trimmed  mad min max range  skew
## Sepal.Length    1 150 0.43 0.23   0.42    0.42 0.29   0   1     1  0.31
## Sepal.Width     2 150 0.44 0.18   0.42    0.43 0.19   0   1     1  0.31
## Petal.Length    3 150 0.47 0.30   0.57    0.47 0.31   0   1     1 -0.27
## Petal.Width     4 150 0.46 0.32   0.50    0.45 0.43   0   1     1 -0.10
## Species*        5 150 2.00 0.82   2.00    2.00 1.48   1   3     2  0.00
##              kurtosis   se
## Sepal.Length    -0.61 0.02
## Sepal.Width      0.14 0.01
## Petal.Length    -1.42 0.02
## Petal.Width     -1.36 0.03
## Species*        -1.52 0.07
library(caret)
data(iris)
bc_iris = preProcess(iris,method = "BoxCox")
bc_iris
## Created from 150 samples and 5 variables
## 
## Pre-processing:
##   - Box-Cox transformation (4)
##   - ignored (1)
## 
## Lambda estimates for Box-Cox transformation:
## -0.1, 0.3, 0.9, 0.6
bc_iris_t = predict(bc_iris,iris)
head(bc_iris_t)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1     1.629241    1.520660          1.4  -1.0321154  setosa
## 2     1.589235    1.301297          1.4  -1.0321154  setosa
## 3     1.547563    1.391905          1.3  -1.0321154  setosa
## 4     1.526056    1.347113          1.5  -1.0321154  setosa
## 5     1.609438    1.561856          1.4  -1.0321154  setosa
## 6     1.686399    1.680826          1.7  -0.7048667  setosa
par(mfrow=c(1,2))
plot(density(x=iris$Sepal.Width))
plot(density(x=bc_iris_t$Sepal.Width))

library(caret)
data(iris)
pca_iris<-preProcess(iris,method = "pca")
pca_iris
## Created from 150 samples and 5 variables
## 
## Pre-processing:
##   - centered (4)
##   - ignored (1)
##   - principal component signal extraction (4)
##   - scaled (4)
## 
## PCA needed 2 components to capture 95 percent of the variance
pca_iris_p<-predict(pca_iris,iris)
head(pca_iris_p)
##   Species       PC1        PC2
## 1  setosa -2.257141 -0.4784238
## 2  setosa -2.074013  0.6718827
## 3  setosa -2.356335  0.3407664
## 4  setosa -2.291707  0.5953999
## 5  setosa -2.381863 -0.6446757
## 6  setosa -2.068701 -1.4842053
library(earth)
## 필요한 패키지를 로딩중입니다: Formula
## 필요한 패키지를 로딩중입니다: plotmo
## 필요한 패키지를 로딩중입니다: plotrix
## 
## 다음의 패키지를 부착합니다: 'plotrix'
## The following object is masked from 'package:psych':
## 
##     rescale
## 필요한 패키지를 로딩중입니다: TeachingDemos
data("etitanic")
library(dplyr)
glimpse(etitanic)
## Rows: 1,046
## Columns: 6
## $ pclass   <fct> 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1…
## $ survived <int> 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1…
## $ sex      <fct> female, male, female, male, female, male, female, male, femal…
## $ age      <dbl> 29.0000, 0.9167, 2.0000, 30.0000, 25.0000, 48.0000, 63.0000, …
## $ sibsp    <int> 0, 1, 1, 1, 1, 0, 1, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1…
## $ parch    <int> 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1…
dummies<-dummyVars(survived~.,data = etitanic)
dummies
## Dummy Variable Object
## 
## Formula: survived ~ .
## 6 variables, 2 factors
## Variables and levels will be separated by '.'
## A less than full rank encoding is used
head(predict(dummies,newdata = etitanic))
##   pclass.1st pclass.2nd pclass.3rd sex.female sex.male     age sibsp parch
## 1          1          0          0          1        0 29.0000     0     0
## 2          1          0          0          0        1  0.9167     1     2
## 3          1          0          0          1        0  2.0000     1     2
## 4          1          0          0          0        1 30.0000     1     2
## 5          1          0          0          1        0 25.0000     1     2
## 6          1          0          0          0        1 48.0000     0     0
data("airquality")
colSums(is.na(airquality))
##   Ozone Solar.R    Wind    Temp   Month     Day 
##      37       7       0       0       0       0
library("RANN")
knn_im<-preProcess(airquality[1:4],method="knnImpute")
head(predict(knn_im,airquality))
##         Ozone     Solar.R       Wind       Temp Month Day
## 1 -0.03423409  0.04517615 -0.7259482 -1.1497140     5   1
## 2 -0.18580489 -0.75430487 -0.5556388 -0.6214670     5   2
## 3 -0.91334473 -0.41008388  0.7500660 -0.4101682     5   3
## 4 -0.73145977  1.41095624  0.4378323 -1.6779609     5   4
## 5 -0.69508278 -0.92308420  1.2326091 -2.3118573     5   5
## 6 -0.42831817 -0.28349938  1.4029185 -1.2553634     5   6
knn_im_p<-predict(knn_im,airquality)
colSums(is.na(knn_im_p))
##   Ozone Solar.R    Wind    Temp   Month     Day 
##       0       0       0       0       0       0
describe(knn_im_p)
##         vars   n  mean   sd median trimmed   mad   min   max range  skew
## Ozone      1 153 -0.04 0.92  -0.31   -0.16  0.72 -1.25  3.82  5.06  1.30
## Solar.R    2 153 -0.01 0.99   0.17    0.03  1.05 -1.99  1.64  3.63 -0.39
## Wind       3 153  0.00 1.00  -0.07   -0.02  0.97 -2.34  3.05  5.39  0.34
## Temp       4 153  0.00 1.00   0.12    0.04  0.94 -2.31  2.02  4.33 -0.37
## Month      5 153  6.99 1.42   7.00    6.99  1.48  5.00  9.00  4.00  0.00
## Day        6 153 15.80 8.86  16.00   15.80 11.86  1.00 31.00 30.00  0.00
##         kurtosis   se
## Ozone       1.62 0.07
## Solar.R    -0.99 0.08
## Wind        0.03 0.08
## Temp       -0.46 0.08
## Month      -1.32 0.11
## Day        -1.22 0.72
median_im<-preProcess(airquality[1:4],method = "medianImpute")
head(predict(median_im,airquality))
##   Ozone Solar.R Wind Temp Month Day
## 1  41.0     190  7.4   67     5   1
## 2  36.0     118  8.0   72     5   2
## 3  12.0     149 12.6   74     5   3
## 4  18.0     313 11.5   62     5   4
## 5  31.5     205 14.3   56     5   5
## 6  28.0     205 14.9   66     5   6
library(mlbench)
data("BostonHousing")
x=BostonHousing[,c("age","lstat","tax")]
y=BostonHousing$medv
featurePlot(x, 
             y = BostonHousing$medv, 
             plot = "scatter", 
             layout = c(3, 1))

glimpse(BostonHousing)
## Rows: 506
## Columns: 14
## $ crim    <dbl> 0.00632, 0.02731, 0.02729, 0.03237, 0.06905, 0.02985, 0.08829,…
## $ zn      <dbl> 18.0, 0.0, 0.0, 0.0, 0.0, 0.0, 12.5, 12.5, 12.5, 12.5, 12.5, 1…
## $ indus   <dbl> 2.31, 7.07, 7.07, 2.18, 2.18, 2.18, 7.87, 7.87, 7.87, 7.87, 7.…
## $ chas    <fct> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ nox     <dbl> 0.538, 0.469, 0.469, 0.458, 0.458, 0.458, 0.524, 0.524, 0.524,…
## $ rm      <dbl> 6.575, 6.421, 7.185, 6.998, 7.147, 6.430, 6.012, 6.172, 5.631,…
## $ age     <dbl> 65.2, 78.9, 61.1, 45.8, 54.2, 58.7, 66.6, 96.1, 100.0, 85.9, 9…
## $ dis     <dbl> 4.0900, 4.9671, 4.9671, 6.0622, 6.0622, 6.0622, 5.5605, 5.9505…
## $ rad     <dbl> 1, 2, 2, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,…
## $ tax     <dbl> 296, 242, 242, 222, 222, 222, 311, 311, 311, 311, 311, 311, 31…
## $ ptratio <dbl> 15.3, 17.8, 17.8, 18.7, 18.7, 18.7, 15.2, 15.2, 15.2, 15.2, 15…
## $ b       <dbl> 396.90, 396.90, 392.83, 394.63, 396.90, 394.12, 395.60, 396.90…
## $ lstat   <dbl> 4.98, 9.14, 4.03, 2.94, 5.33, 5.21, 12.43, 19.15, 29.93, 17.10…
## $ medv    <dbl> 24.0, 21.6, 34.7, 33.4, 36.2, 28.7, 22.9, 27.1, 16.5, 18.9, 15…
#변수 선택
library(mlbench)
library(caret)
library(dplyr)
data("PimaIndiansDiabetes")
glimpse(PimaIndiansDiabetes)#
## Rows: 768
## Columns: 9
## $ pregnant <dbl> 6, 1, 8, 1, 0, 5, 3, 10, 2, 8, 4, 10, 10, 1, 5, 7, 0, 7, 1, 1…
## $ glucose  <dbl> 148, 85, 183, 89, 137, 116, 78, 115, 197, 125, 110, 168, 139,…
## $ pressure <dbl> 72, 66, 64, 66, 40, 74, 50, 0, 70, 96, 92, 74, 80, 60, 72, 0,…
## $ triceps  <dbl> 35, 29, 0, 23, 35, 0, 32, 0, 45, 0, 0, 0, 0, 23, 19, 0, 47, 0…
## $ insulin  <dbl> 0, 0, 0, 94, 168, 0, 88, 0, 543, 0, 0, 0, 0, 846, 175, 0, 230…
## $ mass     <dbl> 33.6, 26.6, 23.3, 28.1, 43.1, 25.6, 31.0, 35.3, 30.5, 0.0, 37…
## $ pedigree <dbl> 0.627, 0.351, 0.672, 0.167, 2.288, 0.201, 0.248, 0.134, 0.158…
## $ age      <dbl> 50, 31, 32, 21, 33, 30, 26, 29, 53, 54, 30, 34, 57, 59, 51, 3…
## $ diabetes <fct> pos, neg, pos, neg, pos, neg, pos, neg, pos, pos, neg, pos, n…
PimaIndiansDiabetes %>% count(diabetes)
##   diabetes   n
## 1      neg 500
## 2      pos 268
library(randomForest)
## randomForest 4.7-1.1
## Type rfNews() to see new features/changes/bug fixes.
## 
## 다음의 패키지를 부착합니다: 'randomForest'
## The following object is masked from 'package:psych':
## 
##     outlier
## The following object is masked from 'package:ggplot2':
## 
##     margin
## The following object is masked from 'package:dplyr':
## 
##     combine
control <- trainControl(method="repeatedcv", number=5)
model <- train(diabetes~., data=PimaIndiansDiabetes, method="rf",
                preProcess=c("center","scale"), trControl=control)
model
## Random Forest 
## 
## 768 samples
##   8 predictor
##   2 classes: 'neg', 'pos' 
## 
## Pre-processing: centered (8), scaled (8) 
## Resampling: Cross-Validated (5 fold, repeated 1 times) 
## Summary of sample sizes: 614, 614, 614, 615, 615 
## Resampling results across tuning parameters:
## 
##   mtry  Accuracy   Kappa    
##   2     0.7630337  0.4593399
##   5     0.7539343  0.4397321
##   8     0.7565487  0.4486158
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 2.
importance<-varImp(model,scale = FALSE)
library(randomForest)
print(importance)
## rf variable importance
## 
##          Overall
## glucose    90.25
## mass       57.21
## age        46.91
## pedigree   44.00
## pressure   30.34
## pregnant   28.74
## insulin    24.66
## triceps    24.10
plot(importance)

model1 <- train(diabetes~., data=PimaIndiansDiabetes, method="knn",
               preProcess=c("center","scale"), trControl=control)
model1
## k-Nearest Neighbors 
## 
## 768 samples
##   8 predictor
##   2 classes: 'neg', 'pos' 
## 
## Pre-processing: centered (8), scaled (8) 
## Resampling: Cross-Validated (5 fold, repeated 1 times) 
## Summary of sample sizes: 614, 614, 615, 614, 615 
## Resampling results across tuning parameters:
## 
##   k  Accuracy   Kappa    
##   5  0.7227400  0.3665145
##   7  0.7318649  0.3864904
##   9  0.7214074  0.3629292
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was k = 7.
library(caret)
library(mlbench)
data(Sonar)
set.seed(998)
inTraining<-createDataPartition(y=Sonar$Class,p=.75,list=FALSE)
training<-Sonar[inTraining,]
testing<-Sonar[-inTraining,]
nrow(training)
## [1] 157
nrow(testing)
## [1] 51
set.seed(825)
rffit<-train(Class~.,data=training,
             method="rf",
             preProcess=c("center","scale"))
rffit
## Random Forest 
## 
## 157 samples
##  60 predictor
##   2 classes: 'M', 'R' 
## 
## Pre-processing: centered (60), scaled (60) 
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 157, 157, 157, 157, 157, 157, ... 
## Resampling results across tuning parameters:
## 
##   mtry  Accuracy   Kappa    
##    2    0.7869345  0.5637847
##   31    0.7772599  0.5465693
##   60    0.7626313  0.5153456
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 2.
rffit1<-train(Class~.,data=training,
              method="rf",
              preProcess=c("center","scale"))
rffit1
## Random Forest 
## 
## 157 samples
##  60 predictor
##   2 classes: 'M', 'R' 
## 
## Pre-processing: centered (60), scaled (60) 
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 157, 157, 157, 157, 157, 157, ... 
## Resampling results across tuning parameters:
## 
##   mtry  Accuracy   Kappa    
##    2    0.7759493  0.5480458
##   31    0.7846331  0.5659090
##   60    0.7749595  0.5446838
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 31.
fitControl<-trainControl(method = "cv",
                         number = 5,
                         classProbs = TRUE,
                         summaryFunction = twoClassSummary)
fitControl
## $method
## [1] "cv"
## 
## $number
## [1] 5
## 
## $repeats
## [1] NA
## 
## $search
## [1] "grid"
## 
## $p
## [1] 0.75
## 
## $initialWindow
## NULL
## 
## $horizon
## [1] 1
## 
## $fixedWindow
## [1] TRUE
## 
## $skip
## [1] 0
## 
## $verboseIter
## [1] FALSE
## 
## $returnData
## [1] TRUE
## 
## $returnResamp
## [1] "final"
## 
## $savePredictions
## [1] FALSE
## 
## $classProbs
## [1] TRUE
## 
## $summaryFunction
## function (data, lev = NULL, model = NULL) 
## {
##     if (length(lev) > 2) {
##         stop(paste("Your outcome has", length(lev), "levels. The twoClassSummary() function isn't appropriate."))
##     }
##     requireNamespaceQuietStop("pROC")
##     if (!all(levels(data[, "pred"]) == lev)) {
##         stop("levels of observed and predicted data do not match")
##     }
##     rocObject <- try(pROC::roc(data$obs, data[, lev[1]], direction = ">", 
##         quiet = TRUE), silent = TRUE)
##     rocAUC <- if (inherits(rocObject, "try-error")) 
##         NA
##     else rocObject$auc
##     out <- c(rocAUC, sensitivity(data[, "pred"], data[, "obs"], 
##         lev[1]), specificity(data[, "pred"], data[, "obs"], lev[2]))
##     names(out) <- c("ROC", "Sens", "Spec")
##     out
## }
## <bytecode: 0x0000020482aa6e38>
## <environment: namespace:caret>
## 
## $selectionFunction
## [1] "best"
## 
## $preProcOptions
## $preProcOptions$thresh
## [1] 0.95
## 
## $preProcOptions$ICAcomp
## [1] 3
## 
## $preProcOptions$k
## [1] 5
## 
## $preProcOptions$freqCut
## [1] 19
## 
## $preProcOptions$uniqueCut
## [1] 10
## 
## $preProcOptions$cutoff
## [1] 0.9
## 
## 
## $sampling
## NULL
## 
## $index
## NULL
## 
## $indexOut
## NULL
## 
## $indexFinal
## NULL
## 
## $timingSamps
## [1] 0
## 
## $predictionBounds
## [1] FALSE FALSE
## 
## $seeds
## [1] NA
## 
## $adaptive
## $adaptive$min
## [1] 5
## 
## $adaptive$alpha
## [1] 0.05
## 
## $adaptive$method
## [1] "gls"
## 
## $adaptive$complete
## [1] TRUE
## 
## 
## $trim
## [1] FALSE
## 
## $allowParallel
## [1] TRUE
set.seed(825)

rmfit1 <- train(Class ~ ., data = training, 
                 method = "rf", 
                 trControl = fitControl, 
                 verbose = FALSE,
                 metric = "ROC")
rmfit1
## Random Forest 
## 
## 157 samples
##  60 predictor
##   2 classes: 'M', 'R' 
## 
## No pre-processing
## Resampling: Cross-Validated (5 fold) 
## Summary of sample sizes: 125, 125, 125, 127, 126 
## Resampling results across tuning parameters:
## 
##   mtry  ROC        Sens       Spec     
##    2    0.9317665  0.9176471  0.7533333
##   31    0.9252381  0.8816176  0.7247619
##   60    0.9146569  0.8580882  0.7514286
## 
## ROC was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 2.
set.seed(825)
customGrid<-expand.grid(mtry=1:10)
rffit2<-train(Class ~ ., data = training, method="rf", trControl=fitControl,
              tuneGrid=customGrid,metric="ROC")
rffit2
## Random Forest 
## 
## 157 samples
##  60 predictor
##   2 classes: 'M', 'R' 
## 
## No pre-processing
## Resampling: Cross-Validated (5 fold) 
## Summary of sample sizes: 125, 125, 125, 127, 126 
## Resampling results across tuning parameters:
## 
##   mtry  ROC        Sens       Spec     
##    1    0.9287640  0.9411765  0.6847619
##    2    0.9371078  0.9058824  0.7533333
##    3    0.9399545  0.9058824  0.7380952
##    4    0.9392787  0.8823529  0.7657143
##    5    0.9365546  0.8941176  0.7523810
##    6    0.9297094  0.8941176  0.7523810
##    7    0.9347584  0.8941176  0.7238095
##    8    0.9331863  0.8816176  0.7800000
##    9    0.9364741  0.8816176  0.7390476
##   10    0.9285399  0.8823529  0.7390476
## 
## ROC was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 3.
set.seed(825)
rffit4 <- train(Class ~ ., data = training, method = "rf",
                trControl = fitControl, tuneLength = 20)
## Warning in train.default(x, y, weights = w, ...): The metric "Accuracy" was not
## in the result set. ROC will be used instead.
rffit4 
## Random Forest 
## 
## 157 samples
##  60 predictor
##   2 classes: 'M', 'R' 
## 
## No pre-processing
## Resampling: Cross-Validated (5 fold) 
## Summary of sample sizes: 125, 125, 125, 127, 126 
## Resampling results across tuning parameters:
## 
##   mtry  ROC        Sens       Spec     
##    2    0.9133386  0.8941176  0.6971429
##    5    0.9254359  0.8823529  0.7514286
##    8    0.9377556  0.8823529  0.7800000
##   11    0.9293085  0.8823529  0.7380952
##   14    0.9175280  0.8816176  0.7523810
##   17    0.9265581  0.8816176  0.7247619
##   20    0.9206478  0.8816176  0.7657143
##   23    0.9246569  0.8816176  0.7390476
##   26    0.9183613  0.8816176  0.7523810
##   29    0.9225000  0.8816176  0.7666667
##   32    0.9210399  0.8816176  0.7523810
##   35    0.9198687  0.8698529  0.7247619
##   38    0.9218803  0.8816176  0.7247619
##   41    0.9198109  0.8698529  0.7533333
##   44    0.9176313  0.8580882  0.7666667
##   47    0.9171849  0.8580882  0.7533333
##   50    0.9200123  0.8698529  0.7247619
##   53    0.9167787  0.8698529  0.7666667
##   56    0.9160644  0.8698529  0.7390476
##   60    0.9180795  0.8816176  0.7390476
## 
## ROC was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 8.
predict(rmfit1,newdata = head(testing))
## [1] R M R M M M
## Levels: M R
predict(rmfit1,newdata = head(testing),type = 'prob')
##        M     R
## 4  0.446 0.554
## 8  0.630 0.370
## 11 0.088 0.912
## 14 0.506 0.494
## 15 0.546 0.454
## 17 0.620 0.380
library(dplyr)
library(caret)

library(caTools)
df<-read.csv("diagnosis.csv")
glimpse(df)
## Rows: 569
## Columns: 32
## $ id                      <int> 842302, 842517, 84300903, 84348301, 84358402, …
## $ diagnosis               <chr> "M", "M", "M", "M", "M", "M", "M", "M", "M", "…
## $ radius_mean             <dbl> 17.990, 20.570, 19.690, 11.420, 20.290, 12.450…
## $ texture_mean            <dbl> 10.38, 17.77, 21.25, 20.38, 14.34, 15.70, 19.9…
## $ perimeter_mean          <dbl> 122.80, 132.90, 130.00, 77.58, 135.10, 82.57, …
## $ area_mean               <dbl> 1001.0, 1326.0, 1203.0, 386.1, 1297.0, 477.1, …
## $ smoothness_mean         <dbl> 0.11840, 0.08474, 0.10960, 0.14250, 0.10030, 0…
## $ compactness_mean        <dbl> 0.27760, 0.07864, 0.15990, 0.28390, 0.13280, 0…
## $ concavity_mean          <dbl> 0.30010, 0.08690, 0.19740, 0.24140, 0.19800, 0…
## $ concave.points_mean     <dbl> 0.14710, 0.07017, 0.12790, 0.10520, 0.10430, 0…
## $ symmetry_mean           <dbl> 0.2419, 0.1812, 0.2069, 0.2597, 0.1809, 0.2087…
## $ fractal_dimension_mean  <dbl> 0.07871, 0.05667, 0.05999, 0.09744, 0.05883, 0…
## $ radius_se               <dbl> 1.0950, 0.5435, 0.7456, 0.4956, 0.7572, 0.3345…
## $ texture_se              <dbl> 0.9053, 0.7339, 0.7869, 1.1560, 0.7813, 0.8902…
## $ perimeter_se            <dbl> 8.589, 3.398, 4.585, 3.445, 5.438, 2.217, 3.18…
## $ area_se                 <dbl> 153.40, 74.08, 94.03, 27.23, 94.44, 27.19, 53.…
## $ smoothness_se           <dbl> 0.006399, 0.005225, 0.006150, 0.009110, 0.0114…
## $ compactness_se          <dbl> 0.049040, 0.013080, 0.040060, 0.074580, 0.0246…
## $ concavity_se            <dbl> 0.05373, 0.01860, 0.03832, 0.05661, 0.05688, 0…
## $ concave.points_se       <dbl> 0.015870, 0.013400, 0.020580, 0.018670, 0.0188…
## $ symmetry_se             <dbl> 0.03003, 0.01389, 0.02250, 0.05963, 0.01756, 0…
## $ fractal_dimension_se    <dbl> 0.006193, 0.003532, 0.004571, 0.009208, 0.0051…
## $ radius_worst            <dbl> 25.38, 24.99, 23.57, 14.91, 22.54, 15.47, 22.8…
## $ texture_worst           <dbl> 17.33, 23.41, 25.53, 26.50, 16.67, 23.75, 27.6…
## $ perimeter_worst         <dbl> 184.60, 158.80, 152.50, 98.87, 152.20, 103.40,…
## $ area_worst              <dbl> 2019.0, 1956.0, 1709.0, 567.7, 1575.0, 741.6, …
## $ smoothness_worst        <dbl> 0.1622, 0.1238, 0.1444, 0.2098, 0.1374, 0.1791…
## $ compactness_worst       <dbl> 0.6656, 0.1866, 0.4245, 0.8663, 0.2050, 0.5249…
## $ concavity_worst         <dbl> 0.71190, 0.24160, 0.45040, 0.68690, 0.40000, 0…
## $ concave.points_worst    <dbl> 0.26540, 0.18600, 0.24300, 0.25750, 0.16250, 0…
## $ symmetry_worst          <dbl> 0.4601, 0.2750, 0.3613, 0.6638, 0.2364, 0.3985…
## $ fractal_dimension_worst <dbl> 0.11890, 0.08902, 0.08758, 0.17300, 0.07678, 0…
colSums(is.na(df))
##                      id               diagnosis             radius_mean 
##                       0                       0                       0 
##            texture_mean          perimeter_mean               area_mean 
##                       0                       0                       0 
##         smoothness_mean        compactness_mean          concavity_mean 
##                       0                       0                       0 
##     concave.points_mean           symmetry_mean  fractal_dimension_mean 
##                       0                       0                       0 
##               radius_se              texture_se            perimeter_se 
##                       0                       0                       0 
##                 area_se           smoothness_se          compactness_se 
##                       0                       0                       0 
##            concavity_se       concave.points_se             symmetry_se 
##                       0                       0                       0 
##    fractal_dimension_se            radius_worst           texture_worst 
##                       0                       0                       0 
##         perimeter_worst              area_worst        smoothness_worst 
##                       0                       0                       0 
##       compactness_worst         concavity_worst    concave.points_worst 
##                       0                       0                       0 
##          symmetry_worst fractal_dimension_worst 
##                       0                       0
df <- df %>% 
  select(-id)
df$diagnosis<-as.factor(df$diagnosis)
prop.table(table(df$diagnosis))
## 
##         B         M 
## 0.6274165 0.3725835
any(is.na(df))
## [1] FALSE
set.seed(3)
inTraining<- createDataPartition(y = df$diagnosis,p = .75, list = FALSE) 
training <- df[ inTraining,]
testing <- df[-inTraining,]



my_trainControl<- trainControl(method = "cv",
                                number = 10,
                                classProbs = TRUE,
                                summaryFunction = twoClassSummary)
my_trainControl
## $method
## [1] "cv"
## 
## $number
## [1] 10
## 
## $repeats
## [1] NA
## 
## $search
## [1] "grid"
## 
## $p
## [1] 0.75
## 
## $initialWindow
## NULL
## 
## $horizon
## [1] 1
## 
## $fixedWindow
## [1] TRUE
## 
## $skip
## [1] 0
## 
## $verboseIter
## [1] FALSE
## 
## $returnData
## [1] TRUE
## 
## $returnResamp
## [1] "final"
## 
## $savePredictions
## [1] FALSE
## 
## $classProbs
## [1] TRUE
## 
## $summaryFunction
## function (data, lev = NULL, model = NULL) 
## {
##     if (length(lev) > 2) {
##         stop(paste("Your outcome has", length(lev), "levels. The twoClassSummary() function isn't appropriate."))
##     }
##     requireNamespaceQuietStop("pROC")
##     if (!all(levels(data[, "pred"]) == lev)) {
##         stop("levels of observed and predicted data do not match")
##     }
##     rocObject <- try(pROC::roc(data$obs, data[, lev[1]], direction = ">", 
##         quiet = TRUE), silent = TRUE)
##     rocAUC <- if (inherits(rocObject, "try-error")) 
##         NA
##     else rocObject$auc
##     out <- c(rocAUC, sensitivity(data[, "pred"], data[, "obs"], 
##         lev[1]), specificity(data[, "pred"], data[, "obs"], lev[2]))
##     names(out) <- c("ROC", "Sens", "Spec")
##     out
## }
## <bytecode: 0x0000020482aa6e38>
## <environment: namespace:caret>
## 
## $selectionFunction
## [1] "best"
## 
## $preProcOptions
## $preProcOptions$thresh
## [1] 0.95
## 
## $preProcOptions$ICAcomp
## [1] 3
## 
## $preProcOptions$k
## [1] 5
## 
## $preProcOptions$freqCut
## [1] 19
## 
## $preProcOptions$uniqueCut
## [1] 10
## 
## $preProcOptions$cutoff
## [1] 0.9
## 
## 
## $sampling
## NULL
## 
## $index
## NULL
## 
## $indexOut
## NULL
## 
## $indexFinal
## NULL
## 
## $timingSamps
## [1] 0
## 
## $predictionBounds
## [1] FALSE FALSE
## 
## $seeds
## [1] NA
## 
## $adaptive
## $adaptive$min
## [1] 5
## 
## $adaptive$alpha
## [1] 0.05
## 
## $adaptive$method
## [1] "gls"
## 
## $adaptive$complete
## [1] TRUE
## 
## 
## $trim
## [1] FALSE
## 
## $allowParallel
## [1] TRUE
library("glmnet")
## 필요한 패키지를 로딩중입니다: Matrix
## Loaded glmnet 4.1-8
glmnetfit<-train(diagnosis ~ ., data = training,
                 method = "glmnet",
                 trControl = fitControl,
                 verbose = FALSE,
                 metric = "ROC")
glmnetfit
## glmnet 
## 
## 427 samples
##  30 predictor
##   2 classes: 'B', 'M' 
## 
## No pre-processing
## Resampling: Cross-Validated (5 fold) 
## Summary of sample sizes: 342, 341, 343, 341, 341 
## Resampling results across tuning parameters:
## 
##   alpha  lambda        ROC        Sens       Spec     
##   0.10   0.0007738036  0.9931304  0.9850454  0.9560484
##   0.10   0.0077380355  0.9941928  0.9962963  0.9372984
##   0.10   0.0773803551  0.9937380  0.9962963  0.9054435
##   0.55   0.0007738036  0.9930087  0.9850454  0.9497984
##   0.55   0.0077380355  0.9943107  0.9962963  0.9497984
##   0.55   0.0773803551  0.9931533  0.9962963  0.8741935
##   1.00   0.0007738036  0.9921904  0.9776380  0.9435484
##   1.00   0.0077380355  0.9941966  0.9962963  0.9370968
##   1.00   0.0773803551  0.9907960  0.9925926  0.8614919
## 
## ROC was used to select the optimal model using the largest value.
## The final values used for the model were alpha = 0.55 and lambda = 0.007738036.
my_trainControl<-trainControl(method = "cv",
                              number = 5,
                              classProbs = TRUE,
                              summaryFunction = twoClassSummary)
my_trainControl
## $method
## [1] "cv"
## 
## $number
## [1] 5
## 
## $repeats
## [1] NA
## 
## $search
## [1] "grid"
## 
## $p
## [1] 0.75
## 
## $initialWindow
## NULL
## 
## $horizon
## [1] 1
## 
## $fixedWindow
## [1] TRUE
## 
## $skip
## [1] 0
## 
## $verboseIter
## [1] FALSE
## 
## $returnData
## [1] TRUE
## 
## $returnResamp
## [1] "final"
## 
## $savePredictions
## [1] FALSE
## 
## $classProbs
## [1] TRUE
## 
## $summaryFunction
## function (data, lev = NULL, model = NULL) 
## {
##     if (length(lev) > 2) {
##         stop(paste("Your outcome has", length(lev), "levels. The twoClassSummary() function isn't appropriate."))
##     }
##     requireNamespaceQuietStop("pROC")
##     if (!all(levels(data[, "pred"]) == lev)) {
##         stop("levels of observed and predicted data do not match")
##     }
##     rocObject <- try(pROC::roc(data$obs, data[, lev[1]], direction = ">", 
##         quiet = TRUE), silent = TRUE)
##     rocAUC <- if (inherits(rocObject, "try-error")) 
##         NA
##     else rocObject$auc
##     out <- c(rocAUC, sensitivity(data[, "pred"], data[, "obs"], 
##         lev[1]), specificity(data[, "pred"], data[, "obs"], lev[2]))
##     names(out) <- c("ROC", "Sens", "Spec")
##     out
## }
## <bytecode: 0x0000020482aa6e38>
## <environment: namespace:caret>
## 
## $selectionFunction
## [1] "best"
## 
## $preProcOptions
## $preProcOptions$thresh
## [1] 0.95
## 
## $preProcOptions$ICAcomp
## [1] 3
## 
## $preProcOptions$k
## [1] 5
## 
## $preProcOptions$freqCut
## [1] 19
## 
## $preProcOptions$uniqueCut
## [1] 10
## 
## $preProcOptions$cutoff
## [1] 0.9
## 
## 
## $sampling
## NULL
## 
## $index
## NULL
## 
## $indexOut
## NULL
## 
## $indexFinal
## NULL
## 
## $timingSamps
## [1] 0
## 
## $predictionBounds
## [1] FALSE FALSE
## 
## $seeds
## [1] NA
## 
## $adaptive
## $adaptive$min
## [1] 5
## 
## $adaptive$alpha
## [1] 0.05
## 
## $adaptive$method
## [1] "gls"
## 
## $adaptive$complete
## [1] TRUE
## 
## 
## $trim
## [1] FALSE
## 
## $allowParallel
## [1] TRUE
rffit <- train(diagnosis ~ ., data = training, 
               method = "rf", 
               tuneLength = 10,
               trControl = fitControl, 
               verbose = FALSE, 
               metric = "ROC")
rffit
## Random Forest 
## 
## 427 samples
##  30 predictor
##   2 classes: 'B', 'M' 
## 
## No pre-processing
## Resampling: Cross-Validated (5 fold) 
## Summary of sample sizes: 342, 342, 341, 342, 341 
## Resampling results across tuning parameters:
## 
##   mtry  ROC        Sens       Spec     
##    2    0.9927149  0.9702306  0.9306452
##    5    0.9911757  0.9665269  0.9431452
##    8    0.9917793  0.9590496  0.9306452
##   11    0.9915422  0.9665269  0.9493952
##   14    0.9917813  0.9665269  0.9493952
##   17    0.9913613  0.9628232  0.9493952
##   20    0.9917738  0.9665269  0.9493952
##   23    0.9912476  0.9665269  0.9493952
##   26    0.9915354  0.9665269  0.9493952
##   30    0.9906015  0.9665269  0.9493952
## 
## ROC was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 2.
library(lubridate)
## 
## 다음의 패키지를 부착합니다: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(dplyr)
library(nycflights13)
data("flights")
glimpse(flights)
## Rows: 336,776
## Columns: 19
## $ year           <int> 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2…
## $ month          <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ day            <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ dep_time       <int> 517, 533, 542, 544, 554, 554, 555, 557, 557, 558, 558, …
## $ sched_dep_time <int> 515, 529, 540, 545, 600, 558, 600, 600, 600, 600, 600, …
## $ dep_delay      <dbl> 2, 4, 2, -1, -6, -4, -5, -3, -3, -2, -2, -2, -2, -2, -1…
## $ arr_time       <int> 830, 850, 923, 1004, 812, 740, 913, 709, 838, 753, 849,…
## $ sched_arr_time <int> 819, 830, 850, 1022, 837, 728, 854, 723, 846, 745, 851,…
## $ arr_delay      <dbl> 11, 20, 33, -18, -25, 12, 19, -14, -8, 8, -2, -3, 7, -1…
## $ carrier        <chr> "UA", "UA", "AA", "B6", "DL", "UA", "B6", "EV", "B6", "…
## $ flight         <int> 1545, 1714, 1141, 725, 461, 1696, 507, 5708, 79, 301, 4…
## $ tailnum        <chr> "N14228", "N24211", "N619AA", "N804JB", "N668DN", "N394…
## $ origin         <chr> "EWR", "LGA", "JFK", "JFK", "LGA", "EWR", "EWR", "LGA",…
## $ dest           <chr> "IAH", "IAH", "MIA", "BQN", "ATL", "ORD", "FLL", "IAD",…
## $ air_time       <dbl> 227, 227, 160, 183, 116, 150, 158, 53, 140, 138, 149, 1…
## $ distance       <dbl> 1400, 1416, 1089, 1576, 762, 719, 1065, 229, 944, 733, …
## $ hour           <dbl> 5, 5, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6…
## $ minute         <dbl> 15, 29, 40, 45, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 0…
## $ time_hour      <dttm> 2013-01-01 05:00:00, 2013-01-01 05:00:00, 2013-01-01 0…
today()
## [1] "2024-01-31"
now()
## [1] "2024-01-31 17:22:03 KST"
ymd("2023-01-31")
## [1] "2023-01-31"
mdy("january 1st, 2023")
## [1] "2023-01-01"
dmy("31-jan-2023")
## [1] "2023-01-31"
ymd("20230131")
## [1] "2023-01-31"
ymd_hms("2017-01-31 20:11:59")
## [1] "2017-01-31 20:11:59 UTC"
ymd_hms()
## POSIXct of length 0
data("flights")
glimpse(flights)
## Rows: 336,776
## Columns: 19
## $ year           <int> 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2…
## $ month          <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ day            <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ dep_time       <int> 517, 533, 542, 544, 554, 554, 555, 557, 557, 558, 558, …
## $ sched_dep_time <int> 515, 529, 540, 545, 600, 558, 600, 600, 600, 600, 600, …
## $ dep_delay      <dbl> 2, 4, 2, -1, -6, -4, -5, -3, -3, -2, -2, -2, -2, -2, -1…
## $ arr_time       <int> 830, 850, 923, 1004, 812, 740, 913, 709, 838, 753, 849,…
## $ sched_arr_time <int> 819, 830, 850, 1022, 837, 728, 854, 723, 846, 745, 851,…
## $ arr_delay      <dbl> 11, 20, 33, -18, -25, 12, 19, -14, -8, 8, -2, -3, 7, -1…
## $ carrier        <chr> "UA", "UA", "AA", "B6", "DL", "UA", "B6", "EV", "B6", "…
## $ flight         <int> 1545, 1714, 1141, 725, 461, 1696, 507, 5708, 79, 301, 4…
## $ tailnum        <chr> "N14228", "N24211", "N619AA", "N804JB", "N668DN", "N394…
## $ origin         <chr> "EWR", "LGA", "JFK", "JFK", "LGA", "EWR", "EWR", "LGA",…
## $ dest           <chr> "IAH", "IAH", "MIA", "BQN", "ATL", "ORD", "FLL", "IAD",…
## $ air_time       <dbl> 227, 227, 160, 183, 116, 150, 158, 53, 140, 138, 149, 1…
## $ distance       <dbl> 1400, 1416, 1089, 1576, 762, 719, 1065, 229, 944, 733, …
## $ hour           <dbl> 5, 5, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6…
## $ minute         <dbl> 15, 29, 40, 45, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 0…
## $ time_hour      <dttm> 2013-01-01 05:00:00, 2013-01-01 05:00:00, 2013-01-01 0…
flights %>% 
  select(year,month,day,hour,minute) %>% 
  mutate(departure = make_datetime(year,month,day,hour,minute))
## # A tibble: 336,776 × 6
##     year month   day  hour minute departure          
##    <int> <int> <int> <dbl>  <dbl> <dttm>             
##  1  2013     1     1     5     15 2013-01-01 05:15:00
##  2  2013     1     1     5     29 2013-01-01 05:29:00
##  3  2013     1     1     5     40 2013-01-01 05:40:00
##  4  2013     1     1     5     45 2013-01-01 05:45:00
##  5  2013     1     1     6      0 2013-01-01 06:00:00
##  6  2013     1     1     5     58 2013-01-01 05:58:00
##  7  2013     1     1     6      0 2013-01-01 06:00:00
##  8  2013     1     1     6      0 2013-01-01 06:00:00
##  9  2013     1     1     6      0 2013-01-01 06:00:00
## 10  2013     1     1     6      0 2013-01-01 06:00:00
## # ℹ 336,766 more rows
make_datetime_100 <- function(year, month, day, time) {
  make_datetime(year, month, day, time %/% 100, time %% 100)
}
make_datetime_100
## function(year, month, day, time) {
##   make_datetime(year, month, day, time %/% 100, time %% 100)
## }
datetime<-ymd_hms("2023-01-31 10:30:20")
year(datetime)
## [1] 2023
month(datetime)
## [1] 1
mday(datetime)
## [1] 31
yday(datetime)
## [1] 31
library(ggplot2)
data("economics")
glimpse(economics)
## Rows: 574
## Columns: 6
## $ date     <date> 1967-07-01, 1967-08-01, 1967-09-01, 1967-10-01, 1967-11-01, …
## $ pce      <dbl> 506.7, 509.8, 515.6, 512.2, 517.4, 525.1, 530.9, 533.6, 544.3…
## $ pop      <dbl> 198712, 198911, 199113, 199311, 199498, 199657, 199808, 19992…
## $ psavert  <dbl> 12.6, 12.6, 11.9, 12.9, 12.8, 11.8, 11.7, 12.3, 11.7, 12.3, 1…
## $ uempmed  <dbl> 4.5, 4.7, 4.6, 4.9, 4.7, 4.8, 5.1, 4.5, 4.1, 4.6, 4.4, 4.4, 4…
## $ unemploy <dbl> 2944, 2945, 2958, 3143, 3066, 3018, 2878, 3001, 2877, 2709, 2…
library(lubridate)
economics$year<-year(economics$date)
economics$month<-month(economics$date)
economics$day<-day(economics$date)
economics %>% group_by(year) %>% 
                         summarise(m=mean(pop))
## # A tibble: 49 × 2
##     year       m
##    <dbl>   <dbl>
##  1  1967 199200.
##  2  1968 200664.
##  3  1969 202649.
##  4  1970 204982.
##  5  1971 207589.
##  6  1972 209838.
##  7  1973 211857.
##  8  1974 213815.
##  9  1975 215891.
## 10  1976 217999.
## # ℹ 39 more rows
library(dplyr)

df<-read.csv("netflix.csv")
glimpse(df)
## Rows: 8,807
## Columns: 11
## $ show_id      <chr> "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s1…
## $ type         <chr> "Movie", "TV Show", "TV Show", "TV Show", "TV Show", "TV …
## $ title        <chr> "Dick Johnson Is Dead", "Blood & Water", "Ganglands", "Ja…
## $ director     <chr> "Kirsten Johnson", "", "Julien Leclercq", "", "", "Mike F…
## $ cast         <chr> "", "Ama Qamata, Khosi Ngema, Gail Mabalane, Thabang Mola…
## $ country      <chr> "United States", "South Africa", "", "", "India", "", "",…
## $ date_added   <chr> "25-Sep-21", "24-Sep-21", "24-Sep-21", "24-Sep-21", "24-S…
## $ release_year <int> 2020, 2021, 2021, 2021, 2021, 2021, 2021, 1993, 2021, 202…
## $ rating       <chr> "PG-13", "TV-MA", "TV-MA", "TV-MA", "TV-MA", "TV-MA", "PG…
## $ duration     <chr> "90 min", "2 Seasons", "1 Season", "1 Season", "2 Seasons…
## $ listed_in    <chr> "Documentaries", "International TV Shows, TV Dramas, TV M…
colSums(is.na(df))
##      show_id         type        title     director         cast      country 
##            0            0            0            0            0            0 
##   date_added release_year       rating     duration    listed_in 
##            0            0            0            0            0
df %>% count(date_added)
##               date_added   n
## 1                         10
## 2         April 15, 2018   1
## 3         April 16, 2019   1
## 4         April 17, 2016   1
## 5         April 20, 2017   1
## 6          April 4, 2017   1
## 7         August 1, 2017   1
## 8        August 13, 2018   1
## 9        August 21, 2017   1
## 10        August 4, 2017   3
## 11      December 1, 2018   1
## 12      December 1, 2019   2
## 13     December 14, 2018   2
## 14     December 15, 2015   1
## 15     December 15, 2017   2
## 16     December 15, 2018   1
## 17     December 18, 2014   1
## 18      December 2, 2017   1
## 19     December 23, 2018   1
## 20     December 25, 2015   1
## 21     December 28, 2016   1
## 22      December 3, 2019   1
## 23     December 31, 2015   1
## 24      February 1, 2015   1
## 25      February 1, 2017   1
## 26      February 1, 2019   3
## 27     February 24, 2018   1
## 28       January 1, 2016   1
## 29       January 1, 2018   3
## 30       January 1, 2020   1
## 31      January 11, 2019   1
## 32      January 12, 2019   1
## 33      January 13, 2016   1
## 34      January 17, 2018   1
## 35      January 28, 2018   1
## 36       January 8, 2018   1
## 37          July 1, 2017   4
## 38         July 12, 2019   1
## 39         July 20, 2018   2
## 40         July 26, 2019   1
## 41          June 1, 2017   2
## 42          June 1, 2018   1
## 43         June 30, 2015   1
## 44         March 1, 2017   1
## 45        March 15, 2019   1
## 46        March 16, 2016   1
## 47        March 20, 2018   1
## 48        March 22, 2015   1
## 49        March 31, 2017   1
## 50        March 31, 2018   2
## 51           May 1, 2018   1
## 52          May 18, 2017   1
## 53          May 19, 2018   1
## 54          May 26, 2016   1
## 55          May 28, 2016   1
## 56          May 31, 2015   1
## 57      November 1, 2016   2
## 58      November 1, 2017   3
## 59      November 1, 2019   2
## 60      November 3, 2015   1
## 61       October 1, 2019   2
## 62      October 31, 2018   1
## 63       October 5, 2017   1
## 64       October 8, 2013   1
## 65     September 1, 2019   1
## 66    September 16, 2018   1
## 67    September 22, 2016   1
## 68     September 7, 2016   1
## 69     September 8, 2015   1
## 70             01-Apr-14   1
## 71             01-Apr-16   7
## 72             01-Apr-17  27
## 73             01-Apr-18  44
## 74             01-Apr-19  28
## 75             01-Apr-20  43
## 76             01-Apr-21  32
## 77             01-Aug-16  14
## 78             01-Aug-17  39
## 79             01-Aug-18  37
## 80             01-Aug-19  26
## 81             01-Aug-20  21
## 82             01-Aug-21  38
## 83             01-Dec-12   1
## 84             01-Dec-15   3
## 85             01-Dec-16  20
## 86             01-Dec-17  26
## 87             01-Dec-18  28
## 88             01-Dec-19  25
## 89             01-Dec-20  28
## 90             01-Feb-14   1
## 91             01-Feb-16   2
## 92             01-Feb-17  18
## 93             01-Feb-18  19
## 94             01-Feb-19  38
## 95             01-Feb-20  15
## 96             01-Feb-21  13
## 97             01-Jan-08   1
## 98             01-Jan-16  32
## 99             01-Jan-17  19
## 100            01-Jan-18  52
## 101            01-Jan-19  37
## 102            01-Jan-20 109
## 103            01-Jan-21  49
## 104            01-Jul-16  12
## 105            01-Jul-17  38
## 106            01-Jul-18  40
## 107            01-Jul-19  52
## 108            01-Jul-20  21
## 109            01-Jul-21  60
## 110            01-Jun-15   1
## 111            01-Jun-16   8
## 112            01-Jun-17  31
## 113            01-Jun-18  12
## 114            01-Jun-19  18
## 115            01-Jun-20  24
## 116            01-Mar-16   4
## 117            01-Mar-17  21
## 118            01-Mar-18  75
## 119            01-Mar-19  30
## 120            01-Mar-20  17
## 121            01-Mar-21  11
## 122            01-May-16   3
## 123            01-May-17  25
## 124            01-May-18  41
## 125            01-May-19  16
## 126            01-May-20  24
## 127            01-May-21  33
## 128            01-Nov-10   1
## 129            01-Nov-13   2
## 130            01-Nov-16  14
## 131            01-Nov-17  30
## 132            01-Nov-18  60
## 133            01-Nov-19  89
## 134            01-Nov-20  33
## 135            01-Oct-11  11
## 136            01-Oct-15   1
## 137            01-Oct-16  23
## 138            01-Oct-17  47
## 139            01-Oct-18  71
## 140            01-Oct-19  60
## 141            01-Oct-20  33
## 142            01-Sep-13   2
## 143            01-Sep-16  20
## 144            01-Sep-17  38
## 145            01-Sep-18  22
## 146            01-Sep-19  30
## 147            01-Sep-20  26
## 148            01-Sep-21  56
## 149            02-Apr-17   2
## 150            02-Apr-18   2
## 151            02-Apr-19   4
## 152            02-Apr-20   2
## 153            02-Apr-21  11
## 154            02-Aug-13   1
## 155            02-Aug-16   1
## 156            02-Aug-18  25
## 157            02-Aug-19   7
## 158            02-Aug-20   2
## 159            02-Dec-15   1
## 160            02-Dec-16   4
## 161            02-Dec-17   2
## 162            02-Dec-18   3
## 163            02-Dec-19   1
## 164            02-Dec-20   6
## 165            02-Feb-17   1
## 166            02-Feb-18   4
## 167            02-Feb-19   6
## 168            02-Feb-21   2
## 169            02-Jan-18   3
## 170            02-Jan-19   2
## 171            02-Jan-20   3
## 172            02-Jan-21   2
## 173            02-Jul-18   2
## 174            02-Jul-19   3
## 175            02-Jul-20   3
## 176            02-Jul-21   9
## 177            02-Jun-16   1
## 178            02-Jun-17   5
## 179            02-Jun-18   2
## 180            02-Jun-19   4
## 181            02-Jun-20  11
## 182            02-Jun-21  51
## 183            02-Mar-16   1
## 184            02-Mar-17   2
## 185            02-Mar-18   4
## 186            02-Mar-19  10
## 187            02-Mar-20   1
## 188            02-Mar-21   3
## 189            02-May-17   2
## 190            02-May-18   1
## 191            02-May-19   7
## 192            02-May-20  11
## 193            02-Nov-16   2
## 194            02-Nov-18   6
## 195            02-Nov-19  14
## 196            02-Nov-20   2
## 197            02-Oct-15   1
## 198            02-Oct-17   1
## 199            02-Oct-18  17
## 200            02-Oct-19  12
## 201            02-Oct-20  11
## 202            02-Sep-15   1
## 203            02-Sep-16   2
## 204            02-Sep-17   3
## 205            02-Sep-18   3
## 206            02-Sep-20   5
## 207            02-Sep-21  14
## 208            03-Apr-18   3
## 209            03-Apr-19   4
## 210            03-Apr-20   4
## 211            03-Apr-21   1
## 212            03-Aug-17   1
## 213            03-Aug-18   4
## 214            03-Aug-19   1
## 215            03-Aug-20   1
## 216            03-Aug-21  10
## 217            03-Dec-16   3
## 218            03-Dec-18   3
## 219            03-Dec-19   4
## 220            03-Dec-20   5
## 221            03-Feb-17   2
## 222            03-Feb-19   1
## 223            03-Feb-20   3
## 224            03-Feb-21   5
## 225            03-Jan-17   1
## 226            03-Jan-19   2
## 227            03-Jan-20   3
## 228            03-Jan-21   1
## 229            03-Jul-18   4
## 230            03-Jul-19   2
## 231            03-Jul-20   9
## 232            03-Jul-21   1
## 233            03-Jun-16   1
## 234            03-Jun-17   3
## 235            03-Jun-19   2
## 236            03-Jun-20   3
## 237            03-Jun-21   8
## 238            03-Mar-17   1
## 239            03-Mar-19   2
## 240            03-Mar-20   8
## 241            03-Mar-21   2
## 242            03-May-18   1
## 243            03-May-19  10
## 244            03-May-20   1
## 245            03-Nov-17   2
## 246            03-Nov-18   2
## 247            03-Nov-20   4
## 248            03-Oct-17   2
## 249            03-Oct-18   3
## 250            03-Oct-19   2
## 251            03-Oct-20   4
## 252            03-Sep-18   1
## 253            03-Sep-20   4
## 254            03-Sep-21   5
## 255            04-Apr-17   1
## 256            04-Apr-18   3
## 257            04-Apr-19   1
## 258            04-Apr-20   2
## 259            04-Apr-21   2
## 260            04-Aug-17   5
## 261            04-Aug-18   4
## 262            04-Aug-20   4
## 263            04-Aug-21   7
## 264            04-Dec-15   1
## 265            04-Dec-16   1
## 266            04-Dec-18   3
## 267            04-Dec-19   3
## 268            04-Dec-20   9
## 269            04-Feb-08   1
## 270            04-Feb-16   1
## 271            04-Feb-17   1
## 272            04-Feb-18   1
## 273            04-Feb-20   4
## 274            04-Jan-17   1
## 275            04-Jan-19   5
## 276            04-Jan-20   1
## 277            04-Jan-21   3
## 278            04-Jul-16   1
## 279            04-Jul-17   1
## 280            04-Jul-18   1
## 281            04-Jul-19   4
## 282            04-Jul-20   1
## 283            04-Jul-21   1
## 284            04-Jun-18   2
## 285            04-Jun-19   4
## 286            04-Jun-20   3
## 287            04-Jun-21   9
## 288            04-Mar-17   1
## 289            04-Mar-18   1
## 290            04-Mar-19   6
## 291            04-Mar-20   4
## 292            04-Mar-21   4
## 293            04-May-17   1
## 294            04-May-18  10
## 295            04-May-20   2
## 296            04-May-21   4
## 297            04-Nov-16   3
## 298            04-Nov-17   1
## 299            04-Nov-19   9
## 300            04-Nov-20   4
## 301            04-Oct-16   1
## 302            04-Oct-18   4
## 303            04-Oct-19  10
## 304            04-Oct-20   1
## 305            04-Sep-17   2
## 306            04-Sep-18   2
## 307            04-Sep-19   3
## 308            04-Sep-20   6
## 309            04-Sep-21   1
## 310            05-Apr-16   1
## 311            05-Apr-18   2
## 312            05-Apr-19  15
## 313            05-Apr-20   2
## 314            05-Apr-21   2
## 315            05-Aug-15   1
## 316            05-Aug-16   1
## 317            05-Aug-17   4
## 318            05-Aug-18   1
## 319            05-Aug-19   5
## 320            05-Aug-20   3
## 321            05-Aug-21   5
## 322            05-Dec-14   1
## 323            05-Dec-16   2
## 324            05-Dec-17   1
## 325            05-Dec-18   1
## 326            05-Dec-19   3
## 327            05-Dec-20   2
## 328            05-Feb-16   3
## 329            05-Feb-17   2
## 330            05-Feb-18   4
## 331            05-Feb-19   6
## 332            05-Feb-20   4
## 333            05-Feb-21  10
## 334            05-Jan-17   3
## 335            05-Jan-18   3
## 336            05-Jan-19   7
## 337            05-Jan-21   3
## 338            05-Jul-18   1
## 339            05-Jul-19   2
## 340            05-Jul-20  29
## 341            05-Jun-17   2
## 342            05-Jun-18   1
## 343            05-Jun-19   6
## 344            05-Jun-20   9
## 345            05-Jun-21   3
## 346            05-Mar-18   1
## 347            05-Mar-19   5
## 348            05-Mar-20   5
## 349            05-Mar-21   7
## 350            05-May-09   1
## 351            05-May-16   1
## 352            05-May-17   5
## 353            05-May-18   3
## 354            05-May-19   1
## 355            05-May-20   1
## 356            05-May-21   3
## 357            05-Nov-17   1
## 358            05-Nov-18   2
## 359            05-Nov-19   7
## 360            05-Nov-20   7
## 361            05-Oct-18   9
## 362            05-Oct-19   3
## 363            05-Oct-20   1
## 364            05-Sep-17   4
## 365            05-Sep-18   7
## 366            05-Sep-19   1
## 367            05-Sep-20   3
## 368            05-Sep-21   2
## 369            06-Apr-17   1
## 370            06-Apr-18  10
## 371            06-Apr-19   1
## 372            06-Apr-20   2
## 373            06-Apr-21   1
## 374            06-Aug-17   2
## 375            06-Aug-19   6
## 376            06-Aug-20   3
## 377            06-Aug-21   5
## 378            06-Dec-16   4
## 379            06-Dec-17   1
## 380            06-Dec-18   1
## 381            06-Dec-19  16
## 382            06-Feb-16   1
## 383            06-Feb-18   3
## 384            06-Feb-19   2
## 385            06-Feb-20   3
## 386            06-Feb-21   1
## 387            06-Jan-17   4
## 388            06-Jan-18   2
## 389            06-Jan-21   3
## 390            06-Jul-16   1
## 391            06-Jul-17   2
## 392            06-Jul-18   6
## 393            06-Jul-19   2
## 394            06-Jul-20   2
## 395            06-Jul-21  39
## 396            06-Jun-19  16
## 397            06-Jun-20   3
## 398            06-Jun-21   1
## 399            06-Mar-15   2
## 400            06-Mar-18   6
## 401            06-Mar-19   2
## 402            06-Mar-20   8
## 403            06-Mar-21   1
## 404            06-May-16   1
## 405            06-May-19   4
## 406            06-May-20   3
## 407            06-May-21   2
## 408            06-Nov-17   1
## 409            06-Nov-19   3
## 410            06-Nov-20   9
## 411            06-Oct-17   4
## 412            06-Oct-18   2
## 413            06-Oct-19   1
## 414            06-Oct-20   5
## 415            06-Sep-16   1
## 416            06-Sep-17   1
## 417            06-Sep-18   2
## 418            06-Sep-19   5
## 419            06-Sep-21   3
## 420            07-Apr-17   5
## 421            07-Apr-18   1
## 422            07-Apr-19   2
## 423            07-Apr-20   2
## 424            07-Apr-21   4
## 425            07-Aug-17   8
## 426            07-Aug-19   3
## 427            07-Aug-20  10
## 428            07-Aug-21   2
## 429            07-Dec-17   1
## 430            07-Dec-18  10
## 431            07-Dec-19   2
## 432            07-Dec-20   5
## 433            07-Feb-17   1
## 434            07-Feb-19   2
## 435            07-Feb-20   9
## 436            07-Feb-21   1
## 437            07-Jan-17   2
## 438            07-Jan-19   2
## 439            07-Jan-20   2
## 440            07-Jan-21   3
## 441            07-Jul-15   1
## 442            07-Jul-16   1
## 443            07-Jul-17   8
## 444            07-Jul-19   1
## 445            07-Jul-20   2
## 446            07-Jul-21  13
## 447            07-Jun-18   3
## 448            07-Jun-19  12
## 449            07-Jun-20   3
## 450            07-Jun-21   1
## 451            07-Mar-16   1
## 452            07-Mar-17   1
## 453            07-Mar-18   2
## 454            07-Mar-19   6
## 455            07-May-17   1
## 456            07-May-18   1
## 457            07-May-19   6
## 458            07-May-20   5
## 459            07-May-21   9
## 460            07-Nov-14   1
## 461            07-Nov-17   5
## 462            07-Nov-18   3
## 463            07-Nov-19   1
## 464            07-Oct-16   4
## 465            07-Oct-17   1
## 466            07-Oct-19   1
## 467            07-Oct-20   2
## 468            07-Sep-17   1
## 469            07-Sep-18   9
## 470            07-Sep-20   5
## 471            07-Sep-21   6
## 472            08-Apr-16   1
## 473            08-Apr-17   2
## 474            08-Apr-19   2
## 475            08-Apr-20   2
## 476            08-Apr-21   2
## 477            08-Aug-17   1
## 478            08-Aug-18   2
## 479            08-Aug-19  13
## 480            08-Aug-20   3
## 481            08-Aug-21   2
## 482            08-Dec-16   4
## 483            08-Dec-17   4
## 484            08-Dec-18   5
## 485            08-Dec-19   1
## 486            08-Dec-20   8
## 487            08-Feb-16   1
## 488            08-Feb-17   3
## 489            08-Feb-18   1
## 490            08-Feb-19   7
## 491            08-Feb-20   2
## 492            08-Feb-21   2
## 493            08-Jan-16   1
## 494            08-Jan-18   1
## 495            08-Jan-19   1
## 496            08-Jan-20   1
## 497            08-Jan-21  11
## 498            08-Jul-16   1
## 499            08-Jul-18   1
## 500            08-Jul-19   1
## 501            08-Jul-20   4
## 502            08-Jul-21   6
## 503            08-Jun-17   1
## 504            08-Jun-18   4
## 505            08-Jun-19   3
## 506            08-Jun-20   1
## 507            08-Jun-21   1
## 508            08-Mar-17   1
## 509            08-Mar-18   2
## 510            08-Mar-19  12
## 511            08-Mar-20   1
## 512            08-Mar-21   2
## 513            08-May-16   1
## 514            08-May-17   1
## 515            08-May-18   3
## 516            08-May-19   9
## 517            08-May-20   6
## 518            08-May-21   2
## 519            08-Nov-18   6
## 520            08-Nov-19   5
## 521            08-Oct-18   2
## 522            08-Oct-19   2
## 523            08-Oct-20   5
## 524            08-Sep-15   1
## 525            08-Sep-17  21
## 526            08-Sep-18   2
## 527            08-Sep-20   4
## 528            08-Sep-21   4
## 529            09-Apr-16   1
## 530            09-Apr-18   2
## 531            09-Apr-19   2
## 532            09-Apr-20   2
## 533            09-Apr-21   6
## 534            09-Aug-17   1
## 535            09-Aug-18   2
## 536            09-Aug-19   8
## 537            09-Aug-21   1
## 538            09-Dec-15   1
## 539            09-Dec-16   5
## 540            09-Dec-18   1
## 541            09-Dec-19   2
## 542            09-Dec-20   7
## 543            09-Feb-18   5
## 544            09-Feb-19   3
## 545            09-Feb-20   3
## 546            09-Feb-21   1
## 547            09-Jan-18   2
## 548            09-Jan-19   5
## 549            09-Jan-20   2
## 550            09-Jul-19   2
## 551            09-Jul-20   3
## 552            09-Jul-21  12
## 553            09-Jun-17   2
## 554            09-Jun-21   5
## 555            09-Mar-16   1
## 556            09-Mar-17   4
## 557            09-Mar-18   4
## 558            09-Mar-19   2
## 559            09-Mar-21   1
## 560            09-May-17   1
## 561            09-May-19   7
## 562            09-May-20   1
## 563            09-May-21   2
## 564            09-Nov-16   2
## 565            09-Nov-18   9
## 566            09-Nov-19   1
## 567            09-Oct-15   1
## 568            09-Oct-18   3
## 569            09-Oct-19   3
## 570            09-Oct-20   6
## 571            09-Sep-16   1
## 572            09-Sep-18   1
## 573            09-Sep-19   1
## 574            09-Sep-20   6
## 575            09-Sep-21   4
## 576            10-Apr-17   2
## 577            10-Apr-18   1
## 578            10-Apr-19   4
## 579            10-Apr-20   8
## 580            10-Apr-21   1
## 581            10-Aug-17   4
## 582            10-Aug-18   7
## 583            10-Aug-20   4
## 584            10-Aug-21   5
## 585            10-Dec-16   2
## 586            10-Dec-18   4
## 587            10-Dec-19   2
## 588            10-Dec-20   6
## 589            10-Feb-17   4
## 590            10-Feb-20   1
## 591            10-Feb-21   3
## 592            10-Jan-17   2
## 593            10-Jan-18   3
## 594            10-Jan-19   3
## 595            10-Jan-20  11
## 596            10-Jan-21   1
## 597            10-Jul-15   1
## 598            10-Jul-16   1
## 599            10-Jul-17   1
## 600            10-Jul-18   2
## 601            10-Jul-20   8
## 602            10-Jul-21   3
## 603            10-Jun-17   9
## 604            10-Jun-19   1
## 605            10-Jun-20   7
## 606            10-Jun-21   6
## 607            10-Mar-17  22
## 608            10-Mar-18   2
## 609            10-Mar-19   1
## 610            10-Mar-20   2
## 611            10-Mar-21   3
## 612            10-May-15   1
## 613            10-May-17   2
## 614            10-May-19  11
## 615            10-May-21   1
## 616            10-Nov-16   2
## 617            10-Nov-17   7
## 618            10-Nov-18   3
## 619            10-Nov-20   2
## 620            10-Oct-14   1
## 621            10-Oct-15   2
## 622            10-Oct-17   1
## 623            10-Oct-18   4
## 624            10-Oct-19   3
## 625            10-Sep-19   4
## 626            10-Sep-20  15
## 627            10-Sep-21   8
## 628            11-Apr-17   1
## 629            11-Apr-19   2
## 630            11-Apr-20   2
## 631            11-Apr-21   1
## 632            11-Aug-16   4
## 633            11-Aug-17   1
## 634            11-Aug-20   2
## 635            11-Aug-21   6
## 636            11-Dec-15   1
## 637            11-Dec-16   1
## 638            11-Dec-17   3
## 639            11-Dec-18   2
## 640            11-Dec-19   1
## 641            11-Dec-20   6
## 642            11-Feb-17   1
## 643            11-Feb-19   1
## 644            11-Feb-20   3
## 645            11-Feb-21   8
## 646            11-Jan-18   1
## 647            11-Jan-19   8
## 648            11-Jan-20   1
## 649            11-Jan-21   2
## 650            11-Jul-14   1
## 651            11-Jul-18   1
## 652            11-Jul-19   2
## 653            11-Jul-20   1
## 654            11-Jun-19   1
## 655            11-Jun-20   2
## 656            11-Jun-21   7
## 657            11-Mar-16   1
## 658            11-Mar-18   2
## 659            11-Mar-19   2
## 660            11-Mar-20   6
## 661            11-Mar-21   3
## 662            11-May-18   6
## 663            11-May-19   4
## 664            11-May-20   5
## 665            11-May-21   3
## 666            11-Nov-16   2
## 667            11-Nov-17   1
## 668            11-Nov-19   4
## 669            11-Nov-20   6
## 670            11-Oct-18   4
## 671            11-Oct-19   8
## 672            11-Oct-20   1
## 673            11-Sep-17   1
## 674            11-Sep-18   3
## 675            11-Sep-19   1
## 676            11-Sep-20   9
## 677            11-Sep-21   3
## 678            12-Apr-17   2
## 679            12-Apr-18   1
## 680            12-Apr-19   9
## 681            12-Apr-21   2
## 682            12-Aug-17   2
## 683            12-Aug-19   1
## 684            12-Aug-20   3
## 685            12-Aug-21   3
## 686            12-Dec-13   1
## 687            12-Dec-14   1
## 688            12-Dec-16   1
## 689            12-Dec-17   4
## 690            12-Dec-18   2
## 691            12-Dec-19   1
## 692            12-Dec-20   2
## 693            12-Feb-17   1
## 694            12-Feb-19   2
## 695            12-Feb-20   3
## 696            12-Feb-21   7
## 697            12-Jan-17   2
## 698            12-Jan-18   6
## 699            12-Jan-19   2
## 700            12-Jan-20   2
## 701            12-Jan-21   3
## 702            12-Jul-17   1
## 703            12-Jul-19  20
## 704            12-Jul-21   1
## 705            12-Jun-18   2
## 706            12-Jun-19   2
## 707            12-Jun-20  15
## 708            12-Jun-21   4
## 709            12-Mar-18   2
## 710            12-Mar-19   3
## 711            12-Mar-21  12
## 712            12-May-17   4
## 713            12-May-18   1
## 714            12-May-19   2
## 715            12-May-20   3
## 716            12-May-21   4
## 717            12-Nov-17   1
## 718            12-Nov-18   1
## 719            12-Nov-19   2
## 720            12-Nov-20   8
## 721            12-Oct-14   1
## 722            12-Oct-16   1
## 723            12-Oct-17   2
## 724            12-Oct-18  11
## 725            12-Oct-20   6
## 726            12-Sep-17   2
## 727            12-Sep-18   2
## 728            12-Sep-19   3
## 729            13-Apr-18   5
## 730            13-Apr-19   2
## 731            13-Apr-20   4
## 732            13-Apr-21   9
## 733            13-Aug-16   1
## 734            13-Aug-17   2
## 735            13-Aug-19   5
## 736            13-Aug-20   6
## 737            13-Aug-21   7
## 738            13-Dec-16   1
## 739            13-Dec-19   8
## 740            13-Dec-20   1
## 741            13-Feb-15   1
## 742            13-Feb-18   1
## 743            13-Feb-19   1
## 744            13-Feb-20   5
## 745            13-Feb-21   1
## 746            13-Jan-17   3
## 747            13-Jan-19   3
## 748            13-Jan-20   2
## 749            13-Jan-21   2
## 750            13-Jul-17   3
## 751            13-Jul-18   6
## 752            13-Jul-19   1
## 753            13-Jul-21   4
## 754            13-Jun-16   1
## 755            13-Jun-17   2
## 756            13-Jun-19   9
## 757            13-Jun-20   5
## 758            13-Jun-21   3
## 759            13-Mar-18   3
## 760            13-Mar-19   3
## 761            13-Mar-20   9
## 762            13-May-17   1
## 763            13-May-18   1
## 764            13-May-19   1
## 765            13-May-20   2
## 766            13-May-21   4
## 767            13-Nov-15   2
## 768            13-Nov-17   1
## 769            13-Nov-18   3
## 770            13-Nov-19   1
## 771            13-Nov-20   8
## 772            13-Oct-16   1
## 773            13-Oct-17   6
## 774            13-Oct-18   1
## 775            13-Oct-19   2
## 776            13-Oct-20   3
## 777            13-Sep-16   1
## 778            13-Sep-17   2
## 779            13-Sep-18   2
## 780            13-Sep-19  12
## 781            14-Apr-17   5
## 782            14-Apr-18   1
## 783            14-Apr-19   2
## 784            14-Apr-20   2
## 785            14-Apr-21  15
## 786            14-Aug-15   1
## 787            14-Aug-17   4
## 788            14-Aug-19   2
## 789            14-Aug-20  10
## 790            14-Dec-16   1
## 791            14-Dec-17   1
## 792            14-Dec-18   9
## 793            14-Dec-20   3
## 794            14-Feb-16   1
## 795            14-Feb-17   4
## 796            14-Feb-18   3
## 797            14-Feb-19   4
## 798            14-Feb-20  10
## 799            14-Feb-21   1
## 800            14-Jan-17   4
## 801            14-Jan-19   2
## 802            14-Jan-20   3
## 803            14-Jan-21   2
## 804            14-Jul-15   1
## 805            14-Jul-16   2
## 806            14-Jul-17   3
## 807            14-Jul-18   3
## 808            14-Jul-20   3
## 809            14-Jul-21   6
## 810            14-Jun-18   1
## 811            14-Jun-19  10
## 812            14-Jun-21   1
## 813            14-Mar-17   4
## 814            14-Mar-18   1
## 815            14-Mar-19   6
## 816            14-Mar-20   1
## 817            14-Mar-21   1
## 818            14-May-17   1
## 819            14-May-19   4
## 820            14-May-20   8
## 821            14-May-21  14
## 822            14-Nov-12   1
## 823            14-Nov-14   1
## 824            14-Nov-17   1
## 825            14-Nov-19   3
## 826            14-Nov-20   1
## 827            14-Oct-13   2
## 828            14-Oct-15   1
## 829            14-Oct-16   1
## 830            14-Oct-17   1
## 831            14-Oct-19   1
## 832            14-Oct-20   3
## 833            14-Sep-18  11
## 834            14-Sep-19   2
## 835            14-Sep-20   1
## 836            14-Sep-21   6
## 837            15-Apr-14   1
## 838            15-Apr-16   3
## 839            15-Apr-17  12
## 840            15-Apr-18   5
## 841            15-Apr-19  10
## 842            15-Apr-20  12
## 843            15-Apr-21  18
## 844            15-Aug-14   1
## 845            15-Aug-16   6
## 846            15-Aug-17   8
## 847            15-Aug-18   6
## 848            15-Aug-19   5
## 849            15-Aug-20   4
## 850            15-Aug-21   5
## 851            15-Dec-15   2
## 852            15-Dec-16  18
## 853            15-Dec-17  23
## 854            15-Dec-18  16
## 855            15-Dec-19  29
## 856            15-Dec-20   7
## 857            15-Feb-15   1
## 858            15-Feb-17   8
## 859            15-Feb-18  13
## 860            15-Feb-19  24
## 861            15-Feb-20   3
## 862            15-Feb-21   3
## 863            15-Jan-16   2
## 864            15-Jan-17  10
## 865            15-Jan-18  12
## 866            15-Jan-19  15
## 867            15-Jan-20   8
## 868            15-Jan-21  13
## 869            15-Jul-15   2
## 870            15-Jul-16   4
## 871            15-Jul-17   3
## 872            15-Jul-18  14
## 873            15-Jul-19   5
## 874            15-Jul-20   7
## 875            15-Jul-21  11
## 876            15-Jun-14   1
## 877            15-Jun-15   1
## 878            15-Jun-17   6
## 879            15-Jun-18  10
## 880            15-Jun-19  11
## 881            15-Jun-20   4
## 882            15-Jun-21  12
## 883            15-Mar-15   2
## 884            15-Mar-17   8
## 885            15-Mar-18  23
## 886            15-Mar-19  21
## 887            15-Mar-20   7
## 888            15-Mar-21   6
## 889            15-May-16   1
## 890            15-May-17  12
## 891            15-May-18   6
## 892            15-May-19   7
## 893            15-May-20  15
## 894            15-May-21   3
## 895            15-Nov-16   4
## 896            15-Nov-17   5
## 897            15-Nov-18  15
## 898            15-Nov-19  24
## 899            15-Nov-20   9
## 900            15-Oct-16   9
## 901            15-Oct-17  23
## 902            15-Oct-18   4
## 903            15-Oct-19   3
## 904            15-Oct-20  11
## 905            15-Sep-15   1
## 906            15-Sep-16   3
## 907            15-Sep-17   9
## 908            15-Sep-18  15
## 909            15-Sep-19   9
## 910            15-Sep-20  10
## 911            15-Sep-21  22
## 912            16-Apr-15   1
## 913            16-Apr-17   1
## 914            16-Apr-18   2
## 915            16-Apr-19   5
## 916            16-Apr-20   8
## 917            16-Apr-21  15
## 918            16-Aug-17   1
## 919            16-Aug-18  22
## 920            16-Aug-19  14
## 921            16-Aug-20   3
## 922            16-Aug-21   2
## 923            16-Dec-16   6
## 924            16-Dec-17   2
## 925            16-Dec-18   9
## 926            16-Dec-19   3
## 927            16-Dec-20  11
## 928            16-Feb-14   1
## 929            16-Feb-17   2
## 930            16-Feb-18   5
## 931            16-Feb-19   3
## 932            16-Feb-20   6
## 933            16-Feb-21   4
## 934            16-Jan-17   2
## 935            16-Jan-18   3
## 936            16-Jan-19   2
## 937            16-Jan-20   9
## 938            16-Jan-21   3
## 939            16-Jul-19   6
## 940            16-Jul-20   3
## 941            16-Jul-21  14
## 942            16-Jun-17   5
## 943            16-Jun-19   2
## 944            16-Jun-20   2
## 945            16-Jun-21   9
## 946            16-Mar-16   1
## 947            16-Mar-17   6
## 948            16-Mar-18   5
## 949            16-Mar-19   1
## 950            16-Mar-20   1
## 951            16-Mar-21   4
## 952            16-May-17   2
## 953            16-May-18   2
## 954            16-May-19   4
## 955            16-May-20   2
## 956            16-May-21   1
## 957            16-Nov-17   1
## 958            16-Nov-18   7
## 959            16-Nov-19   4
## 960            16-Nov-20   2
## 961            16-Oct-15   3
## 962            16-Oct-16   1
## 963            16-Oct-17   7
## 964            16-Oct-18   2
## 965            16-Oct-19   7
## 966            16-Oct-20   8
## 967            16-Sep-16   5
## 968            16-Sep-18   2
## 969            16-Sep-19   1
## 970            16-Sep-20   9
## 971            16-Sep-21  12
## 972            17-Apr-15   1
## 973            17-Apr-16   1
## 974            17-Apr-18   3
## 975            17-Apr-19   5
## 976            17-Apr-20   8
## 977            17-Apr-21   8
## 978            17-Aug-17   1
## 979            17-Aug-18   5
## 980            17-Aug-20   3
## 981            17-Dec-14   1
## 982            17-Dec-15   1
## 983            17-Dec-18   3
## 984            17-Dec-19   1
## 985            17-Dec-20   9
## 986            17-Feb-17   5
## 987            17-Feb-18   1
## 988            17-Feb-19   2
## 989            17-Feb-20   2
## 990            17-Feb-21   4
## 991            17-Jan-14   1
## 992            17-Jan-17   4
## 993            17-Jan-18   2
## 994            17-Jan-20   5
## 995            17-Jul-15   1
## 996            17-Jul-17   1
## 997            17-Jul-18   1
## 998            17-Jul-19   3
## 999            17-Jul-20   5
## 1000           17-Jul-21   1
## 1001           17-Jun-17   1
## 1002           17-Jun-20   2
## 1003           17-Jun-21  11
## 1004           17-Mar-17   5
## 1005           17-Mar-19   2
## 1006           17-Mar-20   3
## 1007           17-Mar-21   3
## 1008           17-May-11   1
## 1009           17-May-15   1
## 1010           17-May-18   1
## 1011           17-May-19  11
## 1012           17-May-20   3
## 1013           17-Nov-16   1
## 1014           17-Nov-17   8
## 1015           17-Nov-18   3
## 1016           17-Nov-19   1
## 1017           17-Nov-20   4
## 1018           17-Oct-17   1
## 1019           17-Oct-18   2
## 1020           17-Oct-19   2
## 1021           17-Oct-20   1
## 1022           17-Sep-16   1
## 1023           17-Sep-17   1
## 1024           17-Sep-18   1
## 1025           17-Sep-19   6
## 1026           17-Sep-20   7
## 1027           17-Sep-21   7
## 1028           18-Apr-17   2
## 1029           18-Apr-18   1
## 1030           18-Apr-19   6
## 1031           18-Apr-20   3
## 1032           18-Aug-17   4
## 1033           18-Aug-18   3
## 1034           18-Aug-20   2
## 1035           18-Aug-21  11
## 1036           18-Dec-14   1
## 1037           18-Dec-15   1
## 1038           18-Dec-17   2
## 1039           18-Dec-18   2
## 1040           18-Dec-19   2
## 1041           18-Dec-20  10
## 1042           18-Feb-16   2
## 1043           18-Feb-21   5
## 1044           18-Jan-17   1
## 1045           18-Jan-18   2
## 1046           18-Jan-19  13
## 1047           18-Jan-20   1
## 1048           18-Jan-21   1
## 1049           18-Jul-17   3
## 1050           18-Jul-18   3
## 1051           18-Jul-19   3
## 1052           18-Jul-20   3
## 1053           18-Jun-16   1
## 1054           18-Jun-18   4
## 1055           18-Jun-19   8
## 1056           18-Jun-20  15
## 1057           18-Jun-21  10
## 1058           18-Mar-16   4
## 1059           18-Mar-17   2
## 1060           18-Mar-19   1
## 1061           18-Mar-20   5
## 1062           18-Mar-21   8
## 1063           18-May-17   1
## 1064           18-May-18   3
## 1065           18-May-19   2
## 1066           18-May-20   2
## 1067           18-May-21   2
## 1068           18-Nov-09   1
## 1069           18-Nov-15   1
## 1070           18-Nov-16   4
## 1071           18-Nov-17   1
## 1072           18-Nov-18   1
## 1073           18-Nov-20   1
## 1074           18-Oct-17   1
## 1075           18-Oct-18   1
## 1076           18-Oct-19  22
## 1077           18-Oct-20   3
## 1078           18-Sep-15   1
## 1079           18-Sep-17   5
## 1080           18-Sep-18   1
## 1081           18-Sep-19   2
## 1082           18-Sep-20   5
## 1083           19-Apr-17   2
## 1084           19-Apr-18   3
## 1085           19-Apr-19  14
## 1086           19-Apr-21   4
## 1087           19-Aug-16   1
## 1088           19-Aug-17   2
## 1089           19-Aug-18   3
## 1090           19-Aug-20   3
## 1091           19-Aug-21   2
## 1092           19-Dec-14   1
## 1093           19-Dec-16   2
## 1094           19-Dec-17   5
## 1095           19-Dec-18   1
## 1096           19-Dec-19   3
## 1097           19-Dec-20   1
## 1098           19-Feb-16   1
## 1099           19-Feb-17   3
## 1100           19-Feb-18   5
## 1101           19-Feb-19   2
## 1102           19-Feb-21   5
## 1103           19-Jan-17   1
## 1104           19-Jan-18   3
## 1105           19-Jan-19   1
## 1106           19-Jan-21   1
## 1107           19-Jul-17   1
## 1108           19-Jul-18   7
## 1109           19-Jul-19   5
## 1110           19-Jul-20   1
## 1111           19-Jul-21   1
## 1112           19-Jun-17   1
## 1113           19-Jun-18   2
## 1114           19-Jun-19   5
## 1115           19-Jun-20  12
## 1116           19-Jun-21  24
## 1117           19-Mar-16   1
## 1118           19-Mar-18   1
## 1119           19-Mar-19   3
## 1120           19-Mar-20   4
## 1121           19-Mar-21   6
## 1122           19-May-17   6
## 1123           19-May-18   1
## 1124           19-May-19   1
## 1125           19-May-20  13
## 1126           19-May-21   5
## 1127           19-Nov-14   1
## 1128           19-Nov-16   1
## 1129           19-Nov-19   2
## 1130           19-Nov-20  11
## 1131           19-Oct-17   1
## 1132           19-Oct-18  18
## 1133           19-Oct-19   3
## 1134           19-Oct-20  16
## 1135           19-Sep-16   7
## 1136           19-Sep-17   1
## 1137           19-Sep-18   2
## 1138           19-Sep-19   2
## 1139           19-Sep-20   6
## 1140           19-Sep-21   2
## 1141           20-Apr-16   1
## 1142           20-Apr-18   5
## 1143           20-Apr-19   3
## 1144           20-Apr-20   4
## 1145           20-Apr-21   7
## 1146           20-Aug-17   1
## 1147           20-Aug-18   1
## 1148           20-Aug-19   3
## 1149           20-Aug-20   5
## 1150           20-Aug-21   8
## 1151           20-Dec-15   3
## 1152           20-Dec-16   4
## 1153           20-Dec-17   3
## 1154           20-Dec-18   7
## 1155           20-Dec-19   7
## 1156           20-Dec-20   2
## 1157           20-Feb-17   1
## 1158           20-Feb-18   4
## 1159           20-Feb-19   2
## 1160           20-Feb-20   3
## 1161           20-Feb-21   4
## 1162           20-Jan-17   3
## 1163           20-Jan-18   1
## 1164           20-Jan-20   3
## 1165           20-Jan-21   4
## 1166           20-Jul-17   2
## 1167           20-Jul-18  10
## 1168           20-Jul-19   2
## 1169           20-Jul-21   3
## 1170           20-Jun-16   1
## 1171           20-Jun-17   4
## 1172           20-Jun-18   1
## 1173           20-Jun-19   9
## 1174           20-Jun-20   1
## 1175           20-Jun-21   1
## 1176           20-Mar-17   2
## 1177           20-Mar-18   2
## 1178           20-Mar-19   6
## 1179           20-Mar-20  12
## 1180           20-Mar-21   4
## 1181           20-May-19   2
## 1182           20-May-20   8
## 1183           20-May-21   7
## 1184           20-Nov-18   7
## 1185           20-Nov-19  30
## 1186           20-Nov-20   8
## 1187           20-Oct-17   6
## 1188           20-Oct-18   2
## 1189           20-Oct-20   3
## 1190           20-Sep-16   1
## 1191           20-Sep-18   3
## 1192           20-Sep-19  10
## 1193           20-Sep-20   8
## 1194           20-Sep-21   1
## 1195           21-Apr-17   5
## 1196           21-Apr-19   1
## 1197           21-Apr-20   3
## 1198           21-Apr-21   3
## 1199           21-Aug-17   5
## 1200           21-Aug-18   5
## 1201           21-Aug-19   6
## 1202           21-Aug-20   8
## 1203           21-Aug-21   1
## 1204           21-Dec-16   1
## 1205           21-Dec-17   1
## 1206           21-Dec-18  13
## 1207           21-Dec-19   2
## 1208           21-Dec-20   2
## 1209           21-Feb-12   1
## 1210           21-Feb-17   1
## 1211           21-Feb-18   3
## 1212           21-Feb-19   2
## 1213           21-Feb-20   9
## 1214           21-Feb-21   3
## 1215           21-Jan-20   2
## 1216           21-Jan-21   2
## 1217           21-Jul-16   1
## 1218           21-Jul-17   1
## 1219           21-Jul-18   2
## 1220           21-Jul-19   8
## 1221           21-Jul-20   3
## 1222           21-Jul-21   4
## 1223           21-Jun-17   2
## 1224           21-Jun-19  14
## 1225           21-Jun-20   2
## 1226           21-Jun-21   4
## 1227           21-Mar-17   4
## 1228           21-Mar-18   1
## 1229           21-Mar-19   9
## 1230           21-Mar-20   1
## 1231           21-May-19   2
## 1232           21-May-20  12
## 1233           21-May-21   8
## 1234           21-Nov-14   1
## 1235           21-Nov-16   1
## 1236           21-Nov-17   4
## 1237           21-Nov-18   2
## 1238           21-Nov-19   2
## 1239           21-Oct-14   1
## 1240           21-Oct-16   2
## 1241           21-Oct-17   1
## 1242           21-Oct-18   1
## 1243           21-Oct-19   1
## 1244           21-Oct-20   3
## 1245           21-Sep-18   6
## 1246           21-Sep-19   4
## 1247           21-Sep-20   1
## 1248           21-Sep-21   5
## 1249           22-Apr-15   3
## 1250           22-Apr-16   2
## 1251           22-Apr-17   6
## 1252           22-Apr-19   1
## 1253           22-Apr-20   7
## 1254           22-Apr-21   5
## 1255           22-Aug-17   2
## 1256           22-Aug-20   2
## 1257           22-Dec-17   2
## 1258           22-Dec-18   5
## 1259           22-Dec-19   2
## 1260           22-Dec-20   8
## 1261           22-Feb-17  11
## 1262           22-Feb-18   1
## 1263           22-Feb-19  11
## 1264           22-Feb-20   2
## 1265           22-Feb-21   1
## 1266           22-Jan-16   1
## 1267           22-Jan-18   4
## 1268           22-Jan-20   3
## 1269           22-Jan-21   6
## 1270           22-Jul-18   2
## 1271           22-Jul-19   4
## 1272           22-Jul-20   4
## 1273           22-Jul-21  25
## 1274           22-Jun-17   2
## 1275           22-Jun-18   6
## 1276           22-Jun-19   2
## 1277           22-Jun-20   3
## 1278           22-Jun-21   5
## 1279           22-Mar-19   9
## 1280           22-Mar-20   1
## 1281           22-Mar-21   1
## 1282           22-May-15   2
## 1283           22-May-16   1
## 1284           22-May-17   7
## 1285           22-May-18   2
## 1286           22-May-19   2
## 1287           22-May-20   5
## 1288           22-May-21   1
## 1289           22-Nov-16   2
## 1290           22-Nov-17   3
## 1291           22-Nov-18   2
## 1292           22-Nov-19  11
## 1293           22-Nov-20   2
## 1294           22-Oct-15   1
## 1295           22-Oct-17   7
## 1296           22-Oct-18   1
## 1297           22-Oct-19   6
## 1298           22-Oct-20   7
## 1299           22-Sep-15   1
## 1300           22-Sep-17   2
## 1301           22-Sep-18   2
## 1302           22-Sep-19   1
## 1303           22-Sep-20   2
## 1304           22-Sep-21   9
## 1305           23-Apr-17   1
## 1306           23-Apr-19   1
## 1307           23-Apr-20   6
## 1308           23-Apr-21  20
## 1309           23-Aug-17   1
## 1310           23-Aug-18   2
## 1311           23-Aug-19   7
## 1312           23-Aug-20   1
## 1313           23-Aug-21   5
## 1314           23-Dec-16   4
## 1315           23-Dec-17   2
## 1316           23-Dec-18   3
## 1317           23-Dec-20   3
## 1318           23-Feb-17   2
## 1319           23-Feb-18   5
## 1320           23-Feb-19   1
## 1321           23-Feb-20   2
## 1322           23-Feb-21   4
## 1323           23-Jan-15   1
## 1324           23-Jan-16   1
## 1325           23-Jan-17   1
## 1326           23-Jan-18   3
## 1327           23-Jan-19   1
## 1328           23-Jan-20   6
## 1329           23-Jul-18   1
## 1330           23-Jul-19   2
## 1331           23-Jul-20   3
## 1332           23-Jul-21  11
## 1333           23-Jun-15   1
## 1334           23-Jun-17   4
## 1335           23-Jun-18   6
## 1336           23-Jun-19   1
## 1337           23-Jun-20   2
## 1338           23-Jun-21   5
## 1339           23-Mar-17   1
## 1340           23-Mar-18   8
## 1341           23-Mar-19   3
## 1342           23-Mar-20   2
## 1343           23-Mar-21   3
## 1344           23-May-16   1
## 1345           23-May-17   2
## 1346           23-May-19   1
## 1347           23-May-20   3
## 1348           23-May-21   1
## 1349           23-Nov-17   1
## 1350           23-Nov-18   3
## 1351           23-Nov-19   5
## 1352           23-Nov-20   4
## 1353           23-Oct-15   1
## 1354           23-Oct-17   1
## 1355           23-Oct-18   4
## 1356           23-Oct-19   4
## 1357           23-Oct-20   7
## 1358           23-Sep-16   3
## 1359           23-Sep-19   2
## 1360           23-Sep-20   2
## 1361           23-Sep-21   2
## 1362           24-Apr-18   2
## 1363           24-Apr-19   2
## 1364           24-Apr-20   6
## 1365           24-Apr-21   2
## 1366           24-Aug-18  10
## 1367           24-Aug-19   2
## 1368           24-Aug-20   1
## 1369           24-Aug-21   3
## 1370           24-Dec-18   2
## 1371           24-Dec-19   4
## 1372           24-Dec-20   3
## 1373           24-Feb-16   1
## 1374           24-Feb-17   3
## 1375           24-Feb-19   3
## 1376           24-Feb-21   6
## 1377           24-Jan-14   1
## 1378           24-Jan-17   1
## 1379           24-Jan-18   4
## 1380           24-Jan-19   3
## 1381           24-Jan-20   6
## 1382           24-Jul-16   1
## 1383           24-Jul-17   2
## 1384           24-Jul-18   3
## 1385           24-Jul-19   1
## 1386           24-Jul-20   8
## 1387           24-Jul-21   1
## 1388           24-Jun-16   3
## 1389           24-Jun-17   2
## 1390           24-Jun-18   1
## 1391           24-Jun-19   1
## 1392           24-Jun-20   4
## 1393           24-Jun-21   5
## 1394           24-Mar-17   4
## 1395           24-Mar-18   2
## 1396           24-Mar-19   1
## 1397           24-Mar-20   1
## 1398           24-Mar-21   1
## 1399           24-May-18   1
## 1400           24-May-19   7
## 1401           24-May-20   1
## 1402           24-May-21   1
## 1403           24-Nov-17   5
## 1404           24-Nov-19   3
## 1405           24-Nov-20   7
## 1406           24-Oct-14   1
## 1407           24-Oct-17   3
## 1408           24-Oct-18   1
## 1409           24-Oct-19   3
## 1410           24-Oct-20   2
## 1411           24-Sep-17   2
## 1412           24-Sep-18   1
## 1413           24-Sep-19   2
## 1414           24-Sep-20   2
## 1415           24-Sep-21  10
## 1416           25-Apr-16   1
## 1417           25-Apr-17   4
## 1418           25-Apr-18   3
## 1419           25-Apr-19   7
## 1420           25-Apr-20  11
## 1421           25-Aug-16   2
## 1422           25-Aug-17   4
## 1423           25-Aug-18   4
## 1424           25-Aug-19   1
## 1425           25-Aug-20   2
## 1426           25-Aug-21  12
## 1427           25-Dec-15   1
## 1428           25-Dec-16   1
## 1429           25-Dec-17   3
## 1430           25-Dec-18   2
## 1431           25-Dec-19   6
## 1432           25-Dec-20   4
## 1433           25-Feb-17   2
## 1434           25-Feb-18   1
## 1435           25-Feb-19   3
## 1436           25-Feb-20   2
## 1437           25-Feb-21   4
## 1438           25-Jan-17   1
## 1439           25-Jan-18   1
## 1440           25-Jan-19   7
## 1441           25-Jan-20   1
## 1442           25-Jul-16   1
## 1443           25-Jul-17   1
## 1444           25-Jul-18   8
## 1445           25-Jul-19   1
## 1446           25-Jul-20   3
## 1447           25-Jun-17   1
## 1448           25-Jun-18   2
## 1449           25-Jun-19   2
## 1450           25-Jun-20   3
## 1451           25-Jun-21   4
## 1452           25-Mar-16   1
## 1453           25-Mar-19   2
## 1454           25-Mar-20   4
## 1455           25-Mar-21   4
## 1456           25-May-17   1
## 1457           25-May-18   5
## 1458           25-May-19   2
## 1459           25-May-20   5
## 1460           25-May-21   2
## 1461           25-Nov-16   3
## 1462           25-Nov-18   2
## 1463           25-Nov-19   2
## 1464           25-Nov-20   4
## 1465           25-Oct-15   1
## 1466           25-Oct-17   2
## 1467           25-Oct-18   4
## 1468           25-Oct-19  16
## 1469           25-Oct-20   1
## 1470           25-Sep-17   3
## 1471           25-Sep-18   1
## 1472           25-Sep-19   8
## 1473           25-Sep-20   6
## 1474           25-Sep-21   1
## 1475           26-Apr-17   1
## 1476           26-Apr-18   2
## 1477           26-Apr-19  12
## 1478           26-Apr-20   2
## 1479           26-Aug-16   4
## 1480           26-Aug-17   2
## 1481           26-Aug-18   1
## 1482           26-Aug-19   1
## 1483           26-Aug-20   5
## 1484           26-Aug-21   2
## 1485           26-Dec-15   1
## 1486           26-Dec-16   4
## 1487           26-Dec-17   3
## 1488           26-Dec-18   1
## 1489           26-Dec-19   3
## 1490           26-Dec-20   3
## 1491           26-Feb-16   2
## 1492           26-Feb-17   1
## 1493           26-Feb-18   3
## 1494           26-Feb-19   1
## 1495           26-Feb-20   8
## 1496           26-Feb-21  10
## 1497           26-Jan-17   1
## 1498           26-Jan-18   6
## 1499           26-Jan-19   2
## 1500           26-Jan-20   2
## 1501           26-Jan-21   4
## 1502           26-Jul-18  11
## 1503           26-Jul-19  13
## 1504           26-Jul-20   2
## 1505           26-Jul-21   2
## 1506           26-Jun-15   1
## 1507           26-Jun-17   2
## 1508           26-Jun-18   3
## 1509           26-Jun-19   5
## 1510           26-Jun-20  10
## 1511           26-Jun-21   2
## 1512           26-Mar-18   1
## 1513           26-Mar-19   1
## 1514           26-Mar-20   6
## 1515           26-Mar-21  11
## 1516           26-May-16   1
## 1517           26-May-17   5
## 1518           26-May-18   2
## 1519           26-May-19   2
## 1520           26-May-20   1
## 1521           26-May-21   5
## 1522           26-Nov-19   5
## 1523           26-Nov-20   4
## 1524           26-Oct-17   1
## 1525           26-Oct-18   8
## 1526           26-Oct-19   2
## 1527           26-Oct-20   1
## 1528           26-Sep-14   1
## 1529           26-Sep-17   3
## 1530           26-Sep-18   1
## 1531           26-Sep-19   3
## 1532           26-Sep-20   2
## 1533           27-Apr-17   1
## 1534           27-Apr-18   9
## 1535           27-Apr-19   1
## 1536           27-Apr-20   3
## 1537           27-Apr-21   5
## 1538           27-Aug-17   1
## 1539           27-Aug-18   2
## 1540           27-Aug-19   1
## 1541           27-Aug-20   6
## 1542           27-Aug-21  27
## 1543           27-Dec-16   2
## 1544           27-Dec-17   3
## 1545           27-Dec-18   1
## 1546           27-Dec-19   5
## 1547           27-Dec-20   2
## 1548           27-Feb-15   1
## 1549           27-Feb-17   1
## 1550           27-Feb-18   2
## 1551           27-Feb-19  15
## 1552           27-Feb-20   6
## 1553           27-Jan-17   3
## 1554           27-Jan-19   2
## 1555           27-Jan-20   2
## 1556           27-Jan-21   6
## 1557           27-Jul-18   6
## 1558           27-Jul-21   8
## 1559           27-Jun-17   1
## 1560           27-Jun-18   1
## 1561           27-Jun-19   3
## 1562           27-Jun-20   2
## 1563           27-Mar-18   2
## 1564           27-Mar-19   2
## 1565           27-Mar-20  12
## 1566           27-May-16   1
## 1567           27-May-18   1
## 1568           27-May-19   2
## 1569           27-May-20   1
## 1570           27-May-21   7
## 1571           27-Nov-17   2
## 1572           27-Nov-18   3
## 1573           27-Nov-19   5
## 1574           27-Nov-20   9
## 1575           27-Oct-15   1
## 1576           27-Oct-16   1
## 1577           27-Oct-17   2
## 1578           27-Oct-18   2
## 1579           27-Oct-19   1
## 1580           27-Oct-20   4
## 1581           27-Sep-11   1
## 1582           27-Sep-17   1
## 1583           27-Sep-18   1
## 1584           27-Sep-19   5
## 1585           27-Sep-20   1
## 1586           28-Apr-16   1
## 1587           28-Apr-17   8
## 1588           28-Apr-19   1
## 1589           28-Apr-20  12
## 1590           28-Apr-21   3
## 1591           28-Aug-17   1
## 1592           28-Aug-18   4
## 1593           28-Aug-19   1
## 1594           28-Aug-20   5
## 1595           28-Aug-21   4
## 1596           28-Dec-15   1
## 1597           28-Dec-16   1
## 1598           28-Dec-18  10
## 1599           28-Dec-19   1
## 1600           28-Dec-20   3
## 1601           28-Feb-17   3
## 1602           28-Feb-18   2
## 1603           28-Feb-19   3
## 1604           28-Feb-20   6
## 1605           28-Feb-21   1
## 1606           28-Jan-16   4
## 1607           28-Jan-19   6
## 1608           28-Jan-21   1
## 1609           28-Jul-17   3
## 1610           28-Jul-18   6
## 1611           28-Jul-20   1
## 1612           28-Jul-21   5
## 1613           28-Jun-17   1
## 1614           28-Jun-18   1
## 1615           28-Jun-19  11
## 1616           28-Jun-20   3
## 1617           28-Jun-21   4
## 1618           28-Mar-17   1
## 1619           28-Mar-18   1
## 1620           28-Mar-19   1
## 1621           28-Mar-20   1
## 1622           28-Mar-21   2
## 1623           28-May-19   2
## 1624           28-May-20   9
## 1625           28-May-21   5
## 1626           28-Nov-18   1
## 1627           28-Nov-19   6
## 1628           28-Oct-16   6
## 1629           28-Oct-17   1
## 1630           28-Oct-18   1
## 1631           28-Oct-19   2
## 1632           28-Oct-20   5
## 1633           28-Sep-17   1
## 1634           28-Sep-18  11
## 1635           28-Sep-19   3
## 1636           28-Sep-20  11
## 1637           29-Apr-16   2
## 1638           29-Apr-19   4
## 1639           29-Apr-20   8
## 1640           29-Apr-21   2
## 1641           29-Aug-17   2
## 1642           29-Aug-18   2
## 1643           29-Aug-19   4
## 1644           29-Aug-20   1
## 1645           29-Aug-21   2
## 1646           29-Dec-13   1
## 1647           29-Dec-17   5
## 1648           29-Dec-18   2
## 1649           29-Jan-17   1
## 1650           29-Jan-18   4
## 1651           29-Jan-19   6
## 1652           29-Jan-20   4
## 1653           29-Jan-21   4
## 1654           29-Jul-16   2
## 1655           29-Jul-18   1
## 1656           29-Jul-19   3
## 1657           29-Jul-20   6
## 1658           29-Jul-21   3
## 1659           29-Jun-15   1
## 1660           29-Jun-18   8
## 1661           29-Jun-19   2
## 1662           29-Jun-20   1
## 1663           29-Jun-21   1
## 1664           29-Mar-18   1
## 1665           29-Mar-19  14
## 1666           29-Mar-20   2
## 1667           29-Mar-21   1
## 1668           29-May-15   1
## 1669           29-May-17   2
## 1670           29-May-18   1
## 1671           29-May-20   4
## 1672           29-May-21   1
## 1673           29-Nov-19  11
## 1674           29-Nov-20   1
## 1675           29-Oct-16   1
## 1676           29-Oct-18   1
## 1677           29-Oct-19   3
## 1678           29-Oct-20   1
## 1679           29-Sep-15   1
## 1680           29-Sep-17   8
## 1681           29-Sep-18   2
## 1682           29-Sep-20   3
## 1683           30-Apr-18   4
## 1684           30-Apr-19  10
## 1685           30-Apr-20   7
## 1686           30-Apr-21   7
## 1687           30-Aug-18   1
## 1688           30-Aug-19   8
## 1689           30-Aug-20   2
## 1690           30-Dec-16   1
## 1691           30-Dec-17   1
## 1692           30-Dec-18   4
## 1693           30-Dec-19   1
## 1694           30-Dec-20   7
## 1695           30-Jan-18   4
## 1696           30-Jan-19   6
## 1697           30-Jan-20   4
## 1698           30-Jul-17   1
## 1699           30-Jul-18   5
## 1700           30-Jul-19   4
## 1701           30-Jul-20   4
## 1702           30-Jul-21  10
## 1703           30-Jun-16   2
## 1704           30-Jun-17   5
## 1705           30-Jun-18   5
## 1706           30-Jun-19   4
## 1707           30-Jun-20   4
## 1708           30-Jun-21  10
## 1709           30-Mar-17   3
## 1710           30-Mar-18  10
## 1711           30-Mar-19   2
## 1712           30-Mar-21   3
## 1713           30-May-17   2
## 1714           30-May-18   1
## 1715           30-May-19   3
## 1716           30-May-21   1
## 1717           30-Nov-16   1
## 1718           30-Nov-17   1
## 1719           30-Nov-18  13
## 1720           30-Nov-19   3
## 1721           30-Nov-20   4
## 1722           30-Oct-17   1
## 1723           30-Oct-18   5
## 1724           30-Oct-19   4
## 1725           30-Oct-20  10
## 1726           30-Sep-16   1
## 1727           30-Sep-17   2
## 1728           30-Sep-18   7
## 1729           30-Sep-19   2
## 1730           30-Sep-20   9
## 1731           31-Aug-17   1
## 1732           31-Aug-18  10
## 1733           31-Aug-19   1
## 1734           31-Aug-20   4
## 1735           31-Aug-21   3
## 1736           31-Dec-15   1
## 1737           31-Dec-16   2
## 1738           31-Dec-17  17
## 1739           31-Dec-18  27
## 1740           31-Dec-19  74
## 1741           31-Dec-20   6
## 1742           31-Jan-17   2
## 1743           31-Jan-18   1
## 1744           31-Jan-19   8
## 1745           31-Jan-20   8
## 1746           31-Jan-21   2
## 1747           31-Jul-15   1
## 1748           31-Jul-18   3
## 1749           31-Jul-19   3
## 1750           31-Jul-20   7
## 1751           31-Jul-21   3
## 1752           31-Mar-13   1
## 1753           31-Mar-16   1
## 1754           31-Mar-17  30
## 1755           31-Mar-18   8
## 1756           31-Mar-19   3
## 1757           31-Mar-20  13
## 1758           31-Mar-21   5
## 1759           31-May-17   1
## 1760           31-May-18   1
## 1761           31-May-19   7
## 1762           31-May-20   1
## 1763           31-May-21   1
## 1764           31-Oct-15   1
## 1765           31-Oct-17   2
## 1766           31-Oct-18   2
## 1767           31-Oct-19   4
## 1768           31-Oct-20   3
library(lubridate)
View(df)
df1<-df %>% filter(country=="United Kingdom") %>% 
  mutate(ymd=dmy(date_added)) %>% 
  filter(ymd>='2018-01-01'&ymd<='2018-01-31')
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `ymd = dmy(date_added)`.
## Caused by warning:
## !  15 failed to parse.
df1
##   show_id    type                                        title        director
## 1   s5058 TV Show                                  Retribution                
## 2   s5075   Movie                          Bad Day for the Cut     Chris Baugh
## 3   s5098 TV Show                                     Lovesick                
## 4   s7399   Movie   Manolo: The Boy Who Made Shoes for Lizards Michael Roberts
## 5   s8620   Movie Treasures from the Wreck of the Unbelievable   Sam Hobkinson
##                                                                                                                                                                            cast
## 1                         Georgina Campbell, Joe Dempsie, Adrian Edmondson, Steve Evets, Laura Fraser, Julie Graham, John Lynch, Gary Lewis, Juliet Stevenson, Joanna Vanderham
## 2                        Nigel O'Neill, Susan Lynch, J?zef Pawlowski, Stuart Graham, David Pearse, Brian Milligan, Anna Prochniak, Stella McCusker, Ian McElhinney, Lalor Roddy
## 3                                                                  Johnny Flynn, Antonia Thomas, Daniel Ings, Hannah Britland, Joshua McGuire, Richard Thomson, Jessica Ellerby
## 4 Manolo Blahnik, Anna Wintour, Andr? Leon Talley, Paloma Picasso, Candace Bushnell, Iman, Rihanna, Naomi Campbell, Isaac Mizrahi, Rupert Everett, Sofia Coppola, John Galliano
## 5                                                                                                                                                                              
##          country date_added release_year rating  duration
## 1 United Kingdom  30-Jan-18         2016  TV-MA  1 Season
## 2 United Kingdom  18-Jan-18         2017  TV-MA    99 min
## 3 United Kingdom  01-Jan-18         2018  TV-MA 3 Seasons
## 4 United Kingdom  15-Jan-18         2017  TV-MA    89 min
## 5 United Kingdom  01-Jan-18         2017   TV-G    82 min
##                                                     listed_in        ymd
## 1    British TV Shows, Crime TV Shows, International TV Shows 2018-01-30
## 2         Independent Movies, International Movies, Thrillers 2018-01-18
## 3 British TV Shows, International TV Shows, Romantic TV Shows 2018-01-01
## 4                         Documentaries, International Movies 2018-01-15
## 5                 Documentaries, Dramas, International Movies 2018-01-01
df$y2<-parse_date_time(df$date_added,orders = c("mdy","dmy"),
                       train=F)
df %>%  filter(country=="United Kingdom") %>% 
  filter(y2>='2018-01-01'&y2<='2018-01-31')
##   show_id    type                                        title        director
## 1   s5058 TV Show                                  Retribution                
## 2   s5075   Movie                          Bad Day for the Cut     Chris Baugh
## 3   s5098 TV Show                                     Lovesick                
## 4   s7399   Movie   Manolo: The Boy Who Made Shoes for Lizards Michael Roberts
## 5   s8358 TV Show                             The Inbetweeners                
## 6   s8620   Movie Treasures from the Wreck of the Unbelievable   Sam Hobkinson
##                                                                                                                                                                            cast
## 1                         Georgina Campbell, Joe Dempsie, Adrian Edmondson, Steve Evets, Laura Fraser, Julie Graham, John Lynch, Gary Lewis, Juliet Stevenson, Joanna Vanderham
## 2                        Nigel O'Neill, Susan Lynch, J?zef Pawlowski, Stuart Graham, David Pearse, Brian Milligan, Anna Prochniak, Stella McCusker, Ian McElhinney, Lalor Roddy
## 3                                                                  Johnny Flynn, Antonia Thomas, Daniel Ings, Hannah Britland, Joshua McGuire, Richard Thomson, Jessica Ellerby
## 4 Manolo Blahnik, Anna Wintour, Andr? Leon Talley, Paloma Picasso, Candace Bushnell, Iman, Rihanna, Naomi Campbell, Isaac Mizrahi, Rupert Everett, Sofia Coppola, John Galliano
## 5                     Simon Bird, James Buckley, Blake Harrison, Joe Thomas, Greg Davies, Emily Head, Martin Trenaman, Belinda Stewart-Wilson, Robin Weaver, Henry Lloyd-Hughes
## 6                                                                                                                                                                              
##          country       date_added release_year rating  duration
## 1 United Kingdom        30-Jan-18         2016  TV-MA  1 Season
## 2 United Kingdom        18-Jan-18         2017  TV-MA    99 min
## 3 United Kingdom        01-Jan-18         2018  TV-MA 3 Seasons
## 4 United Kingdom        15-Jan-18         2017  TV-MA    89 min
## 5 United Kingdom  January 1, 2018         2010  TV-MA 3 Seasons
## 6 United Kingdom        01-Jan-18         2017   TV-G    82 min
##                                                     listed_in         y2
## 1    British TV Shows, Crime TV Shows, International TV Shows 2018-01-30
## 2         Independent Movies, International Movies, Thrillers 2018-01-18
## 3 British TV Shows, International TV Shows, Romantic TV Shows 2018-01-01
## 4                         Documentaries, International Movies 2018-01-15
## 5                               British TV Shows, TV Comedies 2018-01-01
## 6                 Documentaries, Dramas, International Movies 2018-01-01
library(dplyr)
getwd()
## [1] "c:/abc"
getwd()
## [1] "c:/abc"
setwd('c:/abc')


library(plyr)
## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
## 
## 다음의 패키지를 부착합니다: 'plyr'
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
df<-read.csv("Data1.csv")
df$Gender<-as.factor(df$Gender)
df$Gender<-revalue(df$Gender,replace=c("0"="female","1"="male"))
glimpse(df)
## Rows: 1,925
## Columns: 27
## $ X         <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1…
## $ Q1        <int> 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, …
## $ Q2        <int> 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, 4, 4, 4, 2, 4, 4, 2, 4, 2, 2, …
## $ Q3        <int> 2, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, 3, 2, 3, …
## $ Q4        <int> 3, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 2, 2, 4, …
## $ Q5        <int> 4, 4, 2, 4, 4, 4, 4, 4, 2, 4, 4, 2, 4, 4, 4, 4, 4, 3, 1, 2, …
## $ Q6        <int> 2, 3, 4, 4, 4, 4, 4, 4, 1, 2, 2, 2, 4, 4, 3, 5, 2, 2, 1, 4, …
## $ Q7        <int> 2, 2, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 5, 4, 4, 5, 4, 3, 4, 4, …
## $ Q8        <int> 4, 4, 4, 4, 4, 4, 5, 5, 2, 2, 4, 4, 4, 4, 3, 5, 4, 2, 4, 4, …
## $ Q9        <int> 4, 4, 4, 4, 2, 4, 5, 5, 3, 4, 4, 4, 2, 2, 4, 5, 2, 4, 2, 4, …
## $ Q10       <int> 4, 4, 2, 4, 4, 4, 5, 5, 2, 4, 2, 4, 4, 4, 3, 4, 4, 3, 2, 3, …
## $ Q11       <int> 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 4, 3, 4, 4, 4, 4, 5, 4, 3, 3, …
## $ Q12       <int> 4, 4, 4, 4, 4, 4, 5, 5, 3, 4, 4, 3, 4, 3, 3, 4, 5, 4, 4, 2, …
## $ Q13       <int> 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 4, 4, 2, 4, 4, 4, 5, 4, 4, 4, …
## $ Q14       <int> 4, 4, 4, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 4, 5, 4, 5, 4, 4, 4, …
## $ Q15       <int> 4, 4, 3, 4, 4, 4, 4, 2, 3, 4, 4, 3, 1, 4, 4, 4, 5, 4, 4, 4, …
## $ Q16       <int> 4, 4, 4, 4, 4, 4, 5, 2, 4, 4, 4, 4, 4, 4, 5, 4, 5, 4, 4, 4, …
## $ Q17       <int> 4, 3, 4, 4, 4, 4, 2, 2, 4, 4, 4, 4, 3, 2, 4, 5, 4, 4, 3, 4, …
## $ Q18       <int> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 2, 4, 4, 4, …
## $ Q19       <int> 4, 2, 4, 4, 4, 4, 4, 2, 4, 2, 4, 4, 1, 4, 4, 4, 5, 4, 2, 3, …
## $ Q20       <int> 4, 1, 3, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 2, 4, 5, 5, 4, 2, 4, …
## $ Gender    <fct> female, female, female, female, female, female, female, fema…
## $ EDU       <int> 1, 1, 2, 1, 2, 1, 1, 1, 4, 3, 2, 1, 1, 3, 3, 2, 1, 1, 1, 4, …
## $ BF        <dbl> 3.4, 4.0, 3.6, 4.2, 4.0, 4.0, 3.6, 3.6, 3.6, 3.2, 4.0, 3.2, …
## $ BM        <dbl> 3.2, 3.4, 3.6, 4.0, 3.6, 4.0, 4.6, 4.6, 2.2, 3.2, 3.2, 3.6, …
## $ Happiness <dbl> 4.0, 4.0, 3.8, 4.0, 4.0, 4.0, 4.8, 4.4, 3.8, 4.0, 4.0, 3.4, …
## $ Peace     <dbl> 4.0, 2.8, 3.8, 4.0, 4.0, 4.0, 3.8, 2.4, 4.0, 3.2, 4.0, 3.9, …
table(df$Gender)
## 
## female   male 
##   1136    789
colSums(is.na(df))
##         X        Q1        Q2        Q3        Q4        Q5        Q6        Q7 
##         0         0         0         0         0         0         0         0 
##        Q8        Q9       Q10       Q11       Q12       Q13       Q14       Q15 
##         0         0         0         0         0         0         0         0 
##       Q16       Q17       Q18       Q19       Q20    Gender       EDU        BF 
##         0         0         0         0         0         0         0         0 
##        BM Happiness     Peace 
##         0         0         0
library(caret)
control <- trainControl(method="repeatedcv", number=5)
model <- train(Gender ~., data=df, method="rf",
               preProcess=c("center","scale"), trControl=control)



library(caret)
library(mlbench)


set.seed(998) 
inTraining <- createDataPartition(y=df$Gender, p=0.8, list=FALSE)
training <- df[inTraining, ]
testing <- df[-inTraining, ]

fitControl <- trainControl(method="repeatedcv", number=2, repeats=2, 
                           classProbs=TRUE, 
                           summaryFunction=twoClassSummary,
                           savePredictions=TRUE)

grid <- expand.grid(mtry=1:2)

set.seed(998) 
rffit <- train(Gender~., data=training, method="rf",
               tuneGrid=grid, 
               trControl=fitControl,
               preProcess=c("center", "scale"),
               verbose = FALSE,   
               metric="ROC")


print(rffit)
## Random Forest 
## 
## 1541 samples
##   26 predictor
##    2 classes: 'female', 'male' 
## 
## Pre-processing: centered (26), scaled (26) 
## Resampling: Cross-Validated (2 fold, repeated 2 times) 
## Summary of sample sizes: 770, 771, 771, 770 
## Resampling results across tuning parameters:
## 
##   mtry  ROC        Sens       Spec     
##   1     0.6479403  0.8646924  0.2642405
##   2     0.6481700  0.8239834  0.3433544
## 
## ROC was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 2.
predictions_rf <- predict(rffit, testing)
confusionMatrix(predictions_rf, testing$Gender)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction female male
##     female    183   94
##     male       44   63
##                                           
##                Accuracy : 0.6406          
##                  95% CI : (0.5904, 0.6887)
##     No Information Rate : 0.5911          
##     P-Value [Acc > NIR] : 0.0268          
##                                           
##                   Kappa : 0.2182          
##                                           
##  Mcnemar's Test P-Value : 3.031e-05       
##                                           
##             Sensitivity : 0.8062          
##             Specificity : 0.4013          
##          Pos Pred Value : 0.6606          
##          Neg Pred Value : 0.5888          
##              Prevalence : 0.5911          
##          Detection Rate : 0.4766          
##    Detection Prevalence : 0.7214          
##       Balanced Accuracy : 0.6037          
##                                           
##        'Positive' Class : female          
## 
glfit <- train(Gender~.,data=training,
               method="glmnet",
               tuneLength = 20,
               trControl = fitControl,
               verbose = FALSE,
               metric = "ROC")

print(glfit) %>% head
## glmnet 
## 
## 1541 samples
##   26 predictor
##    2 classes: 'female', 'male' 
## 
## No pre-processing
## Resampling: Cross-Validated (2 fold, repeated 2 times) 
## Summary of sample sizes: 770, 771, 770, 771 
## Resampling results across tuning parameters:
## 
##   alpha      lambda        ROC        Sens       Spec       
##   0.1000000  0.0004813674  0.6172949  0.7448177  0.379746835
##   0.1000000  0.0007463678  0.6172949  0.7448177  0.379746835
##   0.1000000  0.0011572550  0.6172949  0.7448177  0.379746835
##   0.1000000  0.0017943422  0.6172949  0.7448177  0.379746835
##   0.1000000  0.0027821558  0.6173627  0.7453672  0.380537975
##   0.1000000  0.0043137765  0.6179181  0.7486687  0.378164557
##   0.1000000  0.0066885786  0.6187399  0.7536186  0.375000000
##   0.1000000  0.0103707466  0.6199046  0.7569190  0.369462025
##   0.1000000  0.0160800063  0.6213670  0.7629702  0.358386076
##   0.1000000  0.0249323034  0.6230785  0.7745220  0.344936709
##   0.1000000  0.0386579299  0.6256029  0.7904705  0.327531646
##   0.1000000  0.0599397303  0.6284281  0.8207145  0.294303797
##   0.1000000  0.0929374977  0.6303473  0.8548156  0.250791139
##   0.1473684  0.0004813674  0.6172548  0.7448177  0.379746835
##   0.1473684  0.0007463678  0.6172548  0.7448177  0.379746835
##   0.1473684  0.0011572550  0.6172548  0.7448177  0.379746835
##   0.1473684  0.0017943422  0.6172548  0.7448177  0.379746835
##   0.1473684  0.0027821558  0.6174915  0.7459166  0.378955696
##   0.1473684  0.0043137765  0.6181620  0.7486675  0.377373418
##   0.1473684  0.0066885786  0.6190846  0.7541681  0.372626582
##   0.1473684  0.0103707466  0.6203364  0.7591204  0.366297468
##   0.1473684  0.0160800063  0.6217919  0.7679213  0.354430380
##   0.1473684  0.0249323034  0.6241637  0.7789236  0.340189873
##   0.1473684  0.0386579299  0.6269768  0.7998124  0.318829114
##   0.1473684  0.0599397303  0.6292613  0.8328182  0.281645570
##   0.1473684  0.0929374977  0.6301376  0.8856175  0.210443038
##   0.1947368  0.0004813674  0.6172461  0.7448177  0.378955696
##   0.1947368  0.0007463678  0.6172461  0.7448177  0.378955696
##   0.1947368  0.0011572550  0.6172461  0.7448177  0.378955696
##   0.1947368  0.0017943422  0.6172461  0.7448177  0.378955696
##   0.1947368  0.0027821558  0.6176396  0.7492182  0.376582278
##   0.1947368  0.0043137765  0.6184301  0.7492158  0.375000000
##   0.1947368  0.0066885786  0.6193648  0.7552682  0.371044304
##   0.1947368  0.0103707466  0.6207594  0.7607712  0.364715190
##   0.1947368  0.0160800063  0.6225583  0.7706685  0.344936709
##   0.1947368  0.0249323034  0.6251474  0.7838699  0.330696203
##   0.1947368  0.0386579299  0.6279809  0.8108099  0.308544304
##   0.1947368  0.0599397303  0.6293224  0.8465665  0.263449367
##   0.1947368  0.0929374977  0.6296968  0.9076124  0.174841772
##   0.2421053  0.0004813674  0.6171904  0.7448177  0.378955696
##   0.2421053  0.0007463678  0.6171904  0.7448177  0.378955696
##   0.2421053  0.0011572550  0.6171904  0.7448177  0.378955696
##   0.2421053  0.0017943422  0.6171991  0.7448177  0.378955696
##   0.2421053  0.0027821558  0.6178225  0.7481169  0.377373418
##   0.2421053  0.0043137765  0.6186129  0.7497664  0.374208861
##   0.2421053  0.0066885786  0.6196677  0.7558201  0.369462025
##   0.2421053  0.0103707466  0.6213044  0.7640703  0.360759494
##   0.2421053  0.0160800063  0.6233264  0.7739701  0.342563291
##   0.2421053  0.0249323034  0.6262800  0.7893632  0.328322785
##   0.2421053  0.0386579299  0.6282382  0.8190662  0.297468354
##   0.2421053  0.0599397303  0.6293651  0.8641744  0.238924051
##   0.2421053  0.0929374977  0.6283591  0.9378588  0.137658228
##   0.2894737  0.0004813674  0.6171590  0.7453672  0.378164557
##   0.2894737  0.0007463678  0.6171590  0.7453672  0.378164557
##   0.2894737  0.0011572550  0.6171590  0.7453672  0.378164557
##   0.2894737  0.0017943422  0.6173314  0.7470155  0.378164557
##   0.2894737  0.0027821558  0.6180000  0.7481157  0.378164557
##   0.2894737  0.0043137765  0.6188026  0.7530680  0.371835443
##   0.2894737  0.0066885786  0.6200526  0.7569190  0.369462025
##   0.2894737  0.0103707466  0.6217433  0.7651704  0.359968354
##   0.2894737  0.0160800063  0.6241047  0.7761691  0.341772152
##   0.2894737  0.0249323034  0.6270985  0.7954132  0.321993671
##   0.2894737  0.0386579299  0.6285817  0.8300649  0.285601266
##   0.2894737  0.0599397303  0.6289960  0.8845198  0.208860759
##   0.2894737  0.0929374977  0.6268310  0.9587561  0.085443038
##   0.3368421  0.0004813674  0.6171416  0.7459166  0.378164557
##   0.3368421  0.0007463678  0.6171416  0.7459166  0.378164557
##   0.3368421  0.0011572550  0.6171416  0.7459166  0.378164557
##   0.3368421  0.0017943422  0.6174428  0.7475662  0.378164557
##   0.3368421  0.0027821558  0.6181689  0.7486651  0.375791139
##   0.3368421  0.0043137765  0.6190672  0.7536186  0.371044304
##   0.3368421  0.0066885786  0.6204809  0.7591216  0.368670886
##   0.3368421  0.0103707466  0.6221999  0.7668200  0.351265823
##   0.3368421  0.0160800063  0.6249841  0.7772692  0.340189873
##   0.3368421  0.0249323034  0.6274849  0.8014656  0.318037975
##   0.3368421  0.0386579299  0.6286214  0.8383151  0.280854430
##   0.3368421  0.0599397303  0.6282259  0.8982633  0.185917722
##   0.3368421  0.0929374977  0.6251316  0.9736034  0.067246835
##   0.3842105  0.0004813674  0.6171643  0.7459166  0.378164557
##   0.3842105  0.0007463678  0.6171643  0.7459166  0.378164557
##   0.3842105  0.0011572550  0.6171643  0.7459166  0.378164557
##   0.3842105  0.0017943422  0.6175821  0.7475662  0.376582278
##   0.3842105  0.0027821558  0.6182804  0.7492158  0.375000000
##   0.3842105  0.0043137765  0.6192760  0.7541681  0.371835443
##   0.3842105  0.0066885786  0.6207961  0.7613230  0.367088608
##   0.3842105  0.0103707466  0.6227345  0.7690190  0.349683544
##   0.3842105  0.0160800063  0.6256040  0.7805695  0.336234177
##   0.3842105  0.0249323034  0.6274501  0.8091664  0.308544304
##   0.3842105  0.0386579299  0.6285249  0.8487704  0.268987342
##   0.3842105  0.0599397303  0.6276600  0.9175134  0.161392405
##   0.3842105  0.0929374977  0.6218007  0.9862504  0.041930380
##   0.4315789  0.0004813674  0.6171800  0.7459166  0.378955696
##   0.4315789  0.0007463678  0.6171800  0.7459166  0.378955696
##   0.4315789  0.0011572550  0.6171817  0.7459166  0.378955696
##   0.4315789  0.0017943422  0.6176954  0.7481157  0.378164557
##   0.4315789  0.0027821558  0.6183919  0.7497664  0.375000000
##   0.4315789  0.0043137765  0.6195354  0.7547187  0.372626582
##   0.4315789  0.0066885786  0.6212052  0.7624219  0.363132911
##   0.4315789  0.0103707466  0.6232814  0.7712216  0.346518987
##   0.4315789  0.0160800063  0.6263606  0.7849664  0.333069620
##   0.4315789  0.0249323034  0.6277782  0.8141163  0.299841772
##   0.4315789  0.0386579299  0.6283804  0.8608740  0.250000000
##   0.4315789  0.0599397303  0.6268559  0.9312582  0.142405063
##   0.4315789  0.0929374977  0.6184823  0.9928499  0.018987342
##   0.4789474  0.0004813674  0.6171573  0.7459166  0.378164557
##   0.4789474  0.0007463678  0.6171573  0.7459166  0.378164557
##   0.4789474  0.0011572550  0.6172235  0.7459166  0.378955696
##   0.4789474  0.0017943422  0.6178172  0.7475650  0.378164557
##   0.4789474  0.0027821558  0.6184858  0.7497664  0.372626582
##   0.4789474  0.0043137765  0.6198036  0.7552694  0.370253165
##   0.4789474  0.0066885786  0.6215171  0.7635208  0.362341772
##   0.4789474  0.0103707466  0.6237517  0.7717699  0.345727848
##   0.4789474  0.0160800063  0.6267558  0.7888149  0.329905063
##   0.4789474  0.0249323034  0.6278702  0.8185167  0.296677215
##   0.4789474  0.0386579299  0.6284387  0.8696761  0.234968354
##   0.4789474  0.0599397303  0.6260274  0.9510541  0.106803797
##   0.4789474  0.0929374977  0.6140897  0.9988999  0.006329114
##   0.5263158  0.0004813674  0.6172183  0.7459166  0.378955696
##   0.5263158  0.0007463678  0.6172183  0.7459166  0.378955696
##   0.5263158  0.0011572550  0.6172896  0.7453648  0.378955696
##   0.5263158  0.0017943422  0.6179391  0.7481157  0.378164557
##   0.5263158  0.0027821558  0.6186476  0.7508665  0.373417722
##   0.5263158  0.0043137765  0.6200213  0.7558201  0.369462025
##   0.5263158  0.0066885786  0.6217994  0.7640703  0.357594937
##   0.5263158  0.0103707466  0.6243724  0.7723193  0.344145570
##   0.5263158  0.0160800063  0.6268898  0.7937648  0.329113924
##   0.5263158  0.0249323034  0.6278282  0.8267645  0.291139241
##   0.5263158  0.0386579299  0.6275962  0.8845186  0.213607595
##   0.5263158  0.0599397303  0.6248310  0.9626071  0.084651899
##   0.5263158  0.0929374977  0.6104873  0.9994505  0.001582278
##   0.5736842  0.0004813674  0.6172148  0.7459166  0.378955696
##   0.5736842  0.0007463678  0.6172148  0.7459166  0.378955696
##   0.5736842  0.0011572550  0.6173715  0.7464661  0.378164557
##   0.5736842  0.0017943422  0.6180157  0.7486651  0.376582278
##   0.5736842  0.0027821558  0.6188427  0.7525185  0.373417722
##   0.5736842  0.0043137765  0.6203242  0.7580215  0.369462025
##   0.5736842  0.0066885786  0.6221252  0.7651704  0.356803797
##   0.5736842  0.0103707466  0.6249714  0.7761691  0.339398734
##   0.5736842  0.0160800063  0.6269995  0.7976158  0.327531646
##   0.5736842  0.0249323034  0.6279668  0.8344677  0.284018987
##   0.5736842  0.0386579299  0.6272129  0.8927652  0.195411392
##   0.5736842  0.0599397303  0.6228357  0.9719562  0.071993671
##   0.5736842  0.0929374977  0.6032908  1.0000000  0.000000000
##   0.6210526  0.0004813674  0.6171904  0.7459166  0.378955696
##   0.6210526  0.0007463678  0.6171904  0.7459166  0.378955696
##   0.6210526  0.0011572550  0.6174272  0.7481157  0.378164557
##   0.6210526  0.0017943422  0.6181133  0.7492158  0.375000000
##   0.6210526  0.0027821558  0.6190533  0.7530692  0.373417722
##   0.6210526  0.0043137765  0.6205907  0.7596723  0.367088608
##   0.6210526  0.0066885786  0.6224979  0.7662705  0.356012658
##   0.6210526  0.0103707466  0.6254468  0.7772692  0.337816456
##   0.6210526  0.0160800063  0.6271223  0.8036670  0.316455696
##   0.6210526  0.0249323034  0.6278675  0.8399683  0.279272152
##   0.6210526  0.0386579299  0.6270267  0.9059617  0.183544304
##   0.6210526  0.0599397303  0.6208406  0.9785545  0.062500000
##   0.6210526  0.0929374977  0.5992801  1.0000000  0.000000000
##   0.6684211  0.0004813674  0.6171956  0.7459166  0.378955696
##   0.6684211  0.0007463678  0.6171956  0.7459166  0.378955696
##   0.6684211  0.0011572550  0.6174830  0.7481157  0.378164557
##   0.6684211  0.0017943422  0.6181585  0.7497664  0.375000000
##   0.6684211  0.0027821558  0.6192134  0.7530692  0.373417722
##   0.6684211  0.0043137765  0.6208727  0.7613218  0.366297468
##   0.6684211  0.0066885786  0.6228028  0.7679225  0.350474684
##   0.6684211  0.0103707466  0.6258037  0.7805683  0.337025316
##   0.6684211  0.0160800063  0.6272232  0.8080675  0.313291139
##   0.6684211  0.0249323034  0.6278273  0.8476715  0.268196203
##   0.6684211  0.0386579299  0.6262678  0.9169616  0.168512658
##   0.6684211  0.0599397303  0.6185798  0.9873517  0.041930380
##   0.6684211  0.0929374977  0.5949853  1.0000000  0.000000000
##   0.7157895  0.0004813674  0.6171677  0.7459166  0.378955696
##   0.7157895  0.0007463678  0.6171677  0.7459166  0.378955696
##   0.7157895  0.0011572550  0.6175979  0.7481157  0.378164557
##   0.7157895  0.0017943422  0.6182351  0.7497664  0.375000000
##   0.7157895  0.0027821558  0.6193997  0.7552694  0.373417722
##   0.7157895  0.0043137765  0.6210400  0.7607724  0.366297468
##   0.7157895  0.0066885786  0.6231615  0.7695708  0.348892405
##   0.7157895  0.0103707466  0.6261014  0.7805695  0.337025316
##   0.7157895  0.0160800063  0.6274007  0.8097183  0.310126582
##   0.7157895  0.0249323034  0.6277096  0.8559254  0.259493671
##   0.7157895  0.0386579299  0.6259433  0.9213656  0.154272152
##   0.7157895  0.0599397303  0.6165559  0.9912027  0.026107595
##   0.7157895  0.0929374977  0.5884356  1.0000000  0.000000000
##   0.7631579  0.0004813674  0.6171991  0.7453660  0.378955696
##   0.7631579  0.0007463678  0.6171938  0.7453660  0.378955696
##   0.7631579  0.0011572550  0.6176727  0.7475650  0.378164557
##   0.7631579  0.0017943422  0.6182874  0.7497664  0.375000000
##   0.7631579  0.0027821558  0.6195059  0.7558201  0.371835443
##   0.7631579  0.0043137765  0.6212838  0.7613218  0.365506329
##   0.7631579  0.0066885786  0.6235081  0.7701215  0.348101266
##   0.7631579  0.0103707466  0.6263746  0.7844157  0.336234177
##   0.7631579  0.0160800063  0.6273744  0.8130174  0.306962025
##   0.7631579  0.0249323034  0.6273354  0.8641780  0.250791139
##   0.7631579  0.0386579299  0.6256620  0.9362056  0.130537975
##   0.7631579  0.0599397303  0.6136544  0.9983492  0.011075949
##   0.7631579  0.0929374977  0.5549099  1.0000000  0.000000000
##   0.8105263  0.0004813674  0.6172339  0.7448153  0.378955696
##   0.8105263  0.0007463678  0.6172304  0.7448153  0.378955696
##   0.8105263  0.0011572550  0.6177562  0.7475650  0.378164557
##   0.8105263  0.0017943422  0.6184231  0.7503159  0.373417722
##   0.8105263  0.0027821558  0.6197357  0.7563707  0.370253165
##   0.8105263  0.0043137765  0.6214425  0.7618713  0.361550633
##   0.8105263  0.0066885786  0.6238808  0.7701203  0.346518987
##   0.8105263  0.0103707466  0.6265296  0.7871654  0.337025316
##   0.8105263  0.0160800063  0.6274002  0.8157671  0.303006329
##   0.8105263  0.0249323034  0.6270238  0.8691279  0.240506329
##   0.8105263  0.0386579299  0.6245023  0.9466513  0.118670886
##   0.8105263  0.0599397303  0.6107497  0.9994505  0.004746835
##   0.8105263  0.0929374977  0.5136841  1.0000000  0.000000000
##   0.8578947  0.0004813674  0.6172148  0.7448153  0.378955696
##   0.8578947  0.0007463678  0.6172461  0.7448153  0.378955696
##   0.8578947  0.0011572550  0.6177980  0.7475650  0.378164557
##   0.8578947  0.0017943422  0.6185206  0.7508665  0.373417722
##   0.8578947  0.0027821558  0.6199099  0.7563707  0.370253165
##   0.8578947  0.0043137765  0.6216898  0.7629702  0.359177215
##   0.8578947  0.0066885786  0.6243066  0.7717699  0.345727848
##   0.8578947  0.0103707466  0.6265627  0.7915658  0.335443038
##   0.8578947  0.0160800063  0.6273861  0.8218171  0.297468354
##   0.8578947  0.0249323034  0.6269001  0.8768238  0.225474684
##   0.8578947  0.0386579299  0.6235774  0.9571053  0.097310127
##   0.8578947  0.0599397303  0.6095756  0.9994505  0.001582278
##   0.8578947  0.0929374977  0.5136841  1.0000000  0.000000000
##   0.9052632  0.0004813674  0.6171904  0.7448153  0.378955696
##   0.9052632  0.0007463678  0.6173070  0.7453648  0.378955696
##   0.9052632  0.0011572550  0.6178729  0.7475650  0.377373418
##   0.9052632  0.0017943422  0.6186459  0.7508665  0.373417722
##   0.9052632  0.0027821558  0.6201432  0.7574720  0.370253165
##   0.9052632  0.0043137765  0.6218727  0.7635196  0.359177215
##   0.9052632  0.0066885786  0.6246478  0.7739701  0.344145570
##   0.9052632  0.0103707466  0.6266847  0.7943143  0.333860759
##   0.9052632  0.0160800063  0.6274503  0.8267670  0.292721519
##   0.9052632  0.0249323034  0.6268190  0.8790192  0.219936709
##   0.9052632  0.0386579299  0.6217859  0.9637036  0.082278481
##   0.9052632  0.0599397303  0.6030369  1.0000000  0.000000000
##   0.9052632  0.0929374977  0.5000000  1.0000000  0.000000000
##   0.9526316  0.0004813674  0.6171834  0.7448153  0.378955696
##   0.9526316  0.0007463678  0.6173436  0.7470155  0.379746835
##   0.9526316  0.0011572550  0.6179130  0.7486651  0.376582278
##   0.9526316  0.0017943422  0.6187835  0.7508665  0.374208861
##   0.9526316  0.0027821558  0.6203539  0.7585722  0.369462025
##   0.9526316  0.0043137765  0.6221967  0.7640703  0.357594937
##   0.9526316  0.0066885786  0.6250290  0.7750678  0.340981013
##   0.9526316  0.0103707466  0.6267553  0.7965157  0.332278481
##   0.9526316  0.0160800063  0.6275387  0.8317193  0.288765823
##   0.9526316  0.0249323034  0.6265755  0.8911132  0.206487342
##   0.9526316  0.0386579299  0.6208159  0.9708549  0.075158228
##   0.9526316  0.0599397303  0.6001691  1.0000000  0.000000000
##   0.9526316  0.0929374977  0.5000000  1.0000000  0.000000000
##   1.0000000  0.0004813674  0.6171643  0.7448153  0.378955696
##   1.0000000  0.0007463678  0.6173697  0.7470155  0.378955696
##   1.0000000  0.0011572550  0.6179653  0.7492158  0.375000000
##   1.0000000  0.0017943422  0.6188252  0.7514172  0.374208861
##   1.0000000  0.0027821558  0.6204167  0.7591216  0.367879747
##   1.0000000  0.0043137765  0.6224493  0.7646210  0.356803797
##   1.0000000  0.0066885786  0.6252484  0.7750690  0.339398734
##   1.0000000  0.0103707466  0.6268126  0.7976170  0.327531646
##   1.0000000  0.0160800063  0.6274428  0.8361209  0.283227848
##   1.0000000  0.0249323034  0.6261732  0.8999092  0.192246835
##   1.0000000  0.0386579299  0.6198205  0.9741540  0.071202532
##   1.0000000  0.0599397303  0.5980941  1.0000000  0.000000000
##   1.0000000  0.0929374977  0.5000000  1.0000000  0.000000000
## 
## ROC was used to select the optimal model using the largest value.
## The final values used for the model were alpha = 0.1 and lambda = 0.0929375.
##  alpha       lambda         ROC         Sens        Spec         
##  "0.1000000" "0.0004813674" "0.6172949" "0.7448177" "0.379746835"
##  "0.1000000" "0.0007463678" "0.6172949" "0.7448177" "0.379746835"
##  "0.1000000" "0.0011572550" "0.6172949" "0.7448177" "0.379746835"
##  "0.1000000" "0.0017943422" "0.6172949" "0.7448177" "0.379746835"
##  "0.1000000" "0.0027821558" "0.6173627" "0.7453672" "0.380537975"
##  "0.1000000" "0.0043137765" "0.6179181" "0.7486687" "0.378164557"
predictions_gl <- predict(glfit, testing)
confusionMatrix(predictions_gl, testing$Gender)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction female male
##     female    203  127
##     male       24   30
##                                           
##                Accuracy : 0.6068          
##                  95% CI : (0.5559, 0.6559)
##     No Information Rate : 0.5911          
##     P-Value [Acc > NIR] : 0.2848          
##                                           
##                   Kappa : 0.095           
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.8943          
##             Specificity : 0.1911          
##          Pos Pred Value : 0.6152          
##          Neg Pred Value : 0.5556          
##              Prevalence : 0.5911          
##          Detection Rate : 0.5286          
##    Detection Prevalence : 0.8594          
##       Balanced Accuracy : 0.5427          
##                                           
##        'Positive' Class : female          
## 
plot(varImp(rffit, scale = FALSE), top = 10, 
     main = "Variable Importance for rffit")

plot(varImp(glfit, scale = FALSE), top = 10, main = "Variable Importance for glfit")

model_list <- list(glmnet = glfit, randomForest = rffit)
resamples <- resamples(model_list)
summary(resamples)
## 
## Call:
## summary.resamples(object = resamples)
## 
## Models: glmnet, randomForest 
## Number of resamples: 4 
## 
## ROC 
##                   Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## glmnet       0.6172486 0.6264811 0.6318053 0.6303473 0.6356715 0.6405300    0
## randomForest 0.6393032 0.6431736 0.6466478 0.6481700 0.6516442 0.6600814    0
## 
## Sens 
##                   Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## glmnet       0.8109890 0.8357143 0.8570000 0.8548156 0.8761013 0.8942731    0
## randomForest 0.8131868 0.8178341 0.8248899 0.8239834 0.8310391 0.8329670    0
## 
## Spec 
##                   Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## glmnet       0.2151899 0.2270570 0.2452532 0.2507911 0.2689873 0.2974684    0
## randomForest 0.3164557 0.3330696 0.3465190 0.3433544 0.3568038 0.3639241    0
cm_rf <- confusionMatrix(predictions_rf, testing$Gender)
print(cm_rf)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction female male
##     female    183   94
##     male       44   63
##                                           
##                Accuracy : 0.6406          
##                  95% CI : (0.5904, 0.6887)
##     No Information Rate : 0.5911          
##     P-Value [Acc > NIR] : 0.0268          
##                                           
##                   Kappa : 0.2182          
##                                           
##  Mcnemar's Test P-Value : 3.031e-05       
##                                           
##             Sensitivity : 0.8062          
##             Specificity : 0.4013          
##          Pos Pred Value : 0.6606          
##          Neg Pred Value : 0.5888          
##              Prevalence : 0.5911          
##          Detection Rate : 0.4766          
##    Detection Prevalence : 0.7214          
##       Balanced Accuracy : 0.6037          
##                                           
##        'Positive' Class : female          
## 
cm_gl <- confusionMatrix(predictions_gl, testing$Gender)
print(cm_gl)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction female male
##     female    203  127
##     male       24   30
##                                           
##                Accuracy : 0.6068          
##                  95% CI : (0.5559, 0.6559)
##     No Information Rate : 0.5911          
##     P-Value [Acc > NIR] : 0.2848          
##                                           
##                   Kappa : 0.095           
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.8943          
##             Specificity : 0.1911          
##          Pos Pred Value : 0.6152          
##          Neg Pred Value : 0.5556          
##              Prevalence : 0.5911          
##          Detection Rate : 0.5286          
##    Detection Prevalence : 0.8594          
##       Balanced Accuracy : 0.5427          
##                                           
##        'Positive' Class : female          
##