title: R: Number of classes is not equal to 2
body: <p>I am getting the following error when trying to generate a lift chart for a random forest model being run through rattle:</p>
  
  <p>Error in prediction(crs$pr, no.miss) : 
    Number of classes is not equal to 2.
  ROCR currently supports only evaluation of binary classification tasks.</p>
  
  <p>My code is as follows:
      # Evaluate model performance. </p>
  
  <pre><code># Lift Chart: requires the ROCR package.
  
  library(ROCR)
  
  # Obtain predictions for the rf model on TBA_jul21c.csv [**train**].
  
  crs$pr &lt;- predict(crs$rf, newdata=na.omit(crs$dataset[crs$sample,    c(crs$input, crs$target)]), type="prob")[,2]
  
  # Remove observations with missing target.
  
  no.miss   &lt;- na.omit(na.omit(crs$dataset[crs$sample, c(crs$input,   crs$target)])$targetvar)
  miss.list &lt;- attr(no.miss, "na.action")
  attributes(no.miss) &lt;- NULL
  
  if (length(miss.list))
  {
   pred &lt;- prediction(crs$pr[-miss.list], no.miss)
  } else
  {
    pred &lt;- prediction(crs$pr, no.miss)
  }
  
  # Convert rate of positive predictions to percentage.
  
  per &lt;- performance(pred, "lift", "rpp")
  per@x.values[[1]] &lt;- per@x.values[[1]]*100
  
  # Plot the lift chart.
  plot(per, col="#CC0000FF", lty=1, xlab="Caseload (%)", add=FALSE)
  </code></pre>
  
  <p>My dataset is has 127 variables including a target variable with Y/N labels. I am reading the dataset in as follows:</p>
  
  <pre><code>crs$dataset &lt;- read.csv("file:///C:/MastersC/TBA_jul21c.csv",    na.strings=c(".", "NA", "", "?"), strip.white=TRUE, encoding="UTF-8")
  
  #============================================================
  # Rattle timestamp: 2015-07-22 08:36:53 x86_64-w64-mingw32 
  
  # Note the user selections. 
  
  # Build the training/validate/test datasets.
  
  set.seed(crv$seed) 
  crs$nobs &lt;- nrow(crs$dataset) # 72824 observations 
  crs$sample &lt;- crs$train &lt;- sample(nrow(crs$dataset), 0.7*crs$nobs) # 50976   observations
  crs$validate &lt;- sample(setdiff(seq_len(nrow(crs$dataset)), crs$train),   0.15*crs$nobs) # 10923 observations
  crs$test &lt;- setdiff(setdiff(seq_len(nrow(crs$dataset)), crs$train),     crs$validate) # 10925 observations
  </code></pre>
  
  <p>I think it has something to do with the target variable but I am not sure. Any help would be greatly appreciated as I have been stuck on this for a number of hours. By the by this is my first stackoverflow post so feel free to chastise me if I am not posting correctly.
  Many thanks</p>