AlineTalhouk / splendid

Supervised Learning Ensemble for Diagnostic Identification
https://alinetalhouk.github.io/splendid/
Other
1 stars 0 forks source link

Returning Probabilities #17

Closed AlineTalhouk closed 7 years ago

AlineTalhouk commented 7 years ago

@dchiu911 can you please see whether of the models we have implemented we are able to obtain probabilities?

dchiu911 commented 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")
AlineTalhouk commented 7 years ago

Please see for knn probability https://www.rdocumentation.org/packages/KODAMA/versions/0.0.1/topics/knn.probability

dchiu911 commented 7 years ago

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

dchiu911 commented 7 years ago

I think my pushes are done for the day!

AlineTalhouk commented 7 years ago

how do you install knnflex?

dchiu911 commented 7 years ago

devtools::install_github("Dasonk/knnflex")

AlineTalhouk commented 7 years ago

Yes that's the one I used as well

dchiu911 commented 7 years ago

Used to compute measures in #12