For the analysis, we will first make a preprocessing step, cleaning the data and factoring some informations. All missing Ages are replaced by the median value. We will consider the following informations from the training data:
    - Survived: Passenger Survival Indicator
    - Pclass: Passenger Class
    - Sex: Sex
    - Age: Age
    - SibSp: Number of Sibling/Spouses Aboard
    - Parch: Number of Parents/Children Aboard
    - Fare: Passenger Fare
    - Embarked: Port of Embarkation

Creation of train and test partitions based on Survival:

Baseline prediction by guessing the outcome

We will first try to guess the outcome of Survival, only by chance.
This will guide following machine learning algorithm predictors.

Since we are guessing only by chance, the accuracy is expected to be around 0.5.
We now apply some machine learning techniques, with several different predictors and parameters.

Linear Discriminant Analysis (LDA)

Survival by Sex

Our first approach will be using only the sex to predict survival.
We can look on the survival rate by sex on the training set:

From the survival rate by sex on the training set, we can predict survival for all individuals of a sex over 0.5 (female) and predict death for all individuals of a sex under 0.5 (male). This is equivalent to applying LDA with Sex as predictor.

LDA

Survival by Passenger Class

Now we will use the passenger class as the predictor of survival.
We already saw the survival status by passenger class with graphics. Now we summarize these rates:

Similar to the model built on sex, we know predict survival for classes that have a rate over 0.5 and predict death for the classes with rate under 0.5. This is equivalent to applying LDA with Passenger Class as predictor.

LDA

Survival by Fare

We will look now the prediction of survival based on the fare as predictor.
Since the fare is not a binary outcome, we will show only the outcome of applying the LDA modelling.

LDA

Survival by all predictors

We apply LDA with all predictors.

By analyzing the LDA models fitted, we can see that by using all predictors, we get the best accuracy and F1 Score. However the values are close to the model using only the Sex as predictor.
We will now apply QDA with the same predictors, to compare them with LDA.

Quadratic Discriminant Analysis (QDA)

Survival by Sex

Since the predictor Sex has only 2 classes the LDA model has the same standard deviation and correlation as the QDA model. Thus the QDA model will have the same confusion matrix.

QDA

Survival by Passenger Class

The passenger class has more than 2 classes, so the QDA confusion matrix is different to the LDA model.

QDA

Survival by Fare

QDA

Survival by all predictors

Since the FamilySize is a redundant predictor as SibSp and Parch, we remove it from the training setting.

We can see that the QDA models had similar outcomes compared to LDA. The best model was also using all predictors. However the accuracy was still not better than 0.8 and the specificity was still low.

Logistic regression

Survival by Sex

We will start by applying only Sex as predictor with logistic regression.

Logistic regression

Survival by Sex, Class, Fare and Age

Now we will apply Sex, Class, Fare and Age as predictors.

Logistic regression

Survival by all predictors

Logistic regression had a slightly better accuracy than previous models. By comparing all predictors, we can see that the number of family members and embarked port don't have valuable information as predictors.

K-nearest neighbors (Knn)

Survival by all predictors

We apply all predictors to knn. This method uses bootstrap samples for tuning the parameter k.

Knn

Survival by all predictors with 10-fold Cross-validation

The default parameter for the knn in this method is to use 25-fold cross-validation, with 25% of the data. We will apply 10-fold cross-validation, with 10% of the data.

Classification tree

Survival by all predictors

The classification tree uses cross-validation to find the best complexity parameter (cp) for the model, calculated by the Gini Index or the Entropy.

Random Forest

Survival by all predictors

Random Forest improves prediction performance and reduces instability of decision tree by averaging multiple decision trees, obtained through bootstrap samples.

The variable importance shows which predictors have more importance in the random forest decisions.

In our approach the Random Forest model showed the best accuracy of all models. It has also increased specificity, compared to the others.
By checking its variable importance, we can see that the most important predictors are the sex, fare and age, which matches the initial analysis we presented previously over the data.