{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "175d61aa-1a5f-0457-398b-f6cd16ba96ec"
      },
      "outputs": [],
      "source": [
        "\n",
        "# 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",
        "\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",
        "from sklearn.base import BaseEstimator, ClassifierMixin\n",
        "from sklearn.utils.validation import check_X_y, check_array, check_is_fitted\n",
        "from sklearn.utils.multiclass import unique_labels\n",
        "from sklearn.metrics import euclidean_distances\n",
        "\n",
        "from sklearn.utils import resample\n",
        "\n",
        "def main():\n",
        "    #docs = check_output([\"ls\", \"../input\"]).decode(\"utf8\")\n",
        "    clicks_train = pd.read_csv(\"../input/clicks_train.csv\")\n",
        "    print(\"Imported training data\")\n",
        "    clicks_test = pd.read_csv(\"../input/clicks_test.csv\")\n",
        "    print(\"Imported testing data\")\n",
        "    \n",
        "    train_X = clicks_train [[\"display_id\", \"ad_id\"]].DataFrame.as_matrix\n",
        "    train_y = clicks_train [[\"clicked\"]].DataFrame.as_matrix\n",
        "    \n",
        "    test_X = clicks_test [[\"display_id\", \"ad_id\"]].DataFrame.as_matrix\n",
        "    test_y = clicks_test [[\"clicked\"]].DataFrame.as_matrix\n",
        "    \n",
        "    h = HyperForest ()\n",
        "    h.fit ()\n",
        "\n",
        "# Any results you write to the current directory are saved as output."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "8d17b9af-015f-2323-7270-945aadc12d3d"
      },
      "outputs": [],
      "source": [
        "class HyperForest (BaseEstimator, ClassifierMixin):\n",
        "    trees = []\n",
        "    def __init__(self):\n",
        "        pass\n",
        "    \n",
        "    def fit(self, X, y):\n",
        "        X, y = check_X_y (X, y)\n",
        "        for _ in range(100):\n",
        "            X_b, y_b = resample(X, y, replace=True)\n",
        "            \n",
        "            h = HyperTree ()\n",
        "            h.fit (X_b, y_b)\n",
        "            trees += [h]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "a6b0f53f-ce0e-368c-d6af-1b185110799d"
      },
      "outputs": [],
      "source": [
        "    def __init__(self, demo_param='demo'):\n",
        "        self.demo_param = demo_param\n",
        "    \n",
        "    def fit(self, X, y):\n",
        "        X, y = check_X_y(X, y)\n",
        "        self.classes_ = unique_labels(y)\n",
        "        return self\n",
        "    \n",
        "    def predict (self, X):\n",
        "        return self.classes_ [0]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "cdf642b5-b8fe-ccec-f69b-7dc89d2ed4e6"
      },
      "outputs": [],
      "source": [
        "if __name__ == \"__main__\": main()"
      ]
    }
  ],
  "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
}