{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "a7f97f79-1634-2940-11e6-4f1fb25fccea"
      },
      "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.ensemble import ExtraTreesClassifier\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",
        "print(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n",
        "\n",
        "# Any results you write to the current directory are saved as output."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "08f88f6c-1d40-910c-781a-66ad096e9d3b"
      },
      "outputs": [],
      "source": [
        "#train_categorical=pd.read_csv(\"../input/train_categorical.csv\", nrows=1000)\n",
        "#train_date=pd.read_csv(\"../input/train_date.csv\", nrows=1000)\n",
        "train_numeric_all=pd.read_csv(\"../input/train_numeric.csv\",nrows=10000)\n",
        "split_index = np.random.rand(len(train_numeric_all)) < 0.8\n",
        "train_numeric=train_numeric_all[split_index]\n",
        "train_numeric_valid=train_numeric_all[~split_index]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "1eb3e694-6dce-e359-2ec7-b4211a55d1f8"
      },
      "outputs": [],
      "source": [
        "train_numeric.fillna(value = -99, inplace = True)\n",
        "    \n",
        "id_train = train_numeric['Id']\n",
        "ytrain = train_numeric['Response']\n",
        "train_numeric.drop(['Id', 'Response'], axis = 1, inplace = True)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "60b9b12e-a133-046d-1b28-a6ec0a6abeef"
      },
      "outputs": [],
      "source": [
        "clf = ExtraTreesClassifier(n_estimators = 50, n_jobs = -1,\n",
        "                                   min_samples_leaf = 10, verbose = 1)\n",
        "clf.fit(xtrain, ytrain)                                   \n",
        "    \n",
        "test_nummeric = pd.read_csv('../input/test_numeric.csv')\n",
        "test_nummeric.fillna(value = -99, inplace = True)\n",
        "    \n",
        "id_test = test_nummeric['Id']\n",
        "test_nummeric.drop(['Id'], axis = 1, inplace = True)\n",
        "    \n",
        "pred = clf.predict_proba(test_nummeric)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "46913328-f689-0617-2730-cdc1d0c7d5d1"
      },
      "outputs": [],
      "source": [
        "bosch_result=pd.DataFrame({'Id':id_test,\n",
        "                           'Response':pred})\n",
        "bosch_result.to_csv('bosch_result.csv', index = False)"
      ]
    }
  ],
  "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.5.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}