{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "352f92f0-4f83-e252-dd4b-f3215e0b1626"
      },
      "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",
        "\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.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "f9bd48e1-52c0-2e39-d700-58c6dab42f05"
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n",
        "%matplotlib inline\n",
        "plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "017fb0db-0735-e911-d7e5-c3dd4cb1d95e"
      },
      "outputs": [],
      "source": [
        "train_photos = pd.read_csv('../input/train_photo_to_biz_ids.csv')\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "708f445f-76f8-9632-e5b8-00fdc7393963"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "print(''.join([str(train_photos.photo_id[0]),'.jpg']))\n",
        "\n",
        "from PIL import Image\n",
        "im = Image.open(os.path.join('../input/','train_photos',''.join([str(train_photos.photo_id[5]),'.jpg'])))\n",
        "plt.imshow(im)\n",
        "\n",
        "\n",
        "#0: good_for_lunch\n",
        "#1: good_for_dinner\n",
        "#2: takes_reservations\n",
        "#3: outdoor_seating\n",
        "#4: restaurant_is_expensive\n",
        "#5: has_alcohol\n",
        "#6: has_table_service\n",
        "#7: ambience_is_classy\n",
        "#8: good_for_kids"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "c7411f48-24b8-5085-f65c-54a8551f7c52"
      },
      "outputs": [],
      "source": [
        "train_attributes = pd.read_csv('../input/train.csv')\n",
        "\n",
        "list(train_attributes)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "3f39a59e-7ee5-d9fb-b9de-5dc90ed894fd"
      },
      "outputs": [],
      "source": [
        "train_attributes['labels_list'] = train_attributes['labels'].str.split(' ')\n",
        "train_attributes['outdoor'] = train_attributes['labels'].str.contains('3')\n",
        "outdoor_businesses = train_attributes[train_attributes.outdoor==True].business_id.tolist()\n",
        "outdoor_photos = train_photos[train_photos.business_id.isin(outdoor_businesses)].photo_id.tolist()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "806585dc-5bab-0edd-fd5b-fc5d74e15201"
      },
      "outputs": [],
      "source": [
        "num_images_for_show = 5\n",
        "\n",
        "photos_to_show = np.random.choice(outdoor_photos,num_images_for_show**2)\n",
        "\n",
        "for x in range(num_images_for_show ** 2):\n",
        "        \n",
        "        plt.subplot(num_images_for_show, num_images_for_show, x+1)\n",
        "        im = Image.open(os.path.join('../input/','train_photos',''.join([str(photos_to_show[x]),'.jpg'])))\n",
        "        plt.imshow(im)\n",
        "        plt.axis('off')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "acd6dd76-6b67-8239-5c9d-33b310900ce8"
      },
      "outputs": [],
      "source": [
        "#0: good_for_lunch\n",
        "#1: good_for_dinner\n",
        "#2: takes_reservations\n",
        "#3: outdoor_seating\n",
        "#4: restaurant_is_expensive\n",
        "#5: has_alcohol\n",
        "#6: has_table_service\n",
        "#7: ambience_is_classy\n",
        "#8: good_for_kids\n",
        "\n",
        "train_attributes['labels_list'] = train_attributes['labels'].str.split(' ')\n",
        "train_attributes['kids'] = train_attributes['labels'].str.contains('8')\n",
        "kids_businesses = train_attributes[train_attributes.kids==True].business_id.tolist()\n",
        "kidsRes_photos = train_photos[train_photos.business_id.isin(kids_businesses)].photo_id.tolist()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "1bc33182-7969-73b7-b1a7-03b4e8224161"
      },
      "outputs": [],
      "source": [
        "num_images_for_show = 5\n",
        "\n",
        "photos_to_show = np.random.choice(kidsRes_photos,num_images_for_show**2)\n",
        "\n",
        "for x in range(num_images_for_show ** 2):\n",
        "        \n",
        "        plt.subplot(num_images_for_show, num_images_for_show, x+1)\n",
        "        im = Image.open(os.path.join('../input/','train_photos',''.join([str(photos_to_show[x]),'.jpg'])))\n",
        "        plt.imshow(im)\n",
        "        plt.axis('off')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "fbecdae1-dd60-4efa-82b4-6a868204bf26"
      },
      "outputs": [],
      "source": [
        "#create a new dataset\n"
      ]
    }
  ],
  "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
}