title: Manual Summary Function in Caret - Make all predictions = Fail
body: <p>I am having some issues in understanding how the manual summary function in Caret works. I have created a simple code to maximize all predictions as "fail". But for some reason it doesn't seem to predict all instances as fail (on the training dataset).</p>
  
  <p>See below for the code:</p>
  
  <p>Maximize all predictions as fail function:</p>
  
  <pre><code>BS &lt;- function (data, lev = NULL, model = NULL) {
     negpredictions  &lt;- sum(data$pred == "fail")
     names(negpredictions) &lt;- c("Min_Precision")
     negpredictions
   } 
  </code></pre>
  
  <p>Training Script:</p>
  
  <pre><code> train.control &lt;- trainControl(method = "repeatedcv",
                            number = 10,
                            repeats = 3,
                            classProbs = TRUE,
                            #sampling = "smote",
                            summaryFunction = BS,
                            search = "grid")
  
  
   tune.grid &lt;- expand.grid(.mtry = seq(from = 1, to = 10, by = 1))
  
  
   cl &lt;- makeCluster(3, type = "SOCK")
   registerDoSNOW(cl)
   random.forest.orig &lt;- train(pass ~ manufacturer+meter.type+premise+size+age+avg.winter+totalizer, 
                   data = meter.train,
                   method = "rf",
                   tuneGrid = tune.grid,
                   metric = "Min_Precision",
                   maximize = TRUE,
                   trControl = train.control)
    stopCluster(cl)
  </code></pre>