{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"markdown","source":"# In this Notebook i will try to explore  label distribution."},{"metadata":{},"cell_type":"markdown","source":"Credit: @ https://www.kaggle.com/thedrcat/hpa-single-cell-classification-eda"},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport numpy as np","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Lets Load the Training File"},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df = pd.read_csv('../input/hpa-single-cell-image-classification/train.csv')\ntrain_df.head(10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As we can see, train.csv contains image id and label column."},{"metadata":{},"cell_type":"markdown","source":"# Unique Labels"},{"metadata":{"trusted":true},"cell_type":"code","source":"all_labels = train_df.Label.unique().tolist()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"all_labels[:10]","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Labels are separated by | symbol"},{"metadata":{"trusted":true},"cell_type":"code","source":"all_labels = '|'.join(all_labels)\n\nall_labels = all_labels.split('|')\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"labels = [str(i) for i in range(19)]\n\nunique_counts = {}\nfor lbl in labels:\n    unique_counts[lbl] = len(train_df[train_df.Label == lbl])\n\nfull_counts = {}\nfor lbl in labels:\n    count = 0\n    for row_label in train_df['Label']:\n        if lbl in row_label.split('|'): count += 1\n    full_counts[lbl] = count\n\ndf_lbls = pd.DataFrame(index=labels)\ndf_lbls['full_count'] = full_counts.values()\ndf_lbls['uniq_count'] = unique_counts.values()\ndf_lbls.plot.bar(figsize=(16,8))","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}