2
$\begingroup$

I came across a kaggle challenge where you have to predict the probabilities for all matchups in a basketball tournament. I was already working with classification and regression algorithms like SVM, Naive Bayes, Random Forests, Nerual Networks etc. Therefore I used R and the caret package. But as the result you always get the final classificated class without the respective probability. E.g. it would either classify 1 if the team home wins and 0 when the team away wins. How can you predict the respective probability that you can say team home has a 82% chance to win?

$\endgroup$
4
$\begingroup$

I assume you use the predict() function in R. You can specify the output you want. For example type="response" or type="prob". Type "prob" and/or "raw" (depending on the model) will output class probability.

Example:

# Predicting class
pred_class <- predict(model, test_set, type="response")
# Predicting probability of class
pred_prob <- predict(model, test_set, type="prob")

Edit: Arguments in the predict.train {caret} (http://www.inside-r.org/packages/cran/caret/docs/predict.train):

type either "raw" or "prob", for the number/class predictions or class probabilities, respectively. Class probabilities are not available for all classification models

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.