{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Import Libraries","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport os\n\nfrom PIL import Image","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-06-03T18:20:53.806981Z","iopub.execute_input":"2022-06-03T18:20:53.807760Z","iopub.status.idle":"2022-06-03T18:20:55.052568Z","shell.execute_reply.started":"2022-06-03T18:20:53.807621Z","shell.execute_reply":"2022-06-03T18:20:55.051338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"DATA_FOLDER  = '/kaggle/input/creation-dataset-512x512/'\nTRAIN_FOLDER = DATA_FOLDER + 'train_images/'","metadata":{"execution":{"iopub.status.busy":"2022-06-03T18:20:55.055920Z","iopub.execute_input":"2022-06-03T18:20:55.056197Z","iopub.status.idle":"2022-06-03T18:20:55.061145Z","shell.execute_reply.started":"2022-06-03T18:20:55.056163Z","shell.execute_reply":"2022-06-03T18:20:55.059583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Hotel Chain Distribution","metadata":{}},{"cell_type":"code","source":"data_df = pd.read_csv(DATA_FOLDER + 'train_df.csv')\ndata_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-06-03T18:20:55.062710Z","iopub.execute_input":"2022-06-03T18:20:55.063499Z","iopub.status.idle":"2022-06-03T18:20:55.126407Z","shell.execute_reply.started":"2022-06-03T18:20:55.063411Z","shell.execute_reply":"2022-06-03T18:20:55.125302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_df.describe()","metadata":{"execution":{"iopub.status.busy":"2022-06-03T18:20:55.128878Z","iopub.execute_input":"2022-06-03T18:20:55.129374Z","iopub.status.idle":"2022-06-03T18:20:55.163410Z","shell.execute_reply.started":"2022-06-03T18:20:55.129324Z","shell.execute_reply":"2022-06-03T18:20:55.162453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chains = data_df.groupby('hotel_id').size()\nchains.sort_values(inplace=True)\nprint('We have a total of', chains.count(), 'hotel chains, and there is an average of', round(chains.mean()), 'pictures per chain, but as it is a skewed representation, we should consider the median which is', chains.median())","metadata":{"execution":{"iopub.status.busy":"2022-06-03T18:20:55.164723Z","iopub.execute_input":"2022-06-03T18:20:55.165080Z","iopub.status.idle":"2022-06-03T18:20:55.177203Z","shell.execute_reply.started":"2022-06-03T18:20:55.165044Z","shell.execute_reply":"2022-06-03T18:20:55.176123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Image Size Distribution","metadata":{}},{"cell_type":"code","source":"sizes = []\nfor dirname, _, filenames in os.walk(TRAIN_FOLDER):\n    for filename in filenames: \n        image_size = Image.open(os.path.join(dirname, filename)).size\n        sizes.append(image_size)","metadata":{"execution":{"iopub.status.busy":"2022-06-03T18:20:55.179131Z","iopub.execute_input":"2022-06-03T18:20:55.179802Z","iopub.status.idle":"2022-06-03T18:21:45.514034Z","shell.execute_reply.started":"2022-06-03T18:20:55.179752Z","shell.execute_reply":"2022-06-03T18:21:45.512579Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"orig_sizes = []\nfor dirname, _, filenames in os.walk('/kaggle/input/hotel-id-to-combat-human-trafficking-2022-fgvc9/train_images'):\n    for filename in filenames: \n        image_size = Image.open(os.path.join(dirname, filename)).size\n        orig_sizes.append(image_size)","metadata":{"execution":{"iopub.status.busy":"2022-06-03T18:21:45.514932Z","iopub.status.idle":"2022-06-03T18:21:45.515295Z","shell.execute_reply.started":"2022-06-03T18:21:45.515113Z","shell.execute_reply":"2022-06-03T18:21:45.515132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_small = sum([1 for x, y in sizes if x < 512 or y < 512])\nprint(total_small, total_small / len(sizes) * 100)\n\nx, y = zip(*sizes)\nplt.scatter(x, y)","metadata":{"execution":{"iopub.status.busy":"2022-06-03T18:21:45.516674Z","iopub.status.idle":"2022-06-03T18:21:45.517329Z","shell.execute_reply.started":"2022-06-03T18:21:45.516849Z","shell.execute_reply":"2022-06-03T18:21:45.517048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_small = sum([1 for x, y in orig_sizes if x < 512 or y < 512])\nprint(total_small, total_small / len(orig_sizes) * 100)\n\nx, y = zip(*orig_sizes)\nplt.scatter(x, y)","metadata":{"execution":{"iopub.status.busy":"2022-06-03T18:21:45.518751Z","iopub.status.idle":"2022-06-03T18:21:45.519120Z","shell.execute_reply.started":"2022-06-03T18:21:45.518931Z","shell.execute_reply":"2022-06-03T18:21:45.518949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}