LogisticRegression Sex Fare Pclass

### 06/02/2016 ### This R script uses a logistic regression model to predict survival in ### the test set ### The following variables are used for predicting: Sex, Fare, Pclass ### and their interactions ### This model has the same score (0.7790) as the Gender, Price and Class based ### model ### read data train <- read.csv(“../input/train.csv”) test <- read.csv(“../input/test.csv”) # We can inspect the train data. summary(train) summary(test) ### transform the following variables from numerical to categorical train$Survived <- as.factor(train$Survived) train$Pclass <- as.factor(train$Pclass) test$Pclass <- as.factor(test$Pclass) ### when having a look at the summary data I noted that their were passengers that ### had a Fare of 0. Impute those fares with the median of the Pclass train$fare <- train$Fare train$fare[train$Fare==0 & train$Pclass==1] <- median(train$Fare[train$Pclass==1]) train$fare[train$Fare==0 & train$Pclass==2] <-…


Link to Full Article: LogisticRegression Sex Fare Pclass