{"id":318,"date":"2017-07-28T17:11:41","date_gmt":"2017-07-28T17:11:41","guid":{"rendered":"http:\/\/www.codeastar.com\/?p=318"},"modified":"2017-07-28T17:11:41","modified_gmt":"2017-07-28T17:11:41","slug":"data-wrangling","status":"publish","type":"post","link":"https:\/\/www.codeastar.com\/data-wrangling\/","title":{"rendered":"Titanic Survivors Dataset and Data Wrangling"},"content":{"rendered":"
\"Data
Data Wrangling, Yee Ha!<\/figcaption><\/figure>\n

We have learnt how to select a machine learning model<\/a>, it is time to study another Data Science topic from the Data Science Life Cycle<\/a> — Data Collection.<\/p>\n

Yes, we do need to know how to collect data.\u00a0Unlike our Iris Classification<\/a>\u00a0project, which its data set is well prepared. Sometimes, we need to prepare our own data for machine to learn.<\/p>\n

<\/p>\n

Data Wrangling<\/h3>\n

Then we have another topic to learn — Data Wrangling. Data Wrangling is a process to transform raw data to machine readable data. This time, we use a well known data set as our subject, the\u00a0Titanic survivors data sets.<\/p>\n

First of all, let’s get the data sets from the Titanic Machine Learning competition<\/a> at Kaggle.com . Although it is called a “competition”, it is an entry level data science practice actually.<\/p>\n

You can download a train.csv file as a training data set and a test.csv file for result predication. Then we use Pandas to take a look on their data structures:<\/p>\n

import pandas as pd\r\nimport numpy as np\r\n\r\n#replace the file paths for your csv files\r\ntrain_df = pd.read_csv(\"Titanic\/train.csv\")\r\ntest_df = pd.read_csv(\"Titanic\/test.csv\")\r\n\r\n#show the numbers of row and column\r\nprint(train_df.shape)\r\n#show the numbers of missing values\r\nprint(train_df.apply(lambda x: sum(x.isnull()),axis=0))\r\nprint(test_df.shape)\r\nprint(test_df.apply(lambda x: sum(x.isnull()),axis=0))\r\n<\/pre>\n
(891, 12)\r\nPassengerId      0\r\nSurvived         0\r\nPclass           0\r\nName             0\r\nSex              0\r\nAge            177\r\nSibSp            0\r\nParch            0\r\nTicket           0\r\nFare             0\r\nCabin          687\r\nEmbarked         2\r\ndtype: int64\r\n(418, 11)\r\nPassengerId      0\r\nPclass           0\r\nName             0\r\nSex              0\r\nAge             86\r\nSibSp            0\r\nParch            0\r\nTicket           0\r\nFare             1\r\nCabin          327\r\nEmbarked         0\r\ndtype: int64\r\n<\/pre>\n

Our mission for this data science project is to find out the survivors on the testing data set. That is why the “Survived” field is missed from the test.csv file. And we also find that there are missing values in “Age”, “Fare”, “Cabin” and “Embarked” features, e.g.:<\/p>\n

\"\"<\/p>\n

Other than those missing values, “Name”, “Sex”, “Ticket”, “Cabin” and “Embarked” are all non-numeric features. Do not feel frustrated, think positive! This is a chance for us to learn the technique on data wrangling.<\/p>\n

Let the machine read the data<\/h3>\n

Our objective on data wrangling is to transform raw data to machine read-able data. Let’ start from the easiest step first, the “Sex” feature. We open our machine’s “eyes” by mapping male as “1” \u00a0and female as “0”:<\/p>\n

train_df[\"Sex\"] = train_df[\"Sex\"].map({\"male\": 1, \"female\":0})\r\n<\/pre>\n

Then we have changed the original “male” and “female” values to machine read-able 1\/0 values:<\/p>\n

\"\"<\/p>\n

We can apply the same technique on “Embarked” feature, but, we know that there are 2 missing values on the training data set. So we go to check the current content of the “Embarked” feature:<\/p>\n

print(train_df['Embarked'].value_counts(ascending=True))\r\nprint(train_df['Embarked'].value_counts(normalize=True,ascending=True))\r\n<\/pre>\n

And we got:<\/p>\n

Q     77\r\nC    168\r\nS    644\r\nName: Embarked, dtype: int64\r\nQ    0.086614\r\nC    0.188976\r\nS    0.724409\r\nName: Embarked, dtype: float64\r\n<\/pre>\n

“S” (Southampton from the data dictation) is the majority of available values, thus we can fill “S” into the 2 missing values and map all values into numbers.<\/p>\n

train_df['Embarked'] = train_df['Embarked'].fillna('S')\r\ntrain_df['Embarked'] = train_df['Embarked'].map( {'S': 0, 'C': 1, 'Q': 2} ).astype(int)\r\n<\/pre>\n

For “Cabin” feature, since there are 687 out of 891 missing records, we can simply skip this feature.<\/p>\n

There is no null values in “Ticket” feature, but I hardly find the data-real life relationship between survival rate and ticket number, so we skip this feature as well.<\/p>\n

That’s Not My Name<\/h3>\n

Now we only have one non-numeric feature to solve: “Name”. We find that other than first name and last name, there is title stored in the “Name” column as well. Let’s take a closer look on the title value.<\/p>\n

#get title from name \r\ntrain_df['Title'] = df['Name'].apply(lambda x: x.split(\",\")[1].split(\".\")[0].strip())\r\nprint(train_df['TicketPrefix'].value_counts(ascending=True, dropna=False))\r\n<\/pre>\n
Ms                1\r\nMme               1\r\nCapt              1\r\nSir               1\r\nJonkheer          1\r\nthe Countess      1\r\nLady              1\r\nDon               1\r\nMajor             2\r\nCol               2\r\nMlle              2\r\nRev               6\r\nDr                7\r\nMaster           40\r\nMrs             125\r\nMiss            182\r\nMr              517\r\n<\/pre>\n

We group different titles according to their social status and similarity.<\/p>\n

train_df[\"Title\"] = train_df[\"Title\"].replace(['Lady', 'the Countess','Countess','Capt', 'Col','Don', 'Dr', 'Major', 'Rev', 'Sir', 'Jonkheer', 'Dona'], 'Rare')\r\ntrain_df['Title'] = train_df['Title'].replace('Mlle', 'Miss')\r\ntrain_df['Title'] = train_df['Title'].replace('Ms', 'Miss')\r\ntrain_df['Title'] = train_df['Title'].replace('Mme', 'Mrs')\r\n<\/pre>\n

And see their relationship with survival rate.<\/p>\n

import matplotlib.pyplot as plt\r\nimport seaborn as sns\r\n\r\nsns.barplot(x=\"Title\", y=\"Survived\", data=train_df)\r\n\r\nplt.show()<\/pre>\n

Please note that we are using seaborn<\/em> library, which is built on top of matplotlib<\/em>. It provides further enhancement on both functionality and presentation for plotting. In short: an upgrade.<\/p>\n

\"\"<\/p>\n

Obviously, female (“Mrs” and “Miss” groups) got much better chance to survive. But “Rare” and “Master” title groups had better survival rates than “Mr” group. Sometimes, having better title does not only mean having better social status, it pays off in the game of surviving.<\/p>\n

We map title group into numeric values and drop unused features.<\/p>\n

title_mapping = {\"Mr\": 1, \"Miss\": 2, \"Mrs\": 3, \"Master\": 4, \"Rare\": 5}\r\ntrain_df['Title'] = train_df['Title'].map(title_mapping)\r\n\r\ntrain_df = train_df.drop([\"Name\", \"Ticket\", \"Cabin\"], axis=1)\r\n<\/pre>\n

Then we have an all-numeric data set:
\n\"\"<\/p>\n

The Number Game<\/h3>\n

Now we focus on the numeric features. “SibSp” and “Parch” represent siblings, spouses, parents and children, i.e. family members. We make a new feature, “FamilySize”, for storing these 2 features. And check its relationship with survival rate using kernel density estimate graph.<\/p>\n

train_df['FamilySize'] = train_df['SibSp'] + train_df['Parch'] + 1\r\n\r\nfacet = sns.FacetGrid(train_df, hue=\"Survived\",aspect=4)\r\nfacet.map(sns.kdeplot,'FamilySize',shade= True)\r\nfacet.set(xlim=(0, train_df['FamilySize'].max()))\r\nfacet.add_legend()\r\n\r\nplt.show()\r\n<\/pre>\n

\"\"<\/p>\n

It is quite sure that, passengers with 2 or 3 family members are easier to survive then those individual travelers. Then we separate “FamilySize” into 4 different groups.<\/p>\n

bins = (-1, 1, 2, 3, 12)\r\ngroup_names = [1,2,3,4]\r\ncategories = pd.cut(train_df['FamilySize'], bins, labels=group_names)\r\ntrain_df['FamilyGroup'] = categories\r\n<\/pre>\n

On the family size feature, it raises out another question. Would passengers with parent and children have better chance to survive than people with siblings and spouses? Thus I create following 2 features, “withP” (with parents\/children) and “withS” (with siblings\/spouses):<\/p>\n

train_df['withP']=0\r\ntrain_df['withS']=0\r\n   \r\ntrain_df.loc[train_df['SibSp'] > 0, 'withS'] = 1\r\ntrain_df.loc[train_df['Parch'] > 0, 'withP'] = 1\r\n\r\nsns.barplot(x=\"withP\", y=\"Survived\", hue=\"withS\", data=train_df)\r\nplt.show()\r\n<\/pre>\n

And compare their relationship with survival rates:
\n\"\"
\nWhen parents\/children are passengers only relatives on the ship, they have better chance to survive than others.<\/p>\n

Money, Money, Money<\/h3>\n

It is time to put passengers’ fare into our model learning routine, but:<\/p>\n

fare_dist = sns.distplot(train_df[\"Fare\"], color=\"m\", label=\"Skewness : %.2f\"%(train_df[\"Fare\"].skew()))\r\nfare_dist = fare_dist.legend(loc=\"best\")\r\nplt.show()\r\n<\/pre>\n

\"\"<\/p>\n

There are extreme values inside the “Fare” feature. On this case, we can use logarithm to remove the impact of extreme values.<\/p>\n

train_df[\"Fare\"] = train_df[\"Fare\"].fillna(train_df[\"Fare\"].median())\r\ntrain_df['Fare_log'] = train_df[\"Fare\"].map(lambda i: np.log(i) if i > 0 else 0)\r\n\r\nfare_log_dist = sns.distplot(train_df[\"Fare_log\"], color=\"m\", label=\"Skewness : %.2f\"%(train_df[\"Fare_log\"].skew()))\r\nfare_log_dist = fare_log_dist.legend(loc=\"best\")\r\nplt.show()\r\n<\/pre>\n

\"\"<\/p>\n

See? The skewness has been changed from 4.79 to 0.44!<\/p>\n

facet = sns.FacetGrid(train_df, hue=\"Survived\",aspect=4)\r\nfacet.map(sns.kdeplot,'Fare_log',shade= True)\r\nfacet.set(xlim=(0, train_df['Fare_log'].max()))\r\nfacet.add_legend()\r\n\r\nplt.show()  \r\n\r\nbins = (-1, 2, 2.68, 3.44, 10)\r\ngroup_names = [1,2,3,4]\r\ncategories = pd.cut(train_df['Fare_log'], bins, labels=group_names)\r\ntrain_df['FareGroup'] = categories\r\n<\/pre>\n

According to the fare_log facet grid graph, we cut the fare_log into 4 groups.<\/p>\n

\"\"<\/p>\n

We are almost done, let’s finish our last feature, the Age.<\/p>\n

For the Age feature in our training data set, there are 177 out of 891 missing values. First, we would like to know the correlation of age and other features by using a heat map.<\/p>\n

age_heat = sns.heatmap(train_df[[\"Age\",\"Sex\",\"SibSp\",\"Parch\",\"Pclass\",\"Embarked\"]].corr(),annot=True)\r\nplt.show()\u00a0\r\n<\/pre>\n

\"\"<\/p>\n

We find that “SibSp”, “Parch” and “Pclass” are relevant to “Age”. Thus, instead of filling those missing ages with the mean value, we should compare the ages of passengers with similar family sizes and classes. If no similar background is found, we fill the missing age with a random value between the mean value minus standard deviation and the mean value plus standard deviation.<\/p>\n

index_NaN_age = list(train_df[\"Age\"][train_df[\"Age\"].isnull()].index)\r\n   \r\nfor i in index_NaN_age :\r\n  age_mean = train_df[\"Age\"].mean()\r\n  age_std = train_df[\"Age\"].std()\r\n  age_pred_w_spc = train_df[\"Age\"][((train_df['SibSp'] == train_df.iloc[i][\"SibSp\"]) & (train_df['Parch'] == train_df.iloc[i][\"Parch\"]) & (train_df['Pclass'] == train_df.iloc[i][\"Pclass\"]))].mean()\r\n  age_pred_wo_spc = np.random.randint(age_mean - age_std, age_mean + age_std)\r\n    \r\n  if not np.isnan(age_pred_w_spc) :\r\n     train_df['Age'].iloc[i] = age_pred_w_spc\r\n  else :\r\n     train_df['Age'].iloc[i] = age_pred_wo_spc  \r\n<\/pre>\n

Now we have handled all non-numeric\/missing values, we can drop those unused features.<\/p>\n

X_learning = train_df.drop(['Name', 'Cabin', 'SibSp', 'Parch', 'Fare', 'Survived', 'Ticket', 'Fare_log', 'FamilySize', 'PassengerId'], axis=1)\r\nY_learning = train_df['Survived']\r\n<\/pre>\n

K-Fold Cross-Validation Time<\/h3>\n

Do you remember the K-Fold Cross Validation process on last post<\/a>? Yes, it is the process to choose a suitable learning model. We have our well formatted training data set, it is time to use it on the validation.<\/p>\n

random_state = 33\r\nmodels = []\r\nmodels.append((\"RFC\", RandomForestClassifier(random_state=random_state)) )\r\nmodels.append((\"ETC\", ExtraTreesClassifier(random_state=random_state)) )\r\nmodels.append((\"ADA\", AdaBoostClassifier(random_state=random_state)) )\r\nmodels.append((\"GBC\", GradientBoostingClassifier(random_state=random_state)) )\r\nmodels.append((\"SVC\", SVC(random_state=random_state)) )\r\nmodels.append((\"LoR\", LogisticRegression(random_state=random_state)) )\r\nmodels.append((\"LDA\", LinearDiscriminantAnalysis()) )\r\nmodels.append((\"QDA\", QuadraticDiscriminantAnalysis()) )\r\nmodels.append((\"DTC\", DecisionTreeClassifier(random_state=random_state)) )\r\nmodels.append((\"XGB\", xgb.XGBClassifier()) )\r\n<\/pre>\n

Please note that, other than popular classifier models from Scikit Learn library, I have added XGBoost Classifier (XGBoost) into the model list. XGBoost is a powerful boosting algorithm and always be chosen as a winning tool in data analysis competition.<\/p>\n

from sklearn import model_selection\r\n\r\nkfold = model_selection.KFold(n_splits=10)\r\n\r\nfor name, model in models:\r\n     #cross validation among models, score based on accuracy\r\n     cv_results = model_selection.cross_val_score(model, X_learning, Y_learning, scoring='accuracy', cv=kfold )\r\n     print(\"\\n[%s] Mean: %.8f Std. Dev.: %8f\" %(name, cv_results.mean(), cv_results.std()))   \r\n<\/pre>\n

And the results are:<\/p>\n

[RFC] Mean: 0.80365793 Std. Dev.: 0.033661\r\n\r\n[ETC] Mean: 0.78902622 Std. Dev.: 0.030693\r\n\r\n[ADA] Mean: 0.80585518 Std. Dev.: 0.032839\r\n\r\n[GBC] Mean: 0.82720350 Std. Dev.: 0.033126\r\n\r\n[SVC] Mean: 0.79242197 Std. Dev.: 0.047439\r\n\r\n[LoR] Mean: 0.80810237 Std. Dev.: 0.029757\r\n\r\n[LDA] Mean: 0.79574282 Std. Dev.: 0.034687\r\n\r\n[QDA] Mean: 0.79466916 Std. Dev.: 0.042005\r\n\r\n[DTC] Mean: 0.77669164 Std. Dev.: 0.026440\r\n\r\n[XGB] Mean: 0.83053683 Std. Dev.: 0.031099\r\n<\/pre>\n

In bar chart:
\n\"\"<\/p>\n

Obviously, XGBoost tops the K-Fold Cross Validation and it is followed by\u00a0the Gradient Boosting Classifier. (Oh, boosting algorithm rules the game this time)<\/p>\n

Since we are focusing on Data Wrangling this time not model tuning, I just use a plain XGBoost to predict the testing data set and submit to Kaggle. It gives me 0.78469 score.<\/p>\n

There is still room for improvement, I hope all of you can learn from this post and make a better model. Just remember, practice makes perfect, enjoy.<\/p>\n

 <\/p>\n

 <\/p>\n

The complete source can be found at\u00a0https:\/\/github.com\/codeastar\/kaggle_Titanic<\/a>\u00a0.<\/p>\n","protected":false},"excerpt":{"rendered":"

We have learnt how to select a machine learning model, it is time to study another Data Science topic from the Data Science Life Cycle — Data Collection. Yes, we do need to know how to collect data.\u00a0Unlike our Iris Classification\u00a0project, which its data set is well prepared. Sometimes, we need to prepare our own […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[18],"tags":[19,31,30,29,28],"class_list":["post-318","post","type-post","status-publish","format-standard","hentry","category-machine-learning","tag-data-science","tag-data-wrangling","tag-kaggle","tag-titanic","tag-xgboost"],"jetpack_publicize_connections":[],"yoast_head":"\nTitanic Survivors Dataset and Data Wrangling ⋆ Code A Star<\/title>\n<meta name=\"description\" content=\"We have learnt how to select a machine learning model, it is time to study another Data Science topic --- Data Wrangling.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codeastar.com\/data-wrangling\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Titanic Survivors Dataset and Data Wrangling ⋆ Code A Star\" \/>\n<meta property=\"og:description\" content=\"We have learnt how to select a machine learning model, it is time to study another Data Science topic --- Data Wrangling.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codeastar.com\/data-wrangling\/\" \/>\n<meta property=\"og:site_name\" content=\"Code A Star\" \/>\n<meta property=\"article:publisher\" content=\"codeastar\" \/>\n<meta property=\"article:author\" content=\"codeastar\" \/>\n<meta property=\"article:published_time\" content=\"2017-07-28T17:11:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png\" \/>\n<meta name=\"author\" content=\"Raven Hon\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codeastar\" \/>\n<meta name=\"twitter:site\" content=\"@codeastar\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Raven Hon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/\"},\"author\":{\"name\":\"Raven Hon\",\"@id\":\"https:\/\/www.codeastar.com\/#\/schema\/person\/832d202eb92a3d430097e88c6d0550bd\"},\"headline\":\"Titanic Survivors Dataset and Data Wrangling\",\"datePublished\":\"2017-07-28T17:11:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/\"},\"wordCount\":1093,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.codeastar.com\/#\/schema\/person\/832d202eb92a3d430097e88c6d0550bd\"},\"image\":{\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png\",\"keywords\":[\"Data Science\",\"Data Wrangling\",\"Kaggle\",\"Titanic\",\"XGBoost\"],\"articleSection\":[\"Learn Machine Learning\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.codeastar.com\/data-wrangling\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/\",\"url\":\"https:\/\/www.codeastar.com\/data-wrangling\/\",\"name\":\"Titanic Survivors Dataset and Data Wrangling ⋆ Code A Star\",\"isPartOf\":{\"@id\":\"https:\/\/www.codeastar.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png\",\"datePublished\":\"2017-07-28T17:11:41+00:00\",\"description\":\"We have learnt how to select a machine learning model, it is time to study another Data Science topic --- Data Wrangling.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.codeastar.com\/data-wrangling\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png?fit=968%2C593&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png?fit=968%2C593&ssl=1\",\"width\":968,\"height\":593},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.codeastar.com\/data-wrangling\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.codeastar.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Titanic Survivors Dataset and Data Wrangling\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.codeastar.com\/#website\",\"url\":\"https:\/\/www.codeastar.com\/\",\"name\":\"Code A Star\",\"description\":\"We don't wish upon a star, we code a star\",\"publisher\":{\"@id\":\"https:\/\/www.codeastar.com\/#\/schema\/person\/832d202eb92a3d430097e88c6d0550bd\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.codeastar.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.codeastar.com\/#\/schema\/person\/832d202eb92a3d430097e88c6d0550bd\",\"name\":\"Raven Hon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.codeastar.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/www.codeastar.com\/wp-content\/uploads\/2018\/08\/logo70.png?fit=70%2C70&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.codeastar.com\/wp-content\/uploads\/2018\/08\/logo70.png?fit=70%2C70&ssl=1\",\"width\":70,\"height\":70,\"caption\":\"Raven Hon\"},\"logo\":{\"@id\":\"https:\/\/www.codeastar.com\/#\/schema\/person\/image\/\"},\"description\":\"Raven Hon is\u00a0a 20 years+ veteran in information technology industry who has worked on various projects from console, web, game, banking and mobile applications in different sized companies.\",\"sameAs\":[\"https:\/\/www.codeastar.com\",\"codeastar\",\"https:\/\/x.com\/codeastar\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Titanic Survivors Dataset and Data Wrangling ⋆ Code A Star","description":"We have learnt how to select a machine learning model, it is time to study another Data Science topic --- Data Wrangling.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codeastar.com\/data-wrangling\/","og_locale":"en_US","og_type":"article","og_title":"Titanic Survivors Dataset and Data Wrangling ⋆ Code A Star","og_description":"We have learnt how to select a machine learning model, it is time to study another Data Science topic --- Data Wrangling.","og_url":"https:\/\/www.codeastar.com\/data-wrangling\/","og_site_name":"Code A Star","article_publisher":"codeastar","article_author":"codeastar","article_published_time":"2017-07-28T17:11:41+00:00","og_image":[{"url":"https:\/\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png","type":"","width":"","height":""}],"author":"Raven Hon","twitter_card":"summary_large_image","twitter_creator":"@codeastar","twitter_site":"@codeastar","twitter_misc":{"Written by":"Raven Hon","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codeastar.com\/data-wrangling\/#article","isPartOf":{"@id":"https:\/\/www.codeastar.com\/data-wrangling\/"},"author":{"name":"Raven Hon","@id":"https:\/\/www.codeastar.com\/#\/schema\/person\/832d202eb92a3d430097e88c6d0550bd"},"headline":"Titanic Survivors Dataset and Data Wrangling","datePublished":"2017-07-28T17:11:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codeastar.com\/data-wrangling\/"},"wordCount":1093,"commentCount":0,"publisher":{"@id":"https:\/\/www.codeastar.com\/#\/schema\/person\/832d202eb92a3d430097e88c6d0550bd"},"image":{"@id":"https:\/\/www.codeastar.com\/data-wrangling\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png","keywords":["Data Science","Data Wrangling","Kaggle","Titanic","XGBoost"],"articleSection":["Learn Machine Learning"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codeastar.com\/data-wrangling\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codeastar.com\/data-wrangling\/","url":"https:\/\/www.codeastar.com\/data-wrangling\/","name":"Titanic Survivors Dataset and Data Wrangling ⋆ Code A Star","isPartOf":{"@id":"https:\/\/www.codeastar.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codeastar.com\/data-wrangling\/#primaryimage"},"image":{"@id":"https:\/\/www.codeastar.com\/data-wrangling\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png","datePublished":"2017-07-28T17:11:41+00:00","description":"We have learnt how to select a machine learning model, it is time to study another Data Science topic --- Data Wrangling.","breadcrumb":{"@id":"https:\/\/www.codeastar.com\/data-wrangling\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codeastar.com\/data-wrangling\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codeastar.com\/data-wrangling\/#primaryimage","url":"https:\/\/i0.wp.com\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png?fit=968%2C593&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.codeastar.com\/wp-content\/uploads\/2017\/07\/data_wrangler.png?fit=968%2C593&ssl=1","width":968,"height":593},{"@type":"BreadcrumbList","@id":"https:\/\/www.codeastar.com\/data-wrangling\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codeastar.com\/"},{"@type":"ListItem","position":2,"name":"Titanic Survivors Dataset and Data Wrangling"}]},{"@type":"WebSite","@id":"https:\/\/www.codeastar.com\/#website","url":"https:\/\/www.codeastar.com\/","name":"Code A Star","description":"We don't wish upon a star, we code a star","publisher":{"@id":"https:\/\/www.codeastar.com\/#\/schema\/person\/832d202eb92a3d430097e88c6d0550bd"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codeastar.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.codeastar.com\/#\/schema\/person\/832d202eb92a3d430097e88c6d0550bd","name":"Raven Hon","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codeastar.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/www.codeastar.com\/wp-content\/uploads\/2018\/08\/logo70.png?fit=70%2C70&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.codeastar.com\/wp-content\/uploads\/2018\/08\/logo70.png?fit=70%2C70&ssl=1","width":70,"height":70,"caption":"Raven Hon"},"logo":{"@id":"https:\/\/www.codeastar.com\/#\/schema\/person\/image\/"},"description":"Raven Hon is\u00a0a 20 years+ veteran in information technology industry who has worked on various projects from console, web, game, banking and mobile applications in different sized companies.","sameAs":["https:\/\/www.codeastar.com","codeastar","https:\/\/x.com\/codeastar"]}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8PcRO-58","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/posts\/318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/comments?post=318"}],"version-history":[{"count":41,"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/posts\/318\/revisions"}],"predecessor-version":[{"id":379,"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/posts\/318\/revisions\/379"}],"wp:attachment":[{"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/media?parent=318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/categories?post=318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codeastar.com\/wp-json\/wp\/v2\/tags?post=318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}