[R] predict function type class vs. prob

Milbert, Sabine (LGL) S@b|ne@M||bert @end|ng |rom |g|@b@yern@de
Fri Sep 22 12:12:51 CEST 2023

Dear R Help Team,

My research group and I use R scripts for our multivariate data screening routines. During routine use, we encountered some inconsistencies within the predict() function of the R Stats Package. Through internal research, we were unable to find the reason for this and have decided to contact your help team with the following issue:

The predict() function is used once to predict the class membership of a new sample (type = "class") on a trained linear SVM model for distinguishing two classes (using the caret package). It is then used to also examine the probability of class membership (type = "prob"). Both are then presented in an R shiny output. Within the routine, we noticed two samples (out of 100+) where the class prediction and probability prediction did not match. The prediction probabilities of one class (52%) did not match the class membership within the predict function. We use the same seed and the discrepancy is reproducible in this sample. The same problem did not occur in other trained models (lda, random forest, radial SVM...).

Is there a weighing of classes within the prediction function or is the classification limit not at 50%/a majority vote? Or do you have another explanation for this discrepancy, please let us know.

PS: If this is an issue based on the model training function of the caret package and therefore not your responsibility, please let us know.

Thank you in advance for your support!

Yours sincerely,
Sabine Milbert

	[[alternative HTML version deleted]]

More information about the R-help mailing list