{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nimport tensorflow as tf\nfrom tensorflow import keras\nimport matplotlib.pyplot as plt\nfrom tensorflow.keras.models import Sequential\nimport glob\nimport seaborn as sns\nimport plotly.graph_objects as go\n# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"train_data_df = pd.read_csv('../input/landmark-retrieval-2020/train.csv')\nprint('The Size of csv file : {}'.format(train_data_df.shape))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_data_df.head(5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print('The missing values in dataset : {}'.format(train_data_df.isnull().sum().sum()))\nprint('The Nan values in dataset : {}'.format(train_data_df.isna().sum().sum()))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"describe = train_data_df.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize=(10,10))\ndescribe.plot(kind='bar')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**This I have referenced from an awesome [notebook](https://www.kaggle.com/pukkinming/google-landmark-retrieval-2020-eda) do refer it for further understanding!!**","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"train_data_df_count = pd.DataFrame(train_data_df.landmark_id.value_counts().sort_values(ascending=False))\ntrain_data_df_count.reset_index(inplace=True)\ntrain_data_df_count.columns = ['landmark_id', 'count']\ntrain_data_df_count","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.set()\nplt.figure(figsize=(10,5))\nsns.barplot(\n    x=\"landmark_id\",\n    y=\"count\",\n    data=train_data_df_count.head(10),\n    label=\"Count\",\n    order=train_data_df_count.head(10).landmark_id)\nlocs, labels = plt.xticks()\nplt.setp(labels, rotation=45)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#to check the distribution of data we use kurtosis\ntrain_data_df.kurtosis()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"***Negative values of kurtosis indicate that a distribution is flat and has thin tails. Platykurtic distributions have negative kurtosis values. A platykurtic distribution is flatter (less peaked) when compared with the normal distribution, with fewer values in its shorter (i.e. lighter and thinner) tails.***","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"# Images Visualization","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"from cv2 import cv2\nim = cv2.imread('../input/landmark-retrieval-2020/train/0/0/0/0000059611c7d079.jpg')\nplt.imshow(im)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"***Big thanks to Sudeep Shouche for this!!***","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"# From: https://www.kaggle.com/sudeepshouche/identify-landmark-name-from-landmark-id\nurl = 'https://s3.amazonaws.com/google-landmark/metadata/train_label_to_category.csv'\ndf_class = pd.read_csv(url, index_col = 'landmark_id', encoding='latin', engine='python')['category'].to_dict()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Let's visualize two most visited Landmarks i.e., Landmark Id:138982 and 126637**","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"import math\ndef print_img(class_id, df_class, figsize):\n    file_path = \"../input/landmark-retrieval-2020/train/\"\n    df = train_data_df[train_data_df['landmark_id'] == class_id].reset_index()\n    \n    print(\"Class {} - {}\".format(class_id, df_class[class_id].split(':')[-1]))\n    print(\"Number of images: {}\".format(len(df)))\n    \n    plt.rcParams[\"axes.grid\"] = False\n    no_row = math.ceil(min(len(df), 12)/3) \n    f, axarr = plt.subplots(no_row, 3, figsize=figsize)\n\n    curr_row = 0\n    len_img = min(12, len(df))\n    for i in range(len_img):\n        img_name = df['id'][i] + \".jpg\"\n        img_path = os.path.join(\n            file_path, img_name[0], img_name[1], img_name[2], img_name)\n        example = cv2.imread(img_path)\n        # uncomment the following if u wanna rotate the image\n        # example = cv2.rotate(example, cv2.ROTATE_180)\n        example = example[:,:,::-1]\n\n        col = i % 3\n        axarr[curr_row, col].imshow(example)\n        axarr[curr_row, col].set_title(\"{}. {} ({})\".format(\n            class_id, df_class[class_id].split(':')[-1], df['id'][i]))\n        if col == 2:\n            curr_row += 1","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"class_id = 138982\nprint_img(class_id, df_class, figsize=(25,25))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"class_id =  126637\nprint_img(class_id, df_class, figsize=(25,25))","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# References\n1. https://www.kaggle.com/pukkinming/google-landmark-retrieval-2020-eda\n2. https://www.kaggle.com/c/landmark-retrieval-2020/discussion/163390","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"***WORK IN PROGRESS***","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"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":4,"nbformat_minor":4}