{"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":"code","source":"import numpy as np \nimport pandas as pd \nimport seaborn as sns\n%pylab inline\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\nimport cv2","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-10-09T10:49:01.378800Z","iopub.execute_input":"2022-10-09T10:49:01.379298Z","iopub.status.idle":"2022-10-09T10:49:02.813816Z","shell.execute_reply.started":"2022-10-09T10:49:01.379204Z","shell.execute_reply":"2022-10-09T10:49:02.812242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label_df = pd.read_csv(\"../input/datathonindoml-2022/train_labels.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-10-09T10:49:02.816542Z","iopub.execute_input":"2022-10-09T10:49:02.817333Z","iopub.status.idle":"2022-10-09T10:49:02.845087Z","shell.execute_reply.started":"2022-10-09T10:49:02.817286Z","shell.execute_reply":"2022-10-09T10:49:02.843592Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sorted(label_df[\"label\"].unique())","metadata":{"execution":{"iopub.status.busy":"2022-10-09T10:49:02.848072Z","iopub.execute_input":"2022-10-09T10:49:02.848937Z","iopub.status.idle":"2022-10-09T10:49:02.875139Z","shell.execute_reply.started":"2022-10-09T10:49:02.848843Z","shell.execute_reply":"2022-10-09T10:49:02.873683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classes = {\n    0:\"letter\",1:\"memo\",2:\"email\",3:\"filefolder\",\n    4:\"form\",5:\"handwritten\",6:\"invoice\",7:\"advertisement\",\n    8:\"budget\",9:\"news article\",10:\"presentation\",11:\"scientific publication\",\n    12:\"questionnaire\",13:\"resume\",14:\"scientific report\",15:\"specification\"\n}","metadata":{"execution":{"iopub.status.busy":"2022-10-09T10:49:02.878789Z","iopub.execute_input":"2022-10-09T10:49:02.879398Z","iopub.status.idle":"2022-10-09T10:49:02.887256Z","shell.execute_reply.started":"2022-10-09T10:49:02.879351Z","shell.execute_reply":"2022-10-09T10:49:02.886063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label_df['label'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T10:49:02.888750Z","iopub.execute_input":"2022-10-09T10:49:02.889860Z","iopub.status.idle":"2022-10-09T10:49:02.907099Z","shell.execute_reply.started":"2022-10-09T10:49:02.889820Z","shell.execute_reply":"2022-10-09T10:49:02.905737Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Seeing the frequency distribution\nplt.rcParams[\"figure.figsize\"] = [7.50, 3.50]\nfig, ax = plt.subplots()\nlabel_df['label'].value_counts().plot(ax=ax, kind='bar', xlabel='Classes', ylabel=\"Count\")\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T10:49:02.909535Z","iopub.execute_input":"2022-10-09T10:49:02.910569Z","iopub.status.idle":"2022-10-09T10:49:03.233698Z","shell.execute_reply.started":"2022-10-09T10:49:02.910520Z","shell.execute_reply":"2022-10-09T10:49:03.232236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plotting an example of each type of document\nfor i in range(16):\n    v = label_df.loc[label_df['label'] == i].values[0][0]\n    img = cv2.imread('../input/datathonindoml-2022/train/train/'+str(v)+\".tif\")\n    print(classes[i])\n    plt.imshow(img)\n    temp=cv2.resize(img,(512,512))\n    plt.imshow(temp)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T10:49:12.059114Z","iopub.execute_input":"2022-10-09T10:49:12.059563Z","iopub.status.idle":"2022-10-09T10:49:17.013373Z","shell.execute_reply.started":"2022-10-09T10:49:12.059527Z","shell.execute_reply":"2022-10-09T10:49:17.012245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-09T10:49:20.599646Z","iopub.execute_input":"2022-10-09T10:49:20.600202Z","iopub.status.idle":"2022-10-09T10:49:20.609106Z","shell.execute_reply.started":"2022-10-09T10:49:20.600131Z","shell.execute_reply":"2022-10-09T10:49:20.607927Z"},"trusted":true},"execution_count":null,"outputs":[]}]}