Created
January 4, 2017 12:28
-
-
Save actsasflinn/c0c1a04a4d84f1f039d57d5eb3f0571b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(jug) | |
library(xgboost) | |
library(Matrix) | |
setwd("~/Projects/xgboost_test") | |
model <- xgb.load("xgboost1.save") | |
jug() %>% | |
get("/model/(?<age>.*)/(?<workclass>.*)/(?<education>.*)/(?<marital_status>.*)/(?<occupation>.*)/(?<relationship>.*)/(?<gender>.*)", function(req, res, err){ | |
df <- data.frame( | |
age = as.numeric(req$params$age), | |
workclass = req$params$workclass, | |
education = req$params$education, | |
marital_status = req$params$marital_status, | |
occupation = req$params$occupation, | |
relationship = req$params$relationship, | |
gender = req$params$gender | |
) | |
df$score <- predict(model, data.matrix(df)) | |
df$prediction <- df$score>0.5 | |
cat(str(df)) | |
res$json(df) | |
}) %>% | |
simple_error_handler_json() %>% | |
serve_it() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment