{"metadata":{"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.6.0"}},"nbformat":4,"nbformat_minor":0,"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"39ed4158-02cf-cc5e-0ec6-157fe5ab2692","_active":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.","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"1486556a-cc97-98d4-845a-34e9eca19fff","_active":false},"outputs":[],"source":"import matplotlib.pyplot as plt\n%matplotlib inline\nplt.rcParams['figure.figsize'] = (12, 40) # set default size of plots","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"f61e99bf-a9b4-84a0-3b96-fb7237dc7565","_active":false},"outputs":[],"source":"#train_photos = pd.read_csv('../input/train_photo_to_biz_ids.csv')\ntrain_photo_to_biz_ids = pd.read_csv('../input/train_photo_to_biz_ids.csv')","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"eb3cbcc6-9a39-afbf-8d50-3ccaf92982af","_active":false},"outputs":[],"source":"train_photo_to_biz_ids","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"ce96b02a-076d-bde5-4b01-be5153eed53f","_active":false},"outputs":[],"source":"# show one image\n\nimport os\nprint(''.join([str(train_photo_to_biz_ids.photo_id[0]),'.jpg']))\n\nfrom PIL import Image\nim = Image.open(os.path.join('../input/','train_photos',''.join([str(train_photo_to_biz_ids.photo_id[1]),'.jpg'])))\nplt.imshow(im)","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"530627f7-3c1d-d164-f2d4-a2d6ebca7f08","_active":false},"outputs":[],"source":"train_attr = pd.read_csv('../input/train.csv')\n#train_attr['labels_list'] = train_attr['labels'].str.split(' ')\ntrain_attr","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"14e1c5a4-fd78-a239-77b0-7430f0cf5c81","_active":false},"outputs":[],"source":"# find all the restaurants that are good for lunch (label=0)\ntrain_attr['is_goodforlunch'] = train_attr['labels'].str.contains('4')\ngoodforlunch_businesses = train_attr[train_attr.is_goodforlunch==True].business_id.tolist()\nlen(goodforlunch_businesses)","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"13d1bab3-e4b7-bbba-6074-4e7f88c38cf8","_active":false,"collapsed":false},"outputs":[],"source":"goodforlunch_businesses[0]","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"6d3f0288-098c-b869-82b0-c3c78c0550b5","_active":false},"outputs":[],"source":"goodforlunch_photos = train_photo_to_biz_ids[train_photo_to_biz_ids.business_id.isin(goodforlunch_businesses)].photo_id.tolist()\nlen(goodforlunch_photos)","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"56075076-e69f-d60b-f66e-8000c85ccc44","_active":false,"collapsed":false},"outputs":[],"source":"#goodforlunch_photos1 = train_photo_to_biz_ids[train_photo_to_biz_ids.business_id==1001].photo_id.tolist()\ngoodforlunch_photos1 = train_photo_to_biz_ids[train_photo_to_biz_ids.business_id==goodforlunch_businesses[0]].photo_id.tolist()\nlen(goodforlunch_photos1)","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"06f90e0e-91b3-408b-9b14-ef1036817e62","_active":false},"outputs":[],"source":"import math\n\nnum_images_for_show_column = 4\nrows= math.ceil(len(goodforlunch_photos1)/num_images_for_show_column)\n#photos_to_show = np.random.choice(goodforlunch_photos1,num_images_for_show**2)\n\nfor x in range(len(goodforlunch_photos1)):\n#for x in range(num_images_for_show ** 2):\n#for x in len(goodforlunch_photos1):\n        \n        plt.subplot(rows,num_images_for_show_column , x+1)\n        im = Image.open(os.path.join('../input/','train_photos',''.join([str(goodforlunch_photos1[x]),'.jpg'])))\n        plt.imshow(im)\n        plt.axis('off')","execution_state":"idle"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"fe8ba594-3a4b-95bb-ed81-2c27295f613d","_active":false,"collapsed":false},"outputs":[],"source":"test_photo_to_biz_ids = pd.read_csv('../input/test_photo_to_biz.csv')","execution_state":"idle"},{"metadata":{"_cell_guid":"f9ab4aa7-9387-cbdb-6cf3-8618d9ac250c","_active":false,"collapsed":false},"source":"test_photo_to_biz_ids","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"a7b33db2-5d38-c2a1-484c-12dd6ce4a329","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"}]}