{"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\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n#    for filename in filenames:\n        #print(os.path.join(dirname, filename))\n\n# You can write up to 20GB 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":{},"cell_type":"markdown","source":"# Datesets\n1. Train \n2. Sample submission"},{"metadata":{"trusted":true},"cell_type":"code","source":"import plotly.express as px\nimport matplotlib.pyplot as plt\nfrom plotly.subplots import make_subplots","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train = pd.read_csv(\"/kaggle/input/hpa-single-cell-image-classification/train.csv\")\ndf_train.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"lbl_cnts = df_train.groupby('Label')['Label'].count().reset_index(name = 'Counts').sort_values(by = 'Counts', ascending = False)\nfig = px.bar(lbl_cnts[:20], x='Label', y='Counts', color = 'Label', title = 'Top 20 Label combinations')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"ls = []\nfor ele in df_train.Label:\n    ls.append(ele.split('|'))\nflat_list = [int(item) for sublist in ls for item in sublist]\ndf = pd.DataFrame(dict((i, flat_list.count(i)) for i in flat_list).items(), columns = ['key','value'])\nfig = px.bar(df, x='key', y='value', color = 'key', title = 'Unique Label distribution')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Unique Label distribution is to know the individual counts of each Label. Nucleoplasm(0) and Cytosol(16) are having high number of Cell samples.**"},{"metadata":{},"cell_type":"markdown","source":"## Sample Cell Images #1"},{"metadata":{"trusted":true},"cell_type":"code","source":"file_id = '5c27f04c-bb99-11e8-b2b9-ac1f6b6435d0'\ncolors = ['_red','_green','_yellow','_blue']\nfile_name = '/kaggle/input/hpa-single-cell-image-classification/train/'\nplt.figure(figsize=(20,20))\n#RED\nfile = file_name+file_id+colors[0]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 1)\nplt.imshow(img)\nplt.title(\"RED\")\n#GREEN\nfile = file_name+file_id+colors[1]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 2)\nplt.imshow(img)\nplt.title(\"GREEN\")\n#YELLOW\nfile = file_name+file_id+colors[2]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 3)\nplt.imshow(img)\nplt.title(\"YELLOW\")\n#BLUE\nfile = file_name+file_id+colors[3]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 4)\nplt.imshow(img)\nplt.title(\"BLUE\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Sample Cell Images #2"},{"metadata":{"trusted":true},"cell_type":"code","source":"file_id = '60b57878-bb99-11e8-b2b9-ac1f6b6435d0'\ncolors = ['_red','_green','_yellow','_blue']\nfile_name = '/kaggle/input/hpa-single-cell-image-classification/train/'\nplt.figure(figsize=(20,20))\n#RED\nfile = file_name+file_id+colors[0]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 1)\nplt.imshow(img)\nplt.title(\"RED\")\n#GREEN\nfile = file_name+file_id+colors[1]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 2)\nplt.imshow(img)\nplt.title(\"GREEN\")\n#YELLOW\nfile = file_name+file_id+colors[2]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 3)\nplt.imshow(img)\nplt.title(\"YELLOW\")\n#BLUE\nfile = file_name+file_id+colors[3]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 4)\nplt.imshow(img)\nplt.title(\"BLUE\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Sample Cell Images \n### Label 0"},{"metadata":{"trusted":true},"cell_type":"code","source":"#Label 0\nzero = df_train[df_train.Label == '0']\nfile_id = zero['ID'][zero.first_valid_index()]\nplt.figure(figsize=(20,20))\n#RED\nfile = file_name+file_id+colors[0]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 1)\nplt.imshow(img)\nplt.title(\"RED\")\n#GREEN\nfile = file_name+file_id+colors[1]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 2)\nplt.imshow(img)\nplt.title(\"GREEN\")\n#YELLOW\nfile = file_name+file_id+colors[2]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 3)\nplt.imshow(img)\nplt.title(\"YELLOW\")\n#BLUE\nfile = file_name+file_id+colors[3]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 4)\nplt.imshow(img)\nplt.title(\"BLUE\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Label 1"},{"metadata":{"trusted":true},"cell_type":"code","source":"#Label 1\nzero = df_train[df_train.Label == '1']\nfile_id = zero['ID'][zero.first_valid_index()]\nplt.figure(figsize=(20,20))\n#RED\nfile = file_name+file_id+colors[0]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 1)\nplt.imshow(img)\nplt.title(\"RED\")\n#GREEN\nfile = file_name+file_id+colors[1]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 2)\nplt.imshow(img)\nplt.title(\"GREEN\")\n#YELLOW\nfile = file_name+file_id+colors[2]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 3)\nplt.imshow(img)\nplt.title(\"YELLOW\")\n#BLUE\nfile = file_name+file_id+colors[3]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 4)\nplt.imshow(img)\nplt.title(\"BLUE\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Label 2"},{"metadata":{"trusted":true},"cell_type":"code","source":"#Label 2\nzero = df_train[df_train.Label == '2']\nfile_id = zero['ID'][zero.first_valid_index()]\nplt.figure(figsize=(20,20))\n#RED\nfile = file_name+file_id+colors[0]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 1)\nplt.imshow(img)\nplt.title(\"RED\")\n#GREEN\nfile = file_name+file_id+colors[1]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 2)\nplt.imshow(img)\nplt.title(\"GREEN\")\n#YELLOW\nfile = file_name+file_id+colors[2]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 3)\nplt.imshow(img)\nplt.title(\"YELLOW\")\n#BLUE\nfile = file_name+file_id+colors[3]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 4)\nplt.imshow(img)\nplt.title(\"BLUE\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Label 3"},{"metadata":{"trusted":true},"cell_type":"code","source":"#Label 3\nzero = df_train[df_train.Label == '3']\nfile_id = zero['ID'][zero.first_valid_index()]\nplt.figure(figsize=(20,20))\n#RED\nfile = file_name+file_id+colors[0]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 1)\nplt.imshow(img)\nplt.title(\"RED\")\n#GREEN\nfile = file_name+file_id+colors[1]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 2)\nplt.imshow(img)\nplt.title(\"GREEN\")\n#YELLOW\nfile = file_name+file_id+colors[2]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 3)\nplt.imshow(img)\nplt.title(\"YELLOW\")\n#BLUE\nfile = file_name+file_id+colors[3]+'.png'\nimg = plt.imread(file)\nplt.subplot(2, 2, 4)\nplt.imshow(img)\nplt.title(\"BLUE\")","execution_count":null,"outputs":[]},{"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}