Closed AlineTalhouk closed 7 years ago
Probabilities can be obtained for all models except knn
since it is non-parametric:
# Temp code for #17
# Load data and run splendid on all algorithms
library(splendid)
library(magrittr)
data(hgsc)
class <- stringr::str_split_fixed(rownames(hgsc), "_", n = 2)[, 2]
sl_result <- splendid(hgsc, class, n = 1)
mods <- purrr::map(sl_result$models, 1)
# Testing on training set here, but use test set in real application
predict(mods$lda, hgsc)$posterior
predict(mods$rf, hgsc, "prob")
predict(mods$multinom, hgsc, "probs")
predict(mods$nnet, hgsc, "raw")
# no knn since it uses non-parametric classification
predict(mods$svm, hgsc, probability = TRUE) %>% attr("prob")
pamr::pamr.predict(mods$pam, t(hgsc), threshold = 1, type = "posterior") # threshold CV'd in real app
predict(mods$adaboost, hgsc %>% set_names(make.names(names(.))), "prob")
predict(mods$xgboost, as.matrix(hgsc)) %>%
matrix(ncol = mods$xgboost$params$num_class, byrow = TRUE)
predict(mods$nb, hgsc, "raw")
predict(mods$lasso, as.matrix(hgsc), type = "response")
predict(mods$ridge, as.matrix(hgsc), type = "response")
Please see for knn probability https://www.rdocumentation.org/packages/KODAMA/versions/0.0.1/topics/knn.probability
See fec92d58e4ec8a07f2894c700dc013be4138a7d6 for knn probability.
Usage: setting probability = TRUE
in splendid_model
(or splendid
) adds the class probability matrix as an attribute to the predicted class vector
I think my pushes are done for the day!
how do you install knnflex?
devtools::install_github("Dasonk/knnflex")
Yes that's the one I used as well
Used to compute measures in #12
@dchiu911 can you please see whether of the models we have implemented we are able to obtain probabilities?