Pour obtenir la proportion de votes pour la classe gagnante dans 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)
Successful Salmon