{"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 # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt #graphing\nimport plotly.express as px #graphing\nimport seaborn as sns #graphing\nimport missingno as msno\n\nsns.set(rc = {\"figure.figsize\":(12, 8)}) #graph size\nplt.style.use(\"fivethirtyeight\")\n\nfrom plotly.offline import plot, iplot, init_notebook_mode\nimport plotly.graph_objs as go\ninit_notebook_mode(connected=True)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-11-30T20:17:45.500977Z","iopub.execute_input":"2022-11-30T20:17:45.502424Z","iopub.status.idle":"2022-11-30T20:17:48.165498Z","shell.execute_reply.started":"2022-11-30T20:17:45.502284Z","shell.execute_reply":"2022-11-30T20:17:48.164231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/train.csv\")\ntest = pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-11-30T20:17:48.16758Z","iopub.execute_input":"2022-11-30T20:17:48.168974Z","iopub.status.idle":"2022-11-30T20:17:48.328524Z","shell.execute_reply.started":"2022-11-30T20:17:48.168927Z","shell.execute_reply":"2022-11-30T20:17:48.327582Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Columns in train & test\n\n`site_id` - ID code for the source hospital.\n\n`patient_id` - ID code for the patient.\n\n`image_id` - ID code for the image.\n\n`laterality` - Whether the image is of the left or right breast.\n\n`view` - The orientation of the image. The default for a screening exam is to capture two views per breast.\n\n`age` - The patient's age in years.\n\n`implant` - Whether or not the patient had breast implants. Site 1 only provides breast implant information at the patient level, not at the breast level.\n\n`density` - A rating for how dense the breast tissue is, with A being the least dense and D being the most dense. Extremely dense tissue can make diagnosis more difficult.\n\n`machine_id` - An ID code for the imaging device.\n\n`cancer` - The target value. Only provided for train.\n\n`biopsy` - Whether or not a follow-up biopsy was performed on the breast. Only provided for train.\n\n`invasive` - If the breast is positive for cancer, whether or not the cancer proved to be invasive. Only provided for train.\n\n`BIRADS` - 0 if the breast required follow-up, 1 if the breast was rated as negative for cancer, and 2 if the breast was rated as normal. Only provided for train.\n\n`prediction_id` - The ID for the matching submission row. Multiple images will share the same prediction ID. Test only.\n\n`difficult_negative_case` - True if the case was unusually difficult. Only provided for train.","metadata":{}},{"cell_type":"code","source":"display(train.head())\ndisplay(test.head())","metadata":{"_kg_hide-input":false,"execution":{"iopub.status.busy":"2022-11-30T20:21:15.436284Z","iopub.execute_input":"2022-11-30T20:21:15.438157Z","iopub.status.idle":"2022-11-30T20:21:15.474804Z","shell.execute_reply.started":"2022-11-30T20:21:15.438086Z","shell.execute_reply":"2022-11-30T20:21:15.473361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display(train.info())\ndisplay(test.info())","metadata":{"_kg_hide-input":false,"execution":{"iopub.status.busy":"2022-11-29T02:14:03.101746Z","iopub.execute_input":"2022-11-29T02:14:03.102081Z","iopub.status.idle":"2022-11-29T02:14:03.132035Z","shell.execute_reply.started":"2022-11-29T02:14:03.102052Z","shell.execute_reply":"2022-11-29T02:14:03.131008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"msno.matrix(train)","metadata":{"execution":{"iopub.status.busy":"2022-11-29T01:35:35.638847Z","iopub.execute_input":"2022-11-29T01:35:35.639216Z","iopub.status.idle":"2022-11-29T01:35:36.249683Z","shell.execute_reply.started":"2022-11-29T01:35:35.639184Z","shell.execute_reply":"2022-11-29T01:35:36.248299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.histogram(train, x = \"age\", marginal = \"box\", color_discrete_sequence = [\"#ff00ff\"],\n                   title = \"Age of women histogram ♀\")\n\nfig.update_layout(plot_bgcolor = \"#000000\", paper_bgcolor = \"#000000\", bargap = 0.3, font = dict(family = \"PT Sans\", size = 14, color = \"#FFFFFF\"))\nfig.update_traces(marker = dict(line = dict(width = 1.5, color = \"#FFFFFF\")))\nfig.update_yaxes(showgrid = True, gridwidth = 0.25, gridcolor = \"#646464\")\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-11-29T01:51:31.351132Z","iopub.execute_input":"2022-11-29T01:51:31.351477Z","iopub.status.idle":"2022-11-29T01:51:31.49367Z","shell.execute_reply.started":"2022-11-29T01:51:31.351447Z","shell.execute_reply":"2022-11-29T01:51:31.492777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in train.columns[3:5]:    \n    \n    ax = sns.countplot(x = train[f\"{i}\"])\n    \n    for container in ax.containers:\n        ax.bar_label(container)\n        \n    plt.title(f\"Countplot of {i}\")      \n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-29T01:50:35.941161Z","iopub.execute_input":"2022-11-29T01:50:35.941532Z","iopub.status.idle":"2022-11-29T01:50:36.293938Z","shell.execute_reply.started":"2022-11-29T01:50:35.9415Z","shell.execute_reply":"2022-11-29T01:50:36.292856Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(x = train.query(\"laterality == 'L'\")[\"age\"], shade = True, color = \"#cc0000\", legend = True)\nsns.kdeplot(x = train.query(\"laterality == 'R'\")[\"age\"], shade = True, color = \"#0066ff\", legend = True)\nplt.legend(labels = [\"laterality: 1\", \"laterality: 0\"])\nplt.title(\"Age of women -- laterality\")\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-11-29T02:02:24.275314Z","iopub.execute_input":"2022-11-29T02:02:24.27573Z","iopub.status.idle":"2022-11-29T02:02:24.723959Z","shell.execute_reply.started":"2022-11-29T02:02:24.275679Z","shell.execute_reply":"2022-11-29T02:02:24.723009Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(x = train.query(\"view == 'CC'\")[\"age\"], shade = True, color = \"#cc0000\", legend = True)\nsns.kdeplot(x = train.query(\"view == 'MLO'\")[\"age\"], shade = True, color = \"#0066ff\", legend = True)\nplt.legend(labels = [\"view: CC\", \"view: MLO\"])\nplt.title(\"Age of women -- view\")\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-11-29T02:02:33.747521Z","iopub.execute_input":"2022-11-29T02:02:33.748432Z","iopub.status.idle":"2022-11-29T02:02:34.217634Z","shell.execute_reply.started":"2022-11-29T02:02:33.748398Z","shell.execute_reply":"2022-11-29T02:02:34.21638Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in train.columns[6:12]:\n    \n    ax = sns.countplot(x = train[f\"{i}\"])\n    \n    for container in ax.containers:\n        ax.bar_label(container)\n        \n    plt.title(f\"Countplot of {i}\")\n    plt.show()    ","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-11-30T20:24:37.487929Z","iopub.execute_input":"2022-11-30T20:24:37.488457Z","iopub.status.idle":"2022-11-30T20:24:38.69975Z","shell.execute_reply.started":"2022-11-30T20:24:37.488418Z","shell.execute_reply":"2022-11-30T20:24:38.6984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(x = train.query(\"difficult_negative_case == True\")[\"age\"], shade = True, color = \"#0066ff\", legend = True)\nsns.kdeplot(x = train.query(\"difficult_negative_case == False\")[\"age\"], shade = True, color = \"#cc0000\", legend = True)\nplt.legend(labels = [\"difficult_negative_case: True\", \"difficult_negative_case: False\"])\nplt.title(\"Age of women -- difficult_negative_case\")\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-11-29T02:02:51.890234Z","iopub.execute_input":"2022-11-29T02:02:51.890644Z","iopub.status.idle":"2022-11-29T02:02:52.314313Z","shell.execute_reply.started":"2022-11-29T02:02:51.890599Z","shell.execute_reply":"2022-11-29T02:02:52.313435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in train.columns[6:9]:\n    \n    sns.kdeplot(x = train.query(f\"{i} == 1\")[\"age\"], shade = True, color = \"#cc0000\", legend = True)\n    sns.kdeplot(x = train.query(f\"{i} == 0\")[\"age\"], shade = True, color = \"#0066ff\", legend = True)\n    plt.legend(labels = [f\"{i}: 1\", f\"{i}: 0\"])\n    plt.title(f\"Age of women -- {i}\")\n    plt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-11-30T20:27:50.647696Z","iopub.execute_input":"2022-11-30T20:27:50.648267Z","iopub.status.idle":"2022-11-30T20:27:52.436234Z","shell.execute_reply.started":"2022-11-30T20:27:50.648226Z","shell.execute_reply":"2022-11-30T20:27:52.435051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in train[\"density\"].sort_values().unique()[:4]:\n    \n    sns.kdeplot(x = train.query(f\"density == '{i}' and cancer == 1\")[\"age\"], shade = True, color = \"#cc0000\", legend = True)\n    sns.kdeplot(x = train.query(f\"density == '{i}' and cancer == 0\")[\"age\"], shade = True, color = \"#0066ff\", legend = True)\n    plt.legend(labels = [\"cancer: 1\", \"cancer: 0\"])\n    plt.title(f\"Age of women -- density = {i}\")\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-30T20:32:12.689569Z","iopub.execute_input":"2022-11-30T20:32:12.690051Z","iopub.status.idle":"2022-11-30T20:32:14.230422Z","shell.execute_reply.started":"2022-11-30T20:32:12.690017Z","shell.execute_reply":"2022-11-30T20:32:14.22926Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}