I am currently working through Kaggle's titanic competition and I'm trying to figure out the correlation between the Survived
column and other columns. I am using numpy.corrcoef()
to matrix the correlation between the columns and here is what I have:
The correlation between pClass & Survived is: [[ 1. -0.33848104]
[-0.33848104 1. ]]
The correlation between Sex & Survived is: [[ 1. -0.54335138]
[-0.54335138 1. ]]
The correlation between Age & Survived is:[[ 1. -0.07065723]
[-0.07065723 1. ]]
The correlation between Fare & Survived is: [[1. 0.25730652]
[0.25730652 1. ]]
The correlation between Parent-Children & Survived is: [[1. 0.08162941]
[0.08162941 1. ]]
The correlation between Sibling-Spouse & Survived is: [[ 1. -0.0353225]
[-0.0353225 1. ]]
The correlation between Embarked & Survived is: [[ 1. -0.16767531]
[-0.16767531 1. ]]
There should be higher correlation between Survived
and [pClass
, sex
, Sibling-Spouse
] and yet the values are really low. I'm new to this so I understand that a simple method is not the best way to find correlations but at the moment, this doesn't add up.
This is my full code (without the printf()
calls):
import pandas as pd
import numpy as np
train = pd.read_csv("https://raw.githubusercontent.com/oo92/Titanic-Kaggle/master/train.csv")
test = pd.read_csv("https://raw.githubusercontent.com/oo92/Titanic-Kaggle/master/test.csv")
survived = train['Survived']
pClass = train['Pclass']
sex = train['Sex'].replace(['female', 'male'], [0, 1])
age = train['Age'].fillna(round(float(np.mean(train['Age'].dropna()))))
fare = train['Fare']
parch = train['Parch']
sibSp = train['SibSp']
embarked = train['Embarked'].replace(['C', 'Q', 'S'], [1, 2, 3])