{"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":"\n# Intro\nWelcome to the [Hotel-ID to Combat Human Trafficking 2021 - FGVC8](https://www.kaggle.com/c/hotel-id-2021-fgvc8/overview) competidtion.\n![](https://storage.googleapis.com/kaggle-competitions/kaggle/25980/logos/header.png)\n\n<span style=\"color: royalblue;\">Please vote the notebook up if it helps you. Feel free to leave a comment above the notebook. Thank you. </span>","metadata":{}},{"cell_type":"markdown","source":"# Libraries","metadata":{}},{"cell_type":"code","source":"import os\nimport pandas as pd\nimport cv2\nimport matplotlib.pyplot as plt","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Path","metadata":{}},{"cell_type":"code","source":"path = '/kaggle/input/hotel-id-2021-fgvc8/'\nos.listdir(path)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Load Data","metadata":{}},{"cell_type":"code","source":"train_data = pd.read_csv(path+'train.csv')\nsamp_subm = pd.read_csv(path+'sample_submission.csv')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Function\nWe define some helper functions.","metadata":{}},{"cell_type":"code","source":"def plot_examples_by_chain(chain):\n    fig, axs = plt.subplots(1, 5, figsize=(20, 10))\n    fig.subplots_adjust(hspace = .1, wspace=.1)\n    df=train_data[train_data['chain']==chain]\n    df.index = range(len(df))\n    axs = axs.ravel()\n    for i in range(5):\n        img = cv2.imread(path+'train_images/'+str(chain)+'/'+df.loc[i, 'image'])\n        axs[i].imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))\n        axs[i].set_title('chain:'+str(chain))\n        axs[i].set_xticklabels([])\n        axs[i].set_yticklabels([])\n    plt.show()","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Overview","metadata":{}},{"cell_type":"code","source":"print('Number of train samples:', len(train_data))\nprint('Number of train features:', len(train_data.columns))\nprint('Number of chain folders with images:', len(os.listdir(path+'train_images/')))","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.head()","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# EDA","metadata":{}},{"cell_type":"code","source":"print('Number of chain ids:', len(train_data['chain'].unique()))\nprint('Number of hotel ids:', len(train_data['hotel_id'].unique()))","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We plot some images for examples of chains: ","metadata":{}},{"cell_type":"code","source":"plot_examples_by_chain(85)\nplot_examples_by_chain(13)\nplot_examples_by_chain(4)","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.groupby(['chain', 'hotel_id']).count()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['chain'].value_counts()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Export","metadata":{}},{"cell_type":"code","source":"output = samp_subm.copy()\noutput['hotel_id'] = 36363\noutput.to_csv('submission.csv', index=False)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"output","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}