{"cells":[
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": true
  },
  "outputs": [],
  "source": "%matplotlib inline"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "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\nimport numpy as np # linear algebra\nimport 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\nfrom subprocess import check_output\nprint(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": {
   "collapsed": false
  },
  "outputs": [],
  "source": "import matplotlib.pyplot as plt\n%matplotlib inline\nplt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots\n"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train_photos = pd.read_csv('../input/train_photo_to_biz_ids.csv')"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "# show one image\n\nimport os\nprint(''.join([str(train_photos.photo_id[0]),'.jpg']))\n\nfrom PIL import Image\nim = Image.open(os.path.join('../input/','train_photos',''.join([str(train_photos.photo_id[0]),'.jpg'])))\nplt.imshow(im)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train_attr = pd.read_csv('../input/train.csv')\ntrain_attr['labels_list'] = train_attr['labels'].str.split(' ')\n# find all the restaurants that are expensive (label=4)\ntrain_attr['is_expensive'] = train_attr['labels'].str.contains('4')\nexpensive_businesses = train_attr[train_attr.is_expensive==True].business_id.tolist()\nexpensive_photos = train_photos[train_photos.business_id.isin(expensive_businesses)].photo_id.tolist()"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "num_images_for_show = 5\n\nphotos_to_show = np.random.choice(expensive_photos,num_images_for_show**2)\n\nfor 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": {
   "collapsed": false
  },
  "outputs": [],
  "source": ""
 }
],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}}, "nbformat": 4, "nbformat_minor": 0}