-
Notifications
You must be signed in to change notification settings - Fork 12
Home
Asaf Schers edited this page May 18, 2017
·
9 revisions
# Install and require randomForest, pmml packages
install.packages('randomForest')
install.packages('pmml')
library("randomForest")
library('pmml')
# Login to Kaggle and download titanic dataset
# https://www.kaggle.com/c/titanic/data
# Load CSV to data frame -
titanic.train <- read.table("titanic_train.csv", header = TRUE, sep = ",")
titanic.train$Survived <- as.factor(titanic.train$Survived)
# Train RF model
titanic.rf <- randomForest(Survived ~ . - Name - Cabin - Ticket, data = titanic.train, na.action = na.roughfix)
# Generate pmml from model
pmml <- pmml(titanic.rf)
saveXML(pmml, 'titanic_rf.pmml')
random_forest = Scourby.get_model 'random_forest.pmml'
features = {a: 1, b: true, c: 'YES'}
random_forest.predict(features)
random_forest.decisions_count(features)