{"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 pandas as pd\nimport numpy as np\nimport SimpleITK as sitk\nimport os\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:21.872102Z","iopub.execute_input":"2022-12-23T16:42:21.872779Z","iopub.status.idle":"2022-12-23T16:42:21.878903Z","shell.execute_reply.started":"2022-12-23T16:42:21.872728Z","shell.execute_reply":"2022-12-23T16:42:21.87804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data loading","metadata":{}},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:21.880906Z","iopub.execute_input":"2022-12-23T16:42:21.881512Z","iopub.status.idle":"2022-12-23T16:42:21.963069Z","shell.execute_reply.started":"2022-12-23T16:42:21.881476Z","shell.execute_reply":"2022-12-23T16:42:21.962092Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:21.964709Z","iopub.execute_input":"2022-12-23T16:42:21.965335Z","iopub.status.idle":"2022-12-23T16:42:21.983609Z","shell.execute_reply.started":"2022-12-23T16:42:21.965296Z","shell.execute_reply":"2022-12-23T16:42:21.982389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Analysis infomation","metadata":{}},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:21.985091Z","iopub.execute_input":"2022-12-23T16:42:21.985476Z","iopub.status.idle":"2022-12-23T16:42:22.011727Z","shell.execute_reply.started":"2022-12-23T16:42:21.985445Z","shell.execute_reply":"2022-12-23T16:42:22.010449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Summaries:\n- Bộ dữ liệu có 54706 mẫu:\n- Bao gồm 13 đặc trưng và một đặc trưng phân lớp (Cancer)\n- Có một số đặc trưng là null\n\n### Only on Train: Một số đặc trưng chỉ có trên tập train\n- Density: Độ đậm đặc \n- Invasive\n- BIRDS\n- difficult_negative_case","metadata":{}},{"cell_type":"code","source":"col_name = df.columns\nisnul= pd.DataFrame(df.isnull().sum()).T\nisnul","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:22.015279Z","iopub.execute_input":"2022-12-23T16:42:22.015648Z","iopub.status.idle":"2022-12-23T16:42:22.041148Z","shell.execute_reply.started":"2022-12-23T16:42:22.015616Z","shell.execute_reply":"2022-12-23T16:42:22.040028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Những đặc trưng có giá trị null:\n   - Age (Độ tuổi): 37\n   - BIRADS (Hệ thống phân loại kết quả chụp nhũ ảnh theo điểm số): 28420\n   - Density (Độ dày đặc  A -> D [ít -> nhiều]): 25236\n   \n **BIRADS và Density bị mất rất nhiều khoảng 50%**","metadata":{"execution":{"iopub.status.busy":"2022-12-23T12:54:41.805457Z","iopub.execute_input":"2022-12-23T12:54:41.805844Z","iopub.status.idle":"2022-12-23T12:54:41.826134Z","shell.execute_reply.started":"2022-12-23T12:54:41.805814Z","shell.execute_reply":"2022-12-23T12:54:41.824172Z"}}},{"cell_type":"code","source":"## Split Class and Features\ny = df[[\"cancer\"]]\ndf = x = df.drop([\"cancer\"],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:22.042798Z","iopub.execute_input":"2022-12-23T16:42:22.04313Z","iopub.status.idle":"2022-12-23T16:42:22.052476Z","shell.execute_reply.started":"2022-12-23T16:42:22.0431Z","shell.execute_reply":"2022-12-23T16:42:22.05146Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"cancer\"] = y","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:22.055099Z","iopub.execute_input":"2022-12-23T16:42:22.055742Z","iopub.status.idle":"2022-12-23T16:42:22.066688Z","shell.execute_reply.started":"2022-12-23T16:42:22.055708Z","shell.execute_reply":"2022-12-23T16:42:22.065481Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features = [\n    \"site_id\", \"age\", \"biopsy\", \"invasive\", \n    \"BIRADS\", \"implant\", \"machine_id\", \"density\",\n    \"difficult_negative_case\", \"cancer\"\n]\ncorrelation_matrix = df[features].corr(method=\"spearman\")\n\nfrom matplotlib.colors import SymLogNorm\n\nf, ax = plt.subplots(figsize=(15, 15))\ncmap = sns.diverging_palette(230, 20, as_cmap=True)\n_ = sns.heatmap(\n    correlation_matrix, \n    mask=np.triu(np.ones_like(correlation_matrix, dtype=bool)), \n    cmap=sns.diverging_palette(230, 20, as_cmap=True), \n    center=0,\n    square=True, \n    linewidths=.1, \n    cbar=False,\n    ax=ax,\n    annot=True,\n)\n_ = ax.set_title(\"Spearman Correlation Matrix\", fontsize=15)","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:22.068205Z","iopub.execute_input":"2022-12-23T16:42:22.068554Z","iopub.status.idle":"2022-12-23T16:42:22.718174Z","shell.execute_reply.started":"2022-12-23T16:42:22.068521Z","shell.execute_reply":"2022-12-23T16:42:22.717013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Sau khi hiển thị heatmap ta có thể thấy**\n- BIOPSY và Invasive có tương quan trực tiếp khá mạnh đối với output\n- difficult_neg_case tương quan mạnh với BIRADS một đặc trưng có tiềm năng cho việc dự đoán output","metadata":{}},{"cell_type":"markdown","source":"## BIRADS Feature\n","metadata":{}},{"cell_type":"code","source":"sns.barplot(df, x=\"BIRADS\")","metadata":{"execution":{"iopub.status.busy":"2022-12-23T16:42:22.719805Z","iopub.execute_input":"2022-12-23T16:42:22.722348Z","iopub.status.idle":"2022-12-23T16:42:22.75986Z","shell.execute_reply.started":"2022-12-23T16:42:22.722308Z","shell.execute_reply":"2022-12-23T16:42:22.758072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}