{"cells":[{"metadata":{"_uuid":"6ec42b5ead81202664365dea5f9163f954fd73e5","trusted":true},"cell_type":"code","source":"!ls -lah ../input/","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"fa7a3d311f1461dc0b8854116f5551b2ca24ac27"},"cell_type":"markdown","source":"## Glance at the Data"},{"metadata":{"_uuid":"bc55f50b32e44cf73623c57a824d79a079b2a4ac","trusted":true},"cell_type":"code","source":"import pandas as pd\nimport os\n\ndf = pd.read_csv(os.path.join('..', 'input', 'stage_1_train_labels.csv'))\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"436495c2e7ff794b41517d6fdcc8c6a52ea169ac"},"cell_type":"markdown","source":"## Plot Frequency for Target Column\nNot yet worrying about uniques"},{"metadata":{"_uuid":"456e2ceeaa2ce58702bbc838ad8f358fc707d427","trusted":true},"cell_type":"code","source":"import matplotlib.pyplot as plt\n%matplotlib inline\nplt.style.use('fivethirtyeight')\n\ndf.Target.value_counts().plot(kind='bar', title='Target Frequency')","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e3f71a5ecd6ed0d6c7b8567fb43d723565e0afee"},"cell_type":"markdown","source":"## Unique Patient Counts"},{"metadata":{"_uuid":"7185da655ea9753177472a77430e297071377c2b","trusted":true},"cell_type":"code","source":"target_spot = df.Target == 1\n\ntotal_unique = df.patientId.nunique()\npos = df[target_spot].patientId.nunique() \nboxes = sum(target_spot)\nneg = df[~target_spot].patientId.nunique()\n\nprint(\"  {:7,} # positive unique patients\".format(pos))\nprint(\"+ {:7,} # negative unique patients\".format(neg))\nprint(\"===========================\")\nprint(\"  {:7,} # total\".format(pos+neg))\nprint(\"  {:7,} # check against total_unique\".format(total_unique))\nprint(\"\\nthe {:,} positive patients have {:,} labelled boxes\".format(pos, boxes))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"46cb4b5c72c1d739e7538a4d43c57f5f20131ea0"},"cell_type":"markdown","source":"## Bounding Box Shape\nAs you can see from the following two plot, the boxes tend to be taller than they are wide."},{"metadata":{"_uuid":"3f15a4c6a5db4821063631bfd6e38478df475a9b","trusted":true},"cell_type":"code","source":"import numpy as np\nimport matplotlib.lines as mlines\n\n# max box height or width + 100, then rounded to nearest hundred\nmax_dim = np.round(np.ceil(np.max([df.width.max(), df.height.max()])) + 100, decimals=-2)\n\ndf.plot.scatter('width', 'height', title = 'Bounding Box Shapes', \n                xlim=(0, max_dim), ylim=(0, max_dim), s = 1)\nplt.plot([0, max_dim], [0, max_dim], color = 'r', \n         linestyle=\"-\", linewidth=1, label='Equal width & height')\nplt.legend()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"b24676fa41c8d7e555ec9f4b2279c84bbc1abe00","trusted":true},"cell_type":"code","source":"df.boxplot(['width', 'height'])","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}