ksygrek

rr

Jun 24th, 2020
1,580
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(C50);
  2. library(RoughSets);
  3. library(keras);
  4. source("knn.R")
  5.  
  6.  
  7. #* Echo back the input
  8. #* @param STG The message to echo
  9. #* @param SCG The second number to add
  10. #* @param STR The second number to add
  11. #* @param LPR The second number to add
  12. #* @param PEG The second number to add
  13. #* @get /api/results
  14. function(STG, SCG, STR, LPR, PEG) {
  15.  
  16.   STG <- as.double(STG)
  17.   SCG <- as.double(SCG)
  18.   STR <- as.double(STR)
  19.   LPR <- as.double(LPR)
  20.   PEG <- as.double(PEG)
  21.  
  22.   new_case <- matrix(c(STG, SCG, STR, LPR, PEG), ncol=5, byrow=TRUE)
  23.   colnames(new_case) <- c("STG","SCG","STR","LPR","PEG")
  24.   rownames(new_case) <- c("1")
  25.  
  26.   model_tree <- get(load("models/c50.RData"))
  27.   model_lem2 <- get(load("models/lem2.RData"))
  28.   model_tf <- load_model_tf("models/deep_learning_model")
  29.  
  30.   sink("nul")
  31.   model_knn <- func_knn(STG, SCG, STR, LPR, PEG)
  32.   sink()
  33.  
  34.   predict_tree <- predict(model_tree, new_case)
  35.   predict_lem2 <- predict(model_lem2, SF.asDecisionTable(new_case))
  36.   predict_tf <- predict_classes(model_tf, new_case) + 1
  37.   predict_knn <- model_knn$Prediction
  38.  
  39.   predict_lem2 <- as.integer(as.vector(predict_lem2$predictions))
  40.   predict_tree <- as.integer(predict_tree)
  41.   predict_tf <- as.integer(predict_tf)
  42.   predict_knn <- as.integer(predict_knn)
  43.  
  44.   result_list <- list("c50" = predict_tree,
  45.                       "lem2" = predict_lem2,
  46.                       "tf" = predict_tf,
  47.                       "knn" = predict_knn,
  48.                       "knn_stats"=model_knn )
  49.   return(result_list)
  50. }
  51.  
  52.  
  53. #library(plumber)
  54. # r <- plumb("prediction.R")  # Where 'plumber.R' is the location of the file shown above
  55. # r$run(port=8000)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×