https://github.com/stevenmmortimer/beard
A Simple Webservice to Predict Proportion of Men with Beards
https://github.com/stevenmmortimer/beard
Last synced: 8 months ago
JSON representation
A Simple Webservice to Predict Proportion of Men with Beards
- Host: GitHub
- URL: https://github.com/stevenmmortimer/beard
- Owner: StevenMMortimer
- Created: 2015-06-11T01:59:06.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-30T13:57:50.000Z (over 10 years ago)
- Last Synced: 2025-03-24T13:25:29.606Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 80.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Deploy scoring model
====================
This package illustrates how to deploy a model for remote scoring/prediction.
# Install in R
library(devtools)
install_github("ReportMort/beard")
# Score in R
library(beard)
mydata <- data.frame(year=c(1890))
beard(input = mydata)
# Score remotely
curl https://public.opencpu.org/ocpu/github/ReportMort/beard/R/beard/json \
-H "Content-Type: application/json" \
-d '{"input" : [ {"year":1914} ]}'
# Score using Vagrant and Virtualbox
# First setup virtual machine, copy package to it, ssh into it and install, and run curl against that machine
scp -P 2222 /cygdrive/c/users/steven.mortimer/documents/personal-github/beard_0.0.tar.gz vagrant@127.0.0.1:~/.
vagrant ssh
sudo R CMD INSTALL beard_0.0.tar.gz --library=/usr/local/lib/R/site-library
curl http://10.68.12.119/ocpu/library/beard/R/beard/json \
-H "Content-Type: application/json" \
-d '{"input" : [ {"year":1914} ]}'
# Score from R using RCurl
library(RCurl)
library(RJSONIO)
res <- postForm("https://public.opencpu.org/ocpu/github/ReportMort/beard/R/beard/json",
.opts = list(postfields = toJSON(list(input=list(year=1890))),
httpheader = c('Content-Type' = 'application/json', Accept = 'application/json'),
ssl.verifypeer = FALSE))
fromJSON(res)
The model is included in the `data` directory of the package, and was created
using the [createmodel.R](https://github.com/reportmort/beard/blob/master/inst/beard/createmodel.R) script. It predicts in the early 20th century the prevelance of beards among men.