Skip to content

Instantly share code, notes, and snippets.

View sdgilley's full-sized avatar

Sheri Gilley sdgilley

  • Microsoft
  • Chicago, IL
View GitHub Profile
library(pdftools)
# read the data from the pdf
url="http://www.idfpr.com/Forms/MC/ListofLicensedDispensaries.pdf"
text<-pdf_text(url)
t<-text
# strip out info about start date, end date, etc... it is not consistently formatted
# 13 8/24/2015 8/24/2016 280.000\r\n
@sdgilley
sdgilley / build.R
Last active August 29, 2015 14:24
build.R - script used in Building and Using Models in DeployR Tutorial
sampleData<-read.csv("http://packages.revolutionanalytics.com/datasets/ccFraud.csv",
nrows=100000)
# a simple tree model
library(rpart)
model <- rpart(fraudRisk~balance+numTrans+creditLine, data=sampleData)
save(model, file="model.rData")
# Set MKL threads if Revolution R Open or Revoltion R Enterprise is available
if(require(Revobase)){
setMKLthreads(4)
}
# Initialization
set.seed (1)
@sdgilley
sdgilley / score.R
Last active August 29, 2015 14:19 — forked from dec100/score.R
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}')