Im using Base R to test this model:
probabilities <- predict(theModel, newdata = dataToModel2 , type = "response")   
dataToModel2$predictions <- ifelse(probabilities >= .5, "True", "False")
and then when I try to test for accuracy using this code:
 accuracy <- sum(dataToModel2$predictions == dataToModel2$incomeNum)/dim(dataToModel2)[1]
I get a 0 rather than a number depicting how accurate my model is. Why is this and how do you fix such an error?
I hope this can help. Data for the original model:
dataToModel <- structure(
  list(
    sex = c("Male", "Male", "Male", "Male", "Female"),
    marital.status = c("Never-married", "married", "pMarried",
                       "married", "married"),
    race = c("White", "White", "White", "Black",
             "Black"),
    education = c(
      "University",
      "University",
      "less-than-Uni",
      "less-than-Uni",
      "University"
    ),
    incomeNum = c(FALSE, FALSE, FALSE,
                  FALSE, FALSE)
  ),
  row.names = c(NA, 5L),
  class = "data.frame"
)
And data for predictions:
dataToModel2 <- structure(
  list(
    sex = c("Male", "Male", "Male", "Male", "Male"),
    marital.status = c(
      "Never-married",
      "married",
      "married",
      "married",
      "Never-married"
    ),
    race = c("Black", "White", "White",
             "Black", "White"),
    education = c(
      "less-than-Uni",
      "less-than-Uni",
      "University",
      "less-than-Uni",
      "less-than-Uni"
    ),
    incomeNum = c(FALSE,
                  FALSE, FALSE, FALSE, FALSE),
    predictions = c("False", "False",
                    "True", "False", "False")
  ),
  row.names = c(1L, 2L, 3L, 4L, 6L),
  class = "data.frame"
)
 
     
    