Titanic Test Script

# This R script will run on our backend. You can write arbitrary code here! # Many standard libraries are already installed, such as randomForest library(randomForest) library(rpart) library(rpart.plot) library(RColorBrewer) library(dplyr) # The train and test data is stored in the ../input directory train <- read.csv(“../input/train.csv”) test <- read.csv(“../input/test.csv”) #Create Family Size variable train$family_size <- train$SibSp + train$Parch + 1 test$family_size <- test$SibSp + test$Parch + 1 #Create Survived variable column in test and fill with NA test$Survived <- NA #Temporarily combine train and test to do formatting combi <- rbind(train, test) #Format combi combi$Name <- as.character(combi$Name) combi$Title <- sapply(combi$Name, FUN=function(x) {strsplit(x, split='[,.]’)[[1]][2]}) combi$Title <- sub(‘ ‘, ”, combi$Title) combi$Title[combi$Title %in% c(‘Mme’, ‘Mlle’)] <- ‘Mlle’ combi$Title[combi$Title %in% c(‘Capt’, ‘Don’, ‘Major’, ‘Jonkheer’, ‘Sir’)] <- ‘Sir’ combi$Title[combi$Title %in% c(‘Dona’, ‘Lady’, ‘the Countess’)] <-…

Link to Full Article: Titanic Test Script

Pin It on Pinterest

Share This

Join Our Newsletter

Sign up to our mailing list to receive the latest news and updates about homeAI.info and the Informed.AI Network of AI related websites which includes Events.AI, Neurons.AI, Awards.AI, and Vocation.AI

You have Successfully Subscribed!