{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "ddc2c842-7c10-436e-534d-44c3c1cc8b58"
      },
      "source": [
        "Titanic Blues"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "ad2918d0-003d-f829-4989-8ceeb933a20c"
      },
      "outputs": [],
      "source": [
        "# This Python 3 environment comes with many helpful analytics libraries installed\n",
        "# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n",
        "# For example, here's several helpful packages to load in \n",
        "\n",
        "import numpy as np # linear algebra\n",
        "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n",
        "from sklearn import tree\n",
        "\n",
        "# Input data files are available in the \"../input/\" directory.\n",
        "# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n",
        "\n",
        "from subprocess import check_output\n",
        "\n",
        "#print(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n",
        "#names = ['PassengerID', 'Survived']\n",
        "df_train = pd.read_csv(\"../input/train.csv\", usecols = ['Pclass', 'Sex', 'Survived'])\n",
        "\n",
        "df_train['Sex'] = df_train['Sex'].replace(['male'], 0)\n",
        "df_train['Sex'] = df_train['Sex'].replace(['female'], 1)\n",
        "#df_train.fillna(-1)\n",
        "array_train = df_train.as_matrix()\n",
        "clf = tree.DecisionTreeClassifier()\n",
        "#print (array_train[:,:1])\n",
        "#print (array_train[:,(1,2,3)])\n",
        "clf = clf.fit(array_train[:,(1,2)], array_train[:,:1])\n",
        "\n",
        "# Any results you write to the current directory are saved as output.\n",
        "df_test = pd.read_csv(\"../input/test.csv\", usecols = ['Pclass', 'Sex'])\n",
        "df_test.fillna(-1)\n",
        "df_test['Sex'] = df_test['Sex'].replace(['male'], 0)\n",
        "df_test['Sex'] = df_test['Sex'].replace(['female'], 1)\n",
        "\n",
        "array_test = df_test.as_matrix()\n",
        "print(clf.predict(array_test[:,(0,1)]) )"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "1d14a9cc-0e02-d20a-da55-d84da068cc2d"
      },
      "outputs": [],
      "source": ""
    }
  ],
  "metadata": {
    "_change_revision": 0,
    "_is_fork": false,
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}