{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"_cell_guid": "881c55fd-3b61-de77-7963-190298f11b66",
"_uuid": "3668ab7cd3e8c4788fe6fe26b5848b6089cde62b"
},
"source": [
"[](http://www.analyticsdojo.com)\n",
"
Introduction to R - Titanic Baseline
\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"_cell_guid": "e4366588-27f9-a4e3-4d02-1b660e1fd226",
"_uuid": "2c7461c172401b7654f874b6de16b6c6b4d41a6e"
},
"source": [
"## Running Code using Kaggle Notebooks\n",
"- Kaggle utilizes Docker to create a fully functional environment for hosting competitions in data science.\n",
"- You could download/run kaggle/python docker image from [GitHub](https://github.com/kaggle/docker-python) and run it as an alternative to the standard Jupyter Stack for Data Science we have been using.\n",
"- Kaggle has created an incredible resource for learning analytics. You can view a number of *toy* examples that can be used to understand data science and also compete in real problems faced by top companies. "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"_cell_guid": "193191ca-9119-56cb-1133-3c356f2300ad",
"_uuid": "3448fcc64b74a564cc35f7d9586e75e853b84642",
"collapsed": true
},
"outputs": [],
"source": [
"train <- read.csv('../../input/train.csv', stringsAsFactors = F)\n",
"test <- read.csv('../../input/test.csv', stringsAsFactors = F)"
]
},
{
"cell_type": "markdown",
"metadata": {
"_cell_guid": "21a68add-20c7-984a-7cb3-a21c0dd80cb0",
"_uuid": "a2ba10a5bb516a208de6e6c7a20fdab86089ab4a"
},
"source": [
"## `train` and `test` set on Kaggle\n",
"- The `train` file contains a wide variety of information that might be useful in understanding whether they survived or not. It also includes a record as to whether they survived or not.\n",
"- The `test` file contains all of the columns of the first file except whether they survived. Our goal is to predict whether the individuals survived."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"_cell_guid": "d12daf5f-88c7-2f45-e106-4052d23c0a0d",
"_uuid": "21b04f0aaa9cfa11948db6c185f2225cba86a718"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |
\n",
"\n",
"\t1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.2500 | | S |
\n",
"\t2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C |
\n",
"\t3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.9250 | | S |
\n",
"\t4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1000 | C123 | S |
\n",
"\t5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.0500 | | S |
\n",
"\t6 | 0 | 3 | Moran, Mr. James | male | NA | 0 | 0 | 330877 | 8.4583 | | Q |
\n",
"\n",
"
\n"
],
"text/latex": [
"\\begin{tabular}{r|llllllllllll}\n",
" PassengerId & Survived & Pclass & Name & Sex & Age & SibSp & Parch & Ticket & Fare & Cabin & Embarked\\\\\n",
"\\hline\n",
"\t 1 & 0 & 3 & Braund, Mr. Owen Harris & male & 22 & 1 & 0 & A/5 21171 & 7.2500 & & S \\\\\n",
"\t 2 & 1 & 1 & Cumings, Mrs. John Bradley (Florence Briggs Thayer) & female & 38 & 1 & 0 & PC 17599 & 71.2833 & C85 & C \\\\\n",
"\t 3 & 1 & 3 & Heikkinen, Miss. Laina & female & 26 & 0 & 0 & STON/O2. 3101282 & 7.9250 & & S \\\\\n",
"\t 4 & 1 & 1 & Futrelle, Mrs. Jacques Heath (Lily May Peel) & female & 35 & 1 & 0 & 113803 & 53.1000 & C123 & S \\\\\n",
"\t 5 & 0 & 3 & Allen, Mr. William Henry & male & 35 & 0 & 0 & 373450 & 8.0500 & & S \\\\\n",
"\t 6 & 0 & 3 & Moran, Mr. James & male & NA & 0 & 0 & 330877 & 8.4583 & & Q \\\\\n",
"\\end{tabular}\n"
],
"text/markdown": [
"\n",
"PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked | \n",
"|---|---|---|---|---|---|\n",
"| 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.2500 | | S | \n",
"| 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C | \n",
"| 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.9250 | | S | \n",
"| 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1000 | C123 | S | \n",
"| 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.0500 | | S | \n",
"| 6 | 0 | 3 | Moran, Mr. James | male | NA | 0 | 0 | 330877 | 8.4583 | | Q | \n",
"\n",
"\n"
],
"text/plain": [
" PassengerId Survived Pclass\n",
"1 1 0 3 \n",
"2 2 1 1 \n",
"3 3 1 3 \n",
"4 4 1 1 \n",
"5 5 0 3 \n",
"6 6 0 3 \n",
" Name Sex Age SibSp Parch\n",
"1 Braund, Mr. Owen Harris male 22 1 0 \n",
"2 Cumings, Mrs. John Bradley (Florence Briggs Thayer) female 38 1 0 \n",
"3 Heikkinen, Miss. Laina female 26 0 0 \n",
"4 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35 1 0 \n",
"5 Allen, Mr. William Henry male 35 0 0 \n",
"6 Moran, Mr. James male NA 0 0 \n",
" Ticket Fare Cabin Embarked\n",
"1 A/5 21171 7.2500 S \n",
"2 PC 17599 71.2833 C85 C \n",
"3 STON/O2. 3101282 7.9250 S \n",
"4 113803 53.1000 C123 S \n",
"5 373450 8.0500 S \n",
"6 330877 8.4583 Q "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"head(train)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"_cell_guid": "17dca1d6-ac00-2342-bfa9-00739d8b2255",
"_uuid": "92fbe1534e780db62d5d81ddb356fd5b45ba166a"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"PassengerId | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |
\n",
"\n",
"\t892 | 3 | Kelly, Mr. James | male | 34.5 | 0 | 0 | 330911 | 7.8292 | | Q |
\n",
"\t893 | 3 | Wilkes, Mrs. James (Ellen Needs) | female | 47.0 | 1 | 0 | 363272 | 7.0000 | | S |
\n",
"\t894 | 2 | Myles, Mr. Thomas Francis | male | 62.0 | 0 | 0 | 240276 | 9.6875 | | Q |
\n",
"\t895 | 3 | Wirz, Mr. Albert | male | 27.0 | 0 | 0 | 315154 | 8.6625 | | S |
\n",
"\t896 | 3 | Hirvonen, Mrs. Alexander (Helga E Lindqvist) | female | 22.0 | 1 | 1 | 3101298 | 12.2875 | | S |
\n",
"\t897 | 3 | Svensson, Mr. Johan Cervin | male | 14.0 | 0 | 0 | 7538 | 9.2250 | | S |
\n",
"\n",
"
\n"
],
"text/latex": [
"\\begin{tabular}{r|lllllllllll}\n",
" PassengerId & Pclass & Name & Sex & Age & SibSp & Parch & Ticket & Fare & Cabin & Embarked\\\\\n",
"\\hline\n",
"\t 892 & 3 & Kelly, Mr. James & male & 34.5 & 0 & 0 & 330911 & 7.8292 & & Q \\\\\n",
"\t 893 & 3 & Wilkes, Mrs. James (Ellen Needs) & female & 47.0 & 1 & 0 & 363272 & 7.0000 & & S \\\\\n",
"\t 894 & 2 & Myles, Mr. Thomas Francis & male & 62.0 & 0 & 0 & 240276 & 9.6875 & & Q \\\\\n",
"\t 895 & 3 & Wirz, Mr. Albert & male & 27.0 & 0 & 0 & 315154 & 8.6625 & & S \\\\\n",
"\t 896 & 3 & Hirvonen, Mrs. Alexander (Helga E Lindqvist) & female & 22.0 & 1 & 1 & 3101298 & 12.2875 & & S \\\\\n",
"\t 897 & 3 & Svensson, Mr. Johan Cervin & male & 14.0 & 0 & 0 & 7538 & 9.2250 & & S \\\\\n",
"\\end{tabular}\n"
],
"text/markdown": [
"\n",
"PassengerId | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked | \n",
"|---|---|---|---|---|---|\n",
"| 892 | 3 | Kelly, Mr. James | male | 34.5 | 0 | 0 | 330911 | 7.8292 | | Q | \n",
"| 893 | 3 | Wilkes, Mrs. James (Ellen Needs) | female | 47.0 | 1 | 0 | 363272 | 7.0000 | | S | \n",
"| 894 | 2 | Myles, Mr. Thomas Francis | male | 62.0 | 0 | 0 | 240276 | 9.6875 | | Q | \n",
"| 895 | 3 | Wirz, Mr. Albert | male | 27.0 | 0 | 0 | 315154 | 8.6625 | | S | \n",
"| 896 | 3 | Hirvonen, Mrs. Alexander (Helga E Lindqvist) | female | 22.0 | 1 | 1 | 3101298 | 12.2875 | | S | \n",
"| 897 | 3 | Svensson, Mr. Johan Cervin | male | 14.0 | 0 | 0 | 7538 | 9.2250 | | S | \n",
"\n",
"\n"
],
"text/plain": [
" PassengerId Pclass Name Sex Age \n",
"1 892 3 Kelly, Mr. James male 34.5\n",
"2 893 3 Wilkes, Mrs. James (Ellen Needs) female 47.0\n",
"3 894 2 Myles, Mr. Thomas Francis male 62.0\n",
"4 895 3 Wirz, Mr. Albert male 27.0\n",
"5 896 3 Hirvonen, Mrs. Alexander (Helga E Lindqvist) female 22.0\n",
"6 897 3 Svensson, Mr. Johan Cervin male 14.0\n",
" SibSp Parch Ticket Fare Cabin Embarked\n",
"1 0 0 330911 7.8292 Q \n",
"2 1 0 363272 7.0000 S \n",
"3 0 0 240276 9.6875 Q \n",
"4 0 0 315154 8.6625 S \n",
"5 1 1 3101298 12.2875 S \n",
"6 0 0 7538 9.2250 S "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"head(test)"
]
},
{
"cell_type": "markdown",
"metadata": {
"_cell_guid": "4de42a6c-db16-edd8-cdb5-46f5f47698f7",
"_uuid": "b68939ee570989916c489bffde89d2a857b6923a"
},
"source": [
"## Baseline Model: No Survivors\n",
"- The Titanic problem is one of classification, and often the simplest baseline of all 0/1 is an appropriate baseline.\n",
"- Even if you aren't familiar with the history of the tragedy, by checking out the [Wikipedia Page](https://en.wikipedia.org/wiki/RMS_Titanic) we can quickly see that the majority of people (68%) died.\n",
"- As a result, our baseline model will be for no survivors."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"_cell_guid": "bcff150d-cbff-3c84-3eea-564df3c43b7b",
"_uuid": "4bb023cb116910bb2121c7f356d4e57de4b3ffa2",
"collapsed": true
},
"outputs": [],
"source": [
"test[\"Survived\"] <- 0"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"_cell_guid": "6c95627c-c1eb-aa34-f4b7-32b8ea7ae61c",
"_uuid": "822074cd1a3eda10ddcb994287f9986cae917933",
"collapsed": true
},
"outputs": [],
"source": [
"submission <- test[,c(\"PassengerId\", \"Survived\")]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"_cell_guid": "2241735d-8164-32f2-94ec-6ec45dacb145",
"_uuid": "9c494660e043f9774f099ceeb405dfa8d37e1e70"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"PassengerId | Survived |
\n",
"\n",
"\t892 | 0 |
\n",
"\t893 | 0 |
\n",
"\t894 | 0 |
\n",
"\t895 | 0 |
\n",
"\t896 | 0 |
\n",
"\t897 | 0 |
\n",
"\n",
"
\n"
],
"text/latex": [
"\\begin{tabular}{r|ll}\n",
" PassengerId & Survived\\\\\n",
"\\hline\n",
"\t 892 & 0 \\\\\n",
"\t 893 & 0 \\\\\n",
"\t 894 & 0 \\\\\n",
"\t 895 & 0 \\\\\n",
"\t 896 & 0 \\\\\n",
"\t 897 & 0 \\\\\n",
"\\end{tabular}\n"
],
"text/markdown": [
"\n",
"PassengerId | Survived | \n",
"|---|---|---|---|---|---|\n",
"| 892 | 0 | \n",
"| 893 | 0 | \n",
"| 894 | 0 | \n",
"| 895 | 0 | \n",
"| 896 | 0 | \n",
"| 897 | 0 | \n",
"\n",
"\n"
],
"text/plain": [
" PassengerId Survived\n",
"1 892 0 \n",
"2 893 0 \n",
"3 894 0 \n",
"4 895 0 \n",
"5 896 0 \n",
"6 897 0 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"head(submission)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"_cell_guid": "1329809f-7aed-c67e-383c-8d71e5c7c4ac",
"_uuid": "26f53c7376bea4297903b499776401d3b240cd74",
"collapsed": true
},
"outputs": [],
"source": [
"# Write the solution to file\n",
"write.csv(submission, file = 'nosurvivors.csv', row.names = F)"
]
},
{
"cell_type": "markdown",
"metadata": {
"_cell_guid": "325683d2-2aa7-96a9-45ec-edf46c69f2da",
"_uuid": "09f9eb8927ddb8bbee7b55103b707953e925c7f1"
},
"source": [
"## The First Rule of Shipwrecks\n",
"- You may have seen it in a movie or read it in a novel, but [women and children first](https://en.wikipedia.org/wiki/Women_and_children_first) has at it's roots something that could provide our first model.\n",
"- Now let's recode the `Survived` column based on whether was a man or a woman. \n",
"- We are using conditionals to *select* rows of interest (for example, where test['Sex'] == 'male') and recoding appropriate columns."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"_cell_guid": "710483a5-7a49-a018-610a-c0968c44479c",
"_uuid": "8b279e9be63feaf0bb5b946e3d32cd752b195e7f",
"collapsed": true
},
"outputs": [],
"source": [
"#Here we can code it as Survived, but if we do so we will overwrite our other prediction. \n",
"#Instead, let's code it as PredGender\n",
"\n",
"test[test$Sex == \"male\", \"PredGender\"] <- 0\n",
"test[test$Sex == \"female\", \"PredGender\"] <- 1"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"_cell_guid": "078e3827-8f89-59ae-ca2d-66fa36bc79eb",
"_uuid": "c0a65b6956267bf39b847741501dde9a30f22272"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"PassengerId | Survived |
\n",
"\n",
"\t892 | 0 |
\n",
"\t893 | 1 |
\n",
"\t894 | 0 |
\n",
"\t895 | 0 |
\n",
"\t896 | 1 |
\n",
"\t897 | 0 |
\n",
"\n",
"
\n"
],
"text/latex": [
"\\begin{tabular}{r|ll}\n",
" PassengerId & Survived\\\\\n",
"\\hline\n",
"\t 892 & 0 \\\\\n",
"\t 893 & 1 \\\\\n",
"\t 894 & 0 \\\\\n",
"\t 895 & 0 \\\\\n",
"\t 896 & 1 \\\\\n",
"\t 897 & 0 \\\\\n",
"\\end{tabular}\n"
],
"text/markdown": [
"\n",
"PassengerId | Survived | \n",
"|---|---|---|---|---|---|\n",
"| 892 | 0 | \n",
"| 893 | 1 | \n",
"| 894 | 0 | \n",
"| 895 | 0 | \n",
"| 896 | 1 | \n",
"| 897 | 0 | \n",
"\n",
"\n"
],
"text/plain": [
" PassengerId Survived\n",
"1 892 0 \n",
"2 893 1 \n",
"3 894 0 \n",
"4 895 0 \n",
"5 896 1 \n",
"6 897 0 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"submission = test[,c(\"PassengerId\", \"PredGender\")]\n",
"#This will Rename the survived column\n",
"names(submission)[2] <- \"Survived\"\n",
"head(submission)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"PassengerId | new |
\n",
"\n",
"\t892 | 0 |
\n",
"\t893 | 1 |
\n",
"\t894 | 0 |
\n",
"\t895 | 0 |
\n",
"\t896 | 1 |
\n",
"\t897 | 0 |
\n",
"\t898 | 1 |
\n",
"\t899 | 0 |
\n",
"\t900 | 1 |
\n",
"\t901 | 0 |
\n",
"\t902 | 0 |
\n",
"\t903 | 0 |
\n",
"\t904 | 1 |
\n",
"\t905 | 0 |
\n",
"\t906 | 1 |
\n",
"\t907 | 1 |
\n",
"\t908 | 0 |
\n",
"\t909 | 0 |
\n",
"\t910 | 1 |
\n",
"\t911 | 1 |
\n",
"\t912 | 0 |
\n",
"\t913 | 0 |
\n",
"\t914 | 1 |
\n",
"\t915 | 0 |
\n",
"\t916 | 1 |
\n",
"\t917 | 0 |
\n",
"\t918 | 1 |
\n",
"\t919 | 0 |
\n",
"\t920 | 0 |
\n",
"\t921 | 0 |
\n",
"\t⋮ | ⋮ |
\n",
"\t1280 | 0 |
\n",
"\t1281 | 0 |
\n",
"\t1282 | 0 |
\n",
"\t1283 | 1 |
\n",
"\t1284 | 0 |
\n",
"\t1285 | 0 |
\n",
"\t1286 | 0 |
\n",
"\t1287 | 1 |
\n",
"\t1288 | 0 |
\n",
"\t1289 | 1 |
\n",
"\t1290 | 0 |
\n",
"\t1291 | 0 |
\n",
"\t1292 | 1 |
\n",
"\t1293 | 0 |
\n",
"\t1294 | 1 |
\n",
"\t1295 | 0 |
\n",
"\t1296 | 0 |
\n",
"\t1297 | 0 |
\n",
"\t1298 | 0 |
\n",
"\t1299 | 0 |
\n",
"\t1300 | 1 |
\n",
"\t1301 | 1 |
\n",
"\t1302 | 1 |
\n",
"\t1303 | 1 |
\n",
"\t1304 | 1 |
\n",
"\t1305 | 0 |
\n",
"\t1306 | 1 |
\n",
"\t1307 | 0 |
\n",
"\t1308 | 0 |
\n",
"\t1309 | 0 |
\n",
"\n",
"
\n"
],
"text/latex": [
"\\begin{tabular}{r|ll}\n",
" PassengerId & new\\\\\n",
"\\hline\n",
"\t 892 & 0 \\\\\n",
"\t 893 & 1 \\\\\n",
"\t 894 & 0 \\\\\n",
"\t 895 & 0 \\\\\n",
"\t 896 & 1 \\\\\n",
"\t 897 & 0 \\\\\n",
"\t 898 & 1 \\\\\n",
"\t 899 & 0 \\\\\n",
"\t 900 & 1 \\\\\n",
"\t 901 & 0 \\\\\n",
"\t 902 & 0 \\\\\n",
"\t 903 & 0 \\\\\n",
"\t 904 & 1 \\\\\n",
"\t 905 & 0 \\\\\n",
"\t 906 & 1 \\\\\n",
"\t 907 & 1 \\\\\n",
"\t 908 & 0 \\\\\n",
"\t 909 & 0 \\\\\n",
"\t 910 & 1 \\\\\n",
"\t 911 & 1 \\\\\n",
"\t 912 & 0 \\\\\n",
"\t 913 & 0 \\\\\n",
"\t 914 & 1 \\\\\n",
"\t 915 & 0 \\\\\n",
"\t 916 & 1 \\\\\n",
"\t 917 & 0 \\\\\n",
"\t 918 & 1 \\\\\n",
"\t 919 & 0 \\\\\n",
"\t 920 & 0 \\\\\n",
"\t 921 & 0 \\\\\n",
"\t ⋮ & ⋮\\\\\n",
"\t 1280 & 0 \\\\\n",
"\t 1281 & 0 \\\\\n",
"\t 1282 & 0 \\\\\n",
"\t 1283 & 1 \\\\\n",
"\t 1284 & 0 \\\\\n",
"\t 1285 & 0 \\\\\n",
"\t 1286 & 0 \\\\\n",
"\t 1287 & 1 \\\\\n",
"\t 1288 & 0 \\\\\n",
"\t 1289 & 1 \\\\\n",
"\t 1290 & 0 \\\\\n",
"\t 1291 & 0 \\\\\n",
"\t 1292 & 1 \\\\\n",
"\t 1293 & 0 \\\\\n",
"\t 1294 & 1 \\\\\n",
"\t 1295 & 0 \\\\\n",
"\t 1296 & 0 \\\\\n",
"\t 1297 & 0 \\\\\n",
"\t 1298 & 0 \\\\\n",
"\t 1299 & 0 \\\\\n",
"\t 1300 & 1 \\\\\n",
"\t 1301 & 1 \\\\\n",
"\t 1302 & 1 \\\\\n",
"\t 1303 & 1 \\\\\n",
"\t 1304 & 1 \\\\\n",
"\t 1305 & 0 \\\\\n",
"\t 1306 & 1 \\\\\n",
"\t 1307 & 0 \\\\\n",
"\t 1308 & 0 \\\\\n",
"\t 1309 & 0 \\\\\n",
"\\end{tabular}\n"
],
"text/markdown": [
"\n",
"PassengerId | new | \n",
"|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n",
"| 892 | 0 | \n",
"| 893 | 1 | \n",
"| 894 | 0 | \n",
"| 895 | 0 | \n",
"| 896 | 1 | \n",
"| 897 | 0 | \n",
"| 898 | 1 | \n",
"| 899 | 0 | \n",
"| 900 | 1 | \n",
"| 901 | 0 | \n",
"| 902 | 0 | \n",
"| 903 | 0 | \n",
"| 904 | 1 | \n",
"| 905 | 0 | \n",
"| 906 | 1 | \n",
"| 907 | 1 | \n",
"| 908 | 0 | \n",
"| 909 | 0 | \n",
"| 910 | 1 | \n",
"| 911 | 1 | \n",
"| 912 | 0 | \n",
"| 913 | 0 | \n",
"| 914 | 1 | \n",
"| 915 | 0 | \n",
"| 916 | 1 | \n",
"| 917 | 0 | \n",
"| 918 | 1 | \n",
"| 919 | 0 | \n",
"| 920 | 0 | \n",
"| 921 | 0 | \n",
"| ⋮ | ⋮ | \n",
"| 1280 | 0 | \n",
"| 1281 | 0 | \n",
"| 1282 | 0 | \n",
"| 1283 | 1 | \n",
"| 1284 | 0 | \n",
"| 1285 | 0 | \n",
"| 1286 | 0 | \n",
"| 1287 | 1 | \n",
"| 1288 | 0 | \n",
"| 1289 | 1 | \n",
"| 1290 | 0 | \n",
"| 1291 | 0 | \n",
"| 1292 | 1 | \n",
"| 1293 | 0 | \n",
"| 1294 | 1 | \n",
"| 1295 | 0 | \n",
"| 1296 | 0 | \n",
"| 1297 | 0 | \n",
"| 1298 | 0 | \n",
"| 1299 | 0 | \n",
"| 1300 | 1 | \n",
"| 1301 | 1 | \n",
"| 1302 | 1 | \n",
"| 1303 | 1 | \n",
"| 1304 | 1 | \n",
"| 1305 | 0 | \n",
"| 1306 | 1 | \n",
"| 1307 | 0 | \n",
"| 1308 | 0 | \n",
"| 1309 | 0 | \n",
"\n",
"\n"
],
"text/plain": [
" PassengerId new\n",
"1 892 0 \n",
"2 893 1 \n",
"3 894 0 \n",
"4 895 0 \n",
"5 896 1 \n",
"6 897 0 \n",
"7 898 1 \n",
"8 899 0 \n",
"9 900 1 \n",
"10 901 0 \n",
"11 902 0 \n",
"12 903 0 \n",
"13 904 1 \n",
"14 905 0 \n",
"15 906 1 \n",
"16 907 1 \n",
"17 908 0 \n",
"18 909 0 \n",
"19 910 1 \n",
"20 911 1 \n",
"21 912 0 \n",
"22 913 0 \n",
"23 914 1 \n",
"24 915 0 \n",
"25 916 1 \n",
"26 917 0 \n",
"27 918 1 \n",
"28 919 0 \n",
"29 920 0 \n",
"30 921 0 \n",
"⋮ ⋮ ⋮ \n",
"389 1280 0 \n",
"390 1281 0 \n",
"391 1282 0 \n",
"392 1283 1 \n",
"393 1284 0 \n",
"394 1285 0 \n",
"395 1286 0 \n",
"396 1287 1 \n",
"397 1288 0 \n",
"398 1289 1 \n",
"399 1290 0 \n",
"400 1291 0 \n",
"401 1292 1 \n",
"402 1293 0 \n",
"403 1294 1 \n",
"404 1295 0 \n",
"405 1296 0 \n",
"406 1297 0 \n",
"407 1298 0 \n",
"408 1299 0 \n",
"409 1300 1 \n",
"410 1301 1 \n",
"411 1302 1 \n",
"412 1303 1 \n",
"413 1304 1 \n",
"414 1305 0 \n",
"415 1306 1 \n",
"416 1307 0 \n",
"417 1308 0 \n",
"418 1309 0 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"names(submission)[2]<-\"new\"\n",
"submission"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"_cell_guid": "9f63501b-df2a-0d41-d4dd-3d0e28fea743",
"_uuid": "b0d72f03f864bde6cd405e1bcda795c74764ccf4",
"collapsed": true
},
"outputs": [],
"source": [
"write.csv(submission, file = 'womensurvive.csv', row.names = F)"
]
}
],
"metadata": {
"_change_revision": 0,
"_is_fork": false,
"anaconda-cloud": {},
"kernelspec": {
"display_name": "R",
"language": "R",
"name": "ir"
},
"language_info": {
"codemirror_mode": "r",
"file_extension": ".r",
"mimetype": "text/x-r-source",
"name": "R",
"pygments_lexer": "r",
"version": "3.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}