<jupyter_start><jupyter_text>Data exploration<jupyter_code># Visualize some samples of train data
train_df.head()
# Variables type
train_df.dtypes<jupyter_output><empty_output><jupyter_text>Variables descriptionVariable | Description:------: | :----------- survival | If the person has survived (0 = No, 1 = Yes)pclass   | Ticket class (1 = 1st, 2 = 2nd, 3 = 3rd)sex      | Sex (Male or Female)Age      | Age in years (Age is fractional if less than 1. If the age is estimated, is it in the form of xx.5)sibsp    |  of siblings / spouses aboard the Titanic (*)parch    |  of parents / children aboard the Titanic (**)ticket   | Ticket numberfare     | Passenger farecabin    | Cabin numberembarked | Port of Embarkation	(C = Cherbourg, Q = Queenstown, S = Southampton)Notes:(*) Sibling = brother, sister, stepbrother, stepsister. Spouse = husband, wife (mistresses and fiancés were ignored)(**) Parent = mother, father. Child = daughter, son, stepdaughter, stepsonSome children travelled only with a nanny, therefore parch=0 for them.<jupyter_code># Dataset shape
train_df.shape
# Visualize percentage of survivors on training set
## Basically check if the dataset is balanced for training
ax = plt.axes()
sns.countplot(x='Survived', data=train_df, ax=ax);
ax.set_title('Survived distribution')
plt.show()
# Check what columns have NANs
train_df.isnull().any()
print('Number of NANs in Age: %s' % train_df[train_df['Age'].isnull()].shape[0])
print('Number of NANs in Cabin: %s' % train_df[train_df['Cabin'].isnull()].shape[0])
print('Number of NANs in Embarked: %s' % train_df[train_df['Embarked'].isnull()].shape[0])<jupyter_output>Number of NANs in Age: 177
Number of NANs in Cabin: 687
Number of NANs in Embarked: 2
{'fraction_non_alphanumeric': 0.12281722933643772, 'fraction_numerical': 0.012223515715948778, 'mean_word_length': 4.886986301369863, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '608442', 'license': 'MIT', 'n_tokens_mistral': 593, 'n_tokens_neox': 556, 'n_words': 189, 'path': 'competitions/titanic/titanic.ipynb', 'repo_name': 'Hguimaraes/kaggle-road', 'size': '1718'}