# This R script will run on our backend. You can write arbitrary code here! library(psych) library(caret) library(rpart) # The train and test data is stored in the ../input directory set.seed(1) train <- read.csv(“../input/train.csv”) test <- read.csv(“../input/test.csv”) ###Data Wrangle Function wrangleFeatures <- function(data) { variables <- c(“Pclass”, “Sex”, “Age”, “SibSp”, “Parch”, “Cabin”, “Fare”, “Embarked”) data <- data[variables] predicted_age <- rpart(Age ~ Pclass + Sex + SibSp + Parch + Fare + Embarked, data = data[!$Age),], method = “anova”) data$Age[$Age)] <- predict(predicted_age, data[$Age),]) data$Fare[$Fare)] <- median(data$Fare, na.rm=TRUE) data$Embarked[data$Embarked==””] = “S” data$Sex <- as.factor(data$Sex) data$Embarked <- as.factor(data$Embarked) data$Cabin <- as.character(data$Cabin) data$Cabin[grep(“A”, data$Cabin)] <- “boat” data$Cabin[grep(“B”, data$Cabin)] <- “promenade” data$Cabin[grep(“C”, data$Cabin)] <- “bridge” data$Cabin[grep(“D”, data$Cabin)] <- “shelter” data$Cabin[grep(“E”, data$Cabin)] <- “saloon” data$Cabin[grep(“F”, data$Cabin)] <- “upper” data$Cabin[grep(“G”, data$Cabin)] <- “middle” data$Cabin[grep(“T”, data$Cabin)] <- “”…

Link to Full Article: BaggedTrees

Pin It on Pinterest

Share This

Join Our Newsletter

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

You have Successfully Subscribed!