{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"c9c39d71-37c4-4433-8cc5-a0b8137fdbcb","collapsed":true},"outputs":[],"source":"%matplotlib inline"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"83e1bd31-2a23-42da-9639-2c05f7de93f9"},"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":{"_cell_guid":"1f339c5e-1212-4075-9f86-6292219364d8"},"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":{"_cell_guid":"359b2fe2-1df1-49d3-93c7-bc23ed0b8079"},"outputs":[],"source":"train_photos = pd.read_csv('../input/train_photo_to_biz_ids.csv')"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"b988c07d-f73a-45ee-8242-6d3616b81d9c"},"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":{"_cell_guid":"cc908be6-bbcf-4d58-9bfb-99ef5b659a7d"},"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":{"_cell_guid":"19250e61-b372-4c86-aab8-4a718fa1f28d"},"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":{"_cell_guid":"d4565e51-e0c4-4417-8e47-f1fe631fc073"},"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.5.2"}},"nbformat":4,"nbformat_minor":0}