A classifier often turns probabilities into labels by comparing each score with a cutoff.

Program

Play the script to change the cutoff and see how many records are classified as yes.

cutoff
classification_threshold.R
Replay: real traced execution (multi-file project)
cutoff <- 0.6
prob <- c(0.20, 0.65, 0.80, 0.55)
predicted <- ifelse(prob >= cutoff, "yes", "no")
yes_count <- sum(predicted == "yes")
label <- paste("yes", yes_count, sep = ":")
cat(label, "\n", sep = "")
cutoff <- 0.5
prob <- c(0.20, 0.65, 0.80, 0.55)
predicted <- ifelse(prob >= cutoff, "yes", "no")
yes_count <- sum(predicted == "yes")
label <- paste("yes", yes_count, sep = ":")
cat(label, "\n", sep = "")
cutoff <- 0.7
prob <- c(0.20, 0.65, 0.80, 0.55)
predicted <- ifelse(prob >= cutoff, "yes", "no")
yes_count <- sum(predicted == "yes")
label <- paste("yes", yes_count, sep = ":")
cat(label, "\n", sep = "")
  1. cutoff ← 0.6

    1cutoff <- 0.62prob <- c(0.20, 0.65, 0.80, 0.55)
    values this step0.6cutoff
  2. prob ← 0.20, 0.65, 0.80, 0.55

    1cutoff <- 0.62prob <- c(0.20, 0.65, 0.80, 0.55)3predicted <- ifelse(prob >= cutoff, "yes", "no")
    values this step0.20, 0.65, 0.80, 0.55prob
  3. predicted ← no, yes, yes, no

    2prob <- c(0.20, 0.65, 0.80, 0.55)3predicted <- ifelse(prob >= cutoff, "yes", "no")4yes_count <- sum(predicted == "yes")
    values this stepno, yes, yes, nopredicted4 scoresprob0.6cutoff
  4. yes_count ← 2

    3predicted <- ifelse(prob >= cutoff, "yes", "no")4yes_count <- sum(predicted == "yes")5label <- paste("yes", yes_count, sep = ":")
    values this step2yes_countno, yes, yes, nopredicted
  5. label ← yes:2

    4yes_count <- sum(predicted == "yes")5label <- paste("yes", yes_count, sep = ":")6cat(label, "\n", sep = "")
    values this stepyes:2label2yes_count
  6. cat(label, " ", sep = "")

    5label <- paste("yes", yes_count, sep = ":")6cat(label, "\n", sep = "")
    outputyes:2
    values this stepyes:2label
  1. cutoff ← 0.5

    1cutoff <- 0.52prob <- c(0.20, 0.65, 0.80, 0.55)
    values this step0.5cutoff
  2. prob ← 0.20, 0.65, 0.80, 0.55

    1cutoff <- 0.52prob <- c(0.20, 0.65, 0.80, 0.55)3predicted <- ifelse(prob >= cutoff, "yes", "no")
    values this step0.20, 0.65, 0.80, 0.55prob
  3. predicted ← no, yes, yes, yes

    2prob <- c(0.20, 0.65, 0.80, 0.55)3predicted <- ifelse(prob >= cutoff, "yes", "no")4yes_count <- sum(predicted == "yes")
    values this stepno, yes, yes, yespredicted4 scoresprob0.5cutoff
  4. yes_count ← 3

    3predicted <- ifelse(prob >= cutoff, "yes", "no")4yes_count <- sum(predicted == "yes")5label <- paste("yes", yes_count, sep = ":")
    values this step3yes_countno, yes, yes, yespredicted
  5. label ← yes:3

    4yes_count <- sum(predicted == "yes")5label <- paste("yes", yes_count, sep = ":")6cat(label, "\n", sep = "")
    values this stepyes:3label3yes_count
  6. cat(label, " ", sep = "")

    5label <- paste("yes", yes_count, sep = ":")6cat(label, "\n", sep = "")
    outputyes:3
    values this stepyes:3label
  1. cutoff ← 0.7

    1cutoff <- 0.72prob <- c(0.20, 0.65, 0.80, 0.55)
    values this step0.7cutoff
  2. prob ← 0.20, 0.65, 0.80, 0.55

    1cutoff <- 0.72prob <- c(0.20, 0.65, 0.80, 0.55)3predicted <- ifelse(prob >= cutoff, "yes", "no")
    values this step0.20, 0.65, 0.80, 0.55prob
  3. predicted ← no, no, yes, no

    2prob <- c(0.20, 0.65, 0.80, 0.55)3predicted <- ifelse(prob >= cutoff, "yes", "no")4yes_count <- sum(predicted == "yes")
    values this stepno, no, yes, nopredicted4 scoresprob0.7cutoff
  4. yes_count ← 1

    3predicted <- ifelse(prob >= cutoff, "yes", "no")4yes_count <- sum(predicted == "yes")5label <- paste("yes", yes_count, sep = ":")
    values this step1yes_countno, no, yes, nopredicted
  5. label ← yes:1

    4yes_count <- sum(predicted == "yes")5label <- paste("yes", yes_count, sep = ":")6cat(label, "\n", sep = "")
    values this stepyes:1label1yes_count
  6. cat(label, " ", sep = "")

    5label <- paste("yes", yes_count, sep = ":")6cat(label, "\n", sep = "")
    outputyes:1
    values this stepyes:1label
probability Scores near 1 are stronger evidence for the positive class.
threshold `prob >= cutoff` creates one decision per score.
label count Counting labels gives a quick summary of classifier output.