rm(list=ls())
for(model in c(paste0("model",c(6:33,35,36)))){
  print(model)


pred <- read.csv(paste0("C:/Users/gerhard/Documents/hpc-mini/chamber_gain_corrected/",model,"_results.csv"),header=F)
act <- read.csv(paste0("C:/Users/gerhard/Documents/hpc-mini/chamber_gain_corrected/model24_y_test.csv"),header=F)

names(pred) <- "pred"
names(act) <- "act"

pred_act <- data.frame(cbind(pred,act))

six_tracklet_pred <- c()

for(i in seq(1,nrow(pred),6)){
  j=i+5
  
  this.dat <- prod(pred[i:j,])/sum(prod(pred[i:j,]),prod(1-pred[i:j,]))
  six_tracklet_pred <- c(six_tracklet_pred,this.dat)
}

six_tracklet_pred <- data.frame(six_tracklet_pred)

six_tracklet_pred <- na.omit(six_tracklet_pred)

six_tracklet_real <- c()

for(i in seq(1,nrow(act),6)){
  this.dat <- act[i,]
  six_tracklet_real <- c(six_tracklet_real,this.dat)
  
}

six_tracklet_real <- data.frame(six_tracklet_real)

which(is.na(six_tracklet_real))

pred_act <- data.frame(cbind(six_tracklet_pred,six_tracklet_real))

elec_pi_eff_func <- function(model_1.preds,model_1.labels){
  
    # model_1.preds <- read.csv(model_1.preds,header=F, sep="")
    # 
    # model_1.labels <- read.csv(model_1.labels,header=F, sep="")
    
    model_1 <- data.frame(cbind(model_1.preds,model_1.labels))
    
    model_1.electrons <- which(model_1[,2]==1)
    
    electrons <- model_1[model_1.electrons,]
    
    pions <- model_1[-as.numeric(model_1.electrons),]
    
    electrons <- data.frame(electrons)
    
    names(electrons) <- c("prediction","label")
    
    pions <- data.frame(pions)
    
    names(pions) <- c("prediction","label")
    
    electron_efficiency <- function(electrons.,par){
  
    electrons <- electrons.
    
    electrons$electron_pred <- ifelse(electrons$prediction>=par[1],1,0)
    
    correct <- ifelse(electrons$electron_pred==electrons$label,1,0)
    
    error_metric <- sum(correct)/nrow(electrons)
    
    error_metric <- (error_metric-0.9)^2
    
    return(error_metric)
  
}

  res <- optim(par=c(0),fn=electron_efficiency,lower = 0,upper = 1,electrons.=electrons,method="Brent")
  
  require(ggplot2)
  
  g <- ggplot(pred_act,aes(pred_act[,1],colour=factor(pred_act[,2])))+geom_histogram(bins = 1000)+facet_wrap(factor(pred_act[,2]))
  print(g)
  
  hist(pred_act[,1],breaks=1000)
  abline(v=res$par,col="red")
  
  electrons$predicted_label <- ifelse(electrons$prediction>=res$par,1,0)
  
  print(paste0("Electron Efficiency: ",sum(electrons$predicted_label)/nrow(electrons)))
  
  pions$predicted_label <- ifelse(pions$prediction>=res$par,1,0)
  
  pions$misclassified_as_electron <- ifelse(pions$predicted_label==1,1,0)
  
  print(paste0("Pion Efficiency: ",sum(pions$misclassified_as_electron)/nrow(pions)))
  
  pred_act$final_pred <- ifelse(pred_act[,1]>=res$par,1,0)
  
  require(caret)
  
  print(caret::confusionMatrix(data=factor(pred_act$final_pred),reference = factor(pred_act[,2])))
  
  
}

elec_pi_eff_func(pred_act[,1],pred_act[,2])

}
## [1] "model6"
## Loading required package: ggplot2
## Registered S3 methods overwritten by 'ggplot2':
##   method         from 
##   [.quosures     rlang
##   c.quosures     rlang
##   print.quosures rlang

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.255432227468776"
## Loading required package: caret
## Loading required package: lattice

## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 36425  4892
##          1 12496 44029
##                                           
##                Accuracy : 0.8223          
##                  95% CI : (0.8199, 0.8247)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.6446          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.7446          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8816          
##          Neg Pred Value : 0.7789          
##              Prevalence : 0.5000          
##          Detection Rate : 0.3723          
##    Detection Prevalence : 0.4223          
##       Balanced Accuracy : 0.8223          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model7"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.157744118067905"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 41204  4892
##          1  7717 44029
##                                          
##                Accuracy : 0.8711         
##                  95% CI : (0.869, 0.8732)
##     No Information Rate : 0.5            
##     P-Value [Acc > NIR] : < 2.2e-16      
##                                          
##                   Kappa : 0.7423         
##                                          
##  Mcnemar's Test P-Value : < 2.2e-16      
##                                          
##             Sensitivity : 0.8423         
##             Specificity : 0.9000         
##          Pos Pred Value : 0.8939         
##          Neg Pred Value : 0.8509         
##              Prevalence : 0.5000         
##          Detection Rate : 0.4211         
##    Detection Prevalence : 0.4711         
##       Balanced Accuracy : 0.8711         
##                                          
##        'Positive' Class : 0              
##                                          
## [1] "model8"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.16375380715848"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 40910  4892
##          1  8011 44029
##                                          
##                Accuracy : 0.8681         
##                  95% CI : (0.866, 0.8702)
##     No Information Rate : 0.5            
##     P-Value [Acc > NIR] : < 2.2e-16      
##                                          
##                   Kappa : 0.7362         
##                                          
##  Mcnemar's Test P-Value : < 2.2e-16      
##                                          
##             Sensitivity : 0.8362         
##             Specificity : 0.9000         
##          Pos Pred Value : 0.8932         
##          Neg Pred Value : 0.8461         
##              Prevalence : 0.5000         
##          Detection Rate : 0.4181         
##    Detection Prevalence : 0.4681         
##       Balanced Accuracy : 0.8681         
##                                          
##        'Positive' Class : 0              
##                                          
## [1] "model9"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.133541832750761"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 42388  4892
##          1  6533 44029
##                                           
##                Accuracy : 0.8832          
##                  95% CI : (0.8812, 0.8852)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.7665          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.8665          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8965          
##          Neg Pred Value : 0.8708          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4332          
##    Detection Prevalence : 0.4832          
##       Balanced Accuracy : 0.8832          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model10"

## [1] "Electron Efficiency: 0.899940720753868"
## [1] "Pion Efficiency: 0.112323950859549"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 43426  4895
##          1  5495 44026
##                                           
##                Accuracy : 0.8938          
##                  95% CI : (0.8919, 0.8957)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.7876          
##                                           
##  Mcnemar's Test P-Value : 4.19e-09        
##                                           
##             Sensitivity : 0.8877          
##             Specificity : 0.8999          
##          Pos Pred Value : 0.8987          
##          Neg Pred Value : 0.8890          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4438          
##    Detection Prevalence : 0.4939          
##       Balanced Accuracy : 0.8938          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model11"

## [1] "Electron Efficiency: 0.900083808589358"
## [1] "Pion Efficiency: 0.0856074078616545"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 44733  4888
##          1  4188 44033
##                                          
##                Accuracy : 0.9072         
##                  95% CI : (0.9054, 0.909)
##     No Information Rate : 0.5            
##     P-Value [Acc > NIR] : < 2.2e-16      
##                                          
##                   Kappa : 0.8145         
##                                          
##  Mcnemar's Test P-Value : 2.181e-13      
##                                          
##             Sensitivity : 0.9144         
##             Specificity : 0.9001         
##          Pos Pred Value : 0.9015         
##          Neg Pred Value : 0.9131         
##              Prevalence : 0.5000         
##          Detection Rate : 0.4572         
##    Detection Prevalence : 0.5072         
##       Balanced Accuracy : 0.9072         
##                                          
##        'Positive' Class : 0              
##                                          
## [1] "model12"

## [1] "Electron Efficiency: 0.899818074037734"
## [1] "Pion Efficiency: 0.41783692074978"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 28480  4901
##          1 20441 44020
##                                           
##                Accuracy : 0.741           
##                  95% CI : (0.7382, 0.7437)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.482           
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.5822          
##             Specificity : 0.8998          
##          Pos Pred Value : 0.8532          
##          Neg Pred Value : 0.6829          
##              Prevalence : 0.5000          
##          Detection Rate : 0.2911          
##    Detection Prevalence : 0.3412          
##       Balanced Accuracy : 0.7410          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model13"

## [1] "Electron Efficiency: 0.899940720753868"
## [1] "Pion Efficiency: 0.100345454917111"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 44012  4895
##          1  4909 44026
##                                           
##                Accuracy : 0.8998          
##                  95% CI : (0.8979, 0.9017)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.7996          
##                                           
##  Mcnemar's Test P-Value : 0.8955          
##                                           
##             Sensitivity : 0.8997          
##             Specificity : 0.8999          
##          Pos Pred Value : 0.8999          
##          Neg Pred Value : 0.8997          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4498          
##    Detection Prevalence : 0.4999          
##       Balanced Accuracy : 0.8998          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model14"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.488501870362421"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 25023  4892
##          1 23898 44029
##                                           
##                Accuracy : 0.7058          
##                  95% CI : (0.7029, 0.7086)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.4115          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.5115          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8365          
##          Neg Pred Value : 0.6482          
##              Prevalence : 0.5000          
##          Detection Rate : 0.2557          
##    Detection Prevalence : 0.3057          
##       Balanced Accuracy : 0.7058          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model15"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.474111322336011"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 25727  4892
##          1 23194 44029
##                                           
##                Accuracy : 0.7129          
##                  95% CI : (0.7101, 0.7158)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.4259          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.5259          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8402          
##          Neg Pred Value : 0.6550          
##              Prevalence : 0.5000          
##          Detection Rate : 0.2629          
##    Detection Prevalence : 0.3129          
##       Balanced Accuracy : 0.7129          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model16"

## [1] "Electron Efficiency: 0.89998160299258"
## [1] "Pion Efficiency: 0.462991353406513"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 26271  4893
##          1 22650 44028
##                                           
##                Accuracy : 0.7185          
##                  95% CI : (0.7157, 0.7213)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.437           
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.5370          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8430          
##          Neg Pred Value : 0.6603          
##              Prevalence : 0.5000          
##          Detection Rate : 0.2685          
##    Detection Prevalence : 0.3185          
##       Balanced Accuracy : 0.7185          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model17"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.473804705545676"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 25742  4892
##          1 23179 44029
##                                           
##                Accuracy : 0.7131          
##                  95% CI : (0.7103, 0.7159)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.4262          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.5262          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8403          
##          Neg Pred Value : 0.6551          
##              Prevalence : 0.5000          
##          Detection Rate : 0.2631          
##    Detection Prevalence : 0.3131          
##       Balanced Accuracy : 0.7131          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model18"

## [1] "Electron Efficiency: 0.899961161873224"
## [1] "Pion Efficiency: 0.44220273502177"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 27288  4894
##          1 21633 44027
##                                           
##                Accuracy : 0.7289          
##                  95% CI : (0.7261, 0.7317)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.4578          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.5578          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8479          
##          Neg Pred Value : 0.6705          
##              Prevalence : 0.5000          
##          Detection Rate : 0.2789          
##    Detection Prevalence : 0.3289          
##       Balanced Accuracy : 0.7289          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model19"

## [1] "Electron Efficiency: 0.89998160299258"
## [1] "Pion Efficiency: 0.319085873142413"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 33311  4893
##          1 15610 44028
##                                          
##                Accuracy : 0.7904         
##                  95% CI : (0.7879, 0.793)
##     No Information Rate : 0.5            
##     P-Value [Acc > NIR] : < 2.2e-16      
##                                          
##                   Kappa : 0.5809         
##                                          
##  Mcnemar's Test P-Value : < 2.2e-16      
##                                          
##             Sensitivity : 0.6809         
##             Specificity : 0.9000         
##          Pos Pred Value : 0.8719         
##          Neg Pred Value : 0.7383         
##              Prevalence : 0.5000         
##          Detection Rate : 0.3405         
##    Detection Prevalence : 0.3905         
##       Balanced Accuracy : 0.7904         
##                                          
##        'Positive' Class : 0              
##                                          
## [1] "model20"

## [1] "Electron Efficiency: 0.900022485231291"
## [1] "Pion Efficiency: 0.400461969297439"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 29330  4891
##          1 19591 44030
##                                           
##                Accuracy : 0.7498          
##                  95% CI : (0.7471, 0.7525)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.4996          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.5995          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8571          
##          Neg Pred Value : 0.6921          
##              Prevalence : 0.5000          
##          Detection Rate : 0.2998          
##    Detection Prevalence : 0.3498          
##       Balanced Accuracy : 0.7498          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model21"

## [1] "Electron Efficiency: 0.900063367470003"
## [1] "Pion Efficiency: 0.086915639500419"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 44669  4889
##          1  4252 44032
##                                           
##                Accuracy : 0.9066          
##                  95% CI : (0.9047, 0.9084)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.8131          
##                                           
##  Mcnemar's Test P-Value : 2.889e-11       
##                                           
##             Sensitivity : 0.9131          
##             Specificity : 0.9001          
##          Pos Pred Value : 0.9013          
##          Neg Pred Value : 0.9119          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4565          
##    Detection Prevalence : 0.5065          
##       Balanced Accuracy : 0.9066          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model22"

## [1] "Electron Efficiency: 0.900063367470003"
## [1] "Pion Efficiency: 0.057071605241103"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 46129  4889
##          1  2792 44032
##                                           
##                Accuracy : 0.9215          
##                  95% CI : (0.9198, 0.9232)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.843           
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.9429          
##             Specificity : 0.9001          
##          Pos Pred Value : 0.9042          
##          Neg Pred Value : 0.9404          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4715          
##    Detection Prevalence : 0.5214          
##       Balanced Accuracy : 0.9215          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model23"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.0645530549252877"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 45763  4892
##          1  3158 44029
##                                          
##                Accuracy : 0.9177         
##                  95% CI : (0.916, 0.9194)
##     No Information Rate : 0.5            
##     P-Value [Acc > NIR] : < 2.2e-16      
##                                          
##                   Kappa : 0.8354         
##                                          
##  Mcnemar's Test P-Value : < 2.2e-16      
##                                          
##             Sensitivity : 0.9354         
##             Specificity : 0.9000         
##          Pos Pred Value : 0.9034         
##          Neg Pred Value : 0.9331         
##              Prevalence : 0.5000         
##          Detection Rate : 0.4677         
##    Detection Prevalence : 0.5177         
##       Balanced Accuracy : 0.9177         
##                                          
##        'Positive' Class : 0              
##                                          
## [1] "model24"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.241143885039145"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 37124  4892
##          1 11797 44029
##                                           
##                Accuracy : 0.8294          
##                  95% CI : (0.8271, 0.8318)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.6589          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.7589          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8836          
##          Neg Pred Value : 0.7887          
##              Prevalence : 0.5000          
##          Detection Rate : 0.3794          
##    Detection Prevalence : 0.4294          
##       Balanced Accuracy : 0.8294          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model25"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.0451135504180209"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 46714  4892
##          1  2207 44029
##                                           
##                Accuracy : 0.9274          
##                  95% CI : (0.9258, 0.9291)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.8549          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.9549          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.9052          
##          Neg Pred Value : 0.9523          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4774          
##    Detection Prevalence : 0.5274          
##       Balanced Accuracy : 0.9274          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model26"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.0454814905664234"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 46696  4892
##          1  2225 44029
##                                           
##                Accuracy : 0.9273          
##                  95% CI : (0.9256, 0.9289)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.8545          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.9545          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.9052          
##          Neg Pred Value : 0.9519          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4773          
##    Detection Prevalence : 0.5273          
##       Balanced Accuracy : 0.9273          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model27"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.172707017436275"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 40472  4892
##          1  8449 44029
##                                           
##                Accuracy : 0.8636          
##                  95% CI : (0.8615, 0.8658)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.7273          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.8273          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8922          
##          Neg Pred Value : 0.8390          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4136          
##    Detection Prevalence : 0.4636          
##       Balanced Accuracy : 0.8636          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model28"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.0583185135218005"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 46068  4892
##          1  2853 44029
##                                           
##                Accuracy : 0.9208          
##                  95% CI : (0.9191, 0.9225)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.8417          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.9417          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.9040          
##          Neg Pred Value : 0.9391          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4708          
##    Detection Prevalence : 0.5208          
##       Balanced Accuracy : 0.9208          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model29"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.0592179227734511"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 46024  4892
##          1  2897 44029
##                                           
##                Accuracy : 0.9204          
##                  95% CI : (0.9187, 0.9221)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.8408          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.9408          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.9039          
##          Neg Pred Value : 0.9383          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4704          
##    Detection Prevalence : 0.5204          
##       Balanced Accuracy : 0.9204          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model30"

## [1] "Electron Efficiency: 0.900022485231291"
## [1] "Pion Efficiency: 0.0530855869667423"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 46324  4891
##          1  2597 44030
##                                           
##                Accuracy : 0.9235          
##                  95% CI : (0.9218, 0.9251)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.8469          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.9469          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.9045          
##          Neg Pred Value : 0.9443          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4735          
##    Detection Prevalence : 0.5234          
##       Balanced Accuracy : 0.9235          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model31"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.105578381472169"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 43756  4892
##          1  5165 44029
##                                           
##                Accuracy : 0.8972          
##                  95% CI : (0.8953, 0.8991)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.7944          
##                                           
##  Mcnemar's Test P-Value : 0.006682        
##                                           
##             Sensitivity : 0.8944          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8994          
##          Neg Pred Value : 0.8950          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4472          
##    Detection Prevalence : 0.4972          
##       Balanced Accuracy : 0.8972          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model32"

## [1] "Electron Efficiency: 0.899940720753868"
## [1] "Pion Efficiency: 0.104965147891499"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 43786  4895
##          1  5135 44026
##                                           
##                Accuracy : 0.8975          
##                  95% CI : (0.8956, 0.8994)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2e-16         
##                                           
##                   Kappa : 0.795           
##                                           
##  Mcnemar's Test P-Value : 0.01701         
##                                           
##             Sensitivity : 0.8950          
##             Specificity : 0.8999          
##          Pos Pred Value : 0.8994          
##          Neg Pred Value : 0.8955          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4475          
##    Detection Prevalence : 0.4975          
##       Balanced Accuracy : 0.8975          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model33"

## [1] "Electron Efficiency: 0.900002044111936"
## [1] "Pion Efficiency: 0.0855869667422988"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 44734  4892
##          1  4187 44029
##                                          
##                Accuracy : 0.9072         
##                  95% CI : (0.9054, 0.909)
##     No Information Rate : 0.5            
##     P-Value [Acc > NIR] : < 2.2e-16      
##                                          
##                   Kappa : 0.8144         
##                                          
##  Mcnemar's Test P-Value : 1.485e-13      
##                                          
##             Sensitivity : 0.9144         
##             Specificity : 0.9000         
##          Pos Pred Value : 0.9014         
##          Neg Pred Value : 0.9132         
##              Prevalence : 0.5000         
##          Detection Rate : 0.4572         
##    Detection Prevalence : 0.5072         
##       Balanced Accuracy : 0.9072         
##                                          
##        'Positive' Class : 0              
##                                          
## [1] "model35"

## [1] "Electron Efficiency: 0.900042926350647"
## [1] "Pion Efficiency: 0.0892254859876127"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 44556  4890
##          1  4365 44031
##                                           
##                Accuracy : 0.9054          
##                  95% CI : (0.9036, 0.9072)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.8108          
##                                           
##  Mcnemar's Test P-Value : 5.128e-08       
##                                           
##             Sensitivity : 0.9108          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.9011          
##          Neg Pred Value : 0.9098          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4554          
##    Detection Prevalence : 0.5054          
##       Balanced Accuracy : 0.9054          
##                                           
##        'Positive' Class : 0               
##                                           
## [1] "model36"

## [1] "Electron Efficiency: 0.899961161873224"
## [1] "Pion Efficiency: 0.096461642239529"
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0 44202  4894
##          1  4719 44027
##                                           
##                Accuracy : 0.9017          
##                  95% CI : (0.8999, 0.9036)
##     No Information Rate : 0.5             
##     P-Value [Acc > NIR] : < 2e-16         
##                                           
##                   Kappa : 0.8035          
##                                           
##  Mcnemar's Test P-Value : 0.07595         
##                                           
##             Sensitivity : 0.9035          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.9003          
##          Neg Pred Value : 0.9032          
##              Prevalence : 0.5000          
##          Detection Rate : 0.4518          
##    Detection Prevalence : 0.5018          
##       Balanced Accuracy : 0.9017          
##                                           
##        'Positive' Class : 0               
##