Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR R

to get the proportion of votes for the winning class in r

# Use the prob parameter to get the proportion of votes for the winning class
x_pred <- knn(train, test, labels, k = 7, prob = TRUE)

# Get the "prob" attribute from the predicted classes
x_prob <- attr(x_pred, "prob")

# Examine the proportion of votes for the winning class
head(x_prob)
 
PREVIOUS NEXT
Tagged: #proportion #votes #winning #class
ADD COMMENT
Topic
Name
4+8 =