Skip to content

Instantly share code, notes, and snippets.

@sdgilley
Forked from dec100/score.R
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdgilley/7a08181976b0f4ed5cbe to your computer and use it in GitHub Desktop.
Save sdgilley/7a08181976b0f4ed5cbe to your computer and use it in GitHub Desktop.
score.R - script used in Building and Using Models in DeployR Tutorial
library(deployrUtils)
deployrPackage("rpart")
# load the model
if (!exists("model")) load(file="model.rData")
# provide some values for an observation to be scored
deployrInput('{"name": "balance","render": "numeric","default": 2000}')
deployrInput('{"name": "numTrans","render": "numeric","default": 10}')
deployrInput('{"name": "creditLine","render": "numeric","default": 18}')
# create a data.frame
obs <- data.frame(balance, numTrans, creditLine)
# score the observation and report the predicted value
Prediction <- predict(model, obs)
Prediction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment