{"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\nimport matplotlib.pyplot as plt\n%matplotlib inline\nfrom PIL import Image","metadata":{"execution":{"iopub.status.busy":"2021-07-04T10:54:05.860845Z","iopub.execute_input":"2021-07-04T10:54:05.861158Z","iopub.status.idle":"2021-07-04T10:54:06.571127Z","shell.execute_reply.started":"2021-07-04T10:54:05.861087Z","shell.execute_reply":"2021-07-04T10:54:06.570387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_labels = pd.read_csv(\"/kaggle/input/human-protein-atlas-image-classification/train.csv\")\ntrain_labels.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-04T10:56:48.825229Z","iopub.execute_input":"2021-07-04T10:56:48.825537Z","iopub.status.idle":"2021-07-04T10:56:48.90552Z","shell.execute_reply.started":"2021-07-04T10:56:48.82551Z","shell.execute_reply":"2021-07-04T10:56:48.904472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label_names = {\n    0:  \"Nucleoplasm\",  \n    1:  \"Nuclear membrane\",   \n    2:  \"Nucleoli\",   \n    3:  \"Nucleoli fibrillar center\",   \n    4:  \"Nuclear speckles\",\n    5:  \"Nuclear bodies\",   \n    6:  \"Endoplasmic reticulum\",   \n    7:  \"Golgi apparatus\",   \n    8:  \"Peroxisomes\",   \n    9:  \"Endosomes\",   \n    10:  \"Lysosomes\",   \n    11:  \"Intermediate filaments\",   \n    12:  \"Actin filaments\",   \n    13:  \"Focal adhesion sites\",   \n    14:  \"Microtubules\",   \n    15:  \"Microtubule ends\",   \n    16:  \"Cytokinetic bridge\",   \n    17:  \"Mitotic spindle\",   \n    18:  \"Microtubule organizing center\",   \n    19:  \"Centrosome\",   \n    20:  \"Lipid droplets\",   \n    21:  \"Plasma membrane\",   \n    22:  \"Cell junctions\",   \n    23:  \"Mitochondria\",   \n    24:  \"Aggresome\",   \n    25:  \"Cytosol\",   \n    26:  \"Cytoplasmic bodies\",   \n    27:  \"Rods & rings\"\n}\n\nreverse_train_labels = dict((v,k) for k,v in label_names.items())","metadata":{"execution":{"iopub.status.busy":"2021-07-04T10:57:27.489977Z","iopub.execute_input":"2021-07-04T10:57:27.490302Z","iopub.status.idle":"2021-07-04T10:57:27.49985Z","shell.execute_reply.started":"2021-07-04T10:57:27.490273Z","shell.execute_reply":"2021-07-04T10:57:27.498755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def fill_targets(row):\n    row.Target = np.array(row.Target.split(\" \")).astype(np.int)\n    for num in row.Target:\n        name = label_names[int(num)]\n        row.loc[name] = 1\n    return row","metadata":{"execution":{"iopub.status.busy":"2021-07-04T10:57:42.323806Z","iopub.execute_input":"2021-07-04T10:57:42.324194Z","iopub.status.idle":"2021-07-04T10:57:42.329597Z","shell.execute_reply.started":"2021-07-04T10:57:42.324162Z","shell.execute_reply":"2021-07-04T10:57:42.328755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_labels = train_labels.apply(fill_targets, axis=1)\ntrain_labels.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-04T10:58:11.925934Z","iopub.execute_input":"2021-07-04T10:58:11.926295Z","iopub.status.idle":"2021-07-04T10:58:49.907514Z","shell.execute_reply.started":"2021-07-04T10:58:11.926263Z","shell.execute_reply":"2021-07-04T10:58:49.906477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_counts = train_labels.drop([\"Id\", \"Target\"],axis=1).sum(axis=0).sort_values(ascending=False) #vertically\nplt.figure(figsize=(8,8))\nsns.barplot(y=target_counts.index.values, x=target_counts.values, order=target_counts.index)","metadata":{"execution":{"iopub.status.busy":"2021-07-04T10:59:19.706426Z","iopub.execute_input":"2021-07-04T10:59:19.706754Z","iopub.status.idle":"2021-07-04T10:59:20.101419Z","shell.execute_reply.started":"2021-07-04T10:59:19.706724Z","shell.execute_reply":"2021-07-04T10:59:20.100628Z"},"trusted":true},"execution_count":null,"outputs":[]}]}