{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":39272,"databundleVersionId":4629629,"sourceType":"competition"}],"dockerImageVersionId":30301,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Introduction\n\nThis notebook was developed for analyzing the main data delivered on the RSNA competition https://www.kaggle.com/competitions/rsna-breast-cancer-detection, focused on the main CSV table and the images.","metadata":{}},{"cell_type":"markdown","source":"# Data overview\n\nThe description of the data is shown on the following list, where is specified that some of them are exclusive for the training set and also they give an introduction to the data form:\n\n- site_id - ID code for the source hospital.\n- patient_id - ID code for the patient.\n- image_id - ID code for the image.\n- laterality - Whether the image is of the left or right breast.\n- view - The orientation of the image. The default for a screening exam is to capture two views per breast.\n- age - The patient's age in years.\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- 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. **Only provided for train**.\n- machine_id - An ID code for the imaging device.\n- cancer - Whether or not the breast was positive for malignant cancer. The target value. **Only provided for train**.\n- biopsy - Whether or not a follow-up biopsy was performed on the breast. **Only provided for train**.\n- invasive - If the breast is positive for cancer, whether or not the cancer proved to be invasive. **Only provided for train**.\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- prediction_id - The ID for the matching submission row. Multiple images will share the same prediction ID. **Test only**.\n- difficult_negative_case - True if the case was unusually difficult. **Only provided for train.**\n\nFrom this description, the main EDA was built as a reference for the future Cancer Detection.","metadata":{}},{"cell_type":"markdown","source":"First, the main libraries are loaded, focused on plotting and statistical analysis.","metadata":{}},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing\nimport seaborn as sns #plotting\nimport matplotlib.pyplot as plt #plotting\nsns.set_theme()","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-02-06T01:11:37.07408Z","iopub.execute_input":"2023-02-06T01:11:37.074525Z","iopub.status.idle":"2023-02-06T01:11:37.081122Z","shell.execute_reply.started":"2023-02-06T01:11:37.074491Z","shell.execute_reply":"2023-02-06T01:11:37.079922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Later, the train table was saved on a pandas DataFrame. At first glace, it shows that each patient has more than two images and that there are some missing elements on the **BIRADS** and **density** columns.","metadata":{}},{"cell_type":"code","source":"sample_table=pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/train.csv\")\nsample_table.head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:37.117742Z","iopub.execute_input":"2023-02-06T01:11:37.118141Z","iopub.status.idle":"2023-02-06T01:11:37.19731Z","shell.execute_reply.started":"2023-02-06T01:11:37.118109Z","shell.execute_reply":"2023-02-06T01:11:37.196057Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Exploratory Data Analysis\n\nWith this in consideration, it was compared the total of images related to each column category to find if there is any pattern or if there is a possible imbalance of the data that could harm the performance of predicting models.\n\nFirst, it was checked the total sites registered on the table, finding that there are only two of them and the images are almost equally distributed. Then, the plot helps to identify that there is a difference of almost 5000 images between places.","metadata":{}},{"cell_type":"code","source":"count_site=sample_table.groupby(by=\"site_id\").count()[\"patient_id\"]\ncount_site.reset_index()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:37.199624Z","iopub.execute_input":"2023-02-06T01:11:37.200174Z","iopub.status.idle":"2023-02-06T01:11:37.226529Z","shell.execute_reply.started":"2023-02-06T01:11:37.200124Z","shell.execute_reply":"2023-02-06T01:11:37.225496Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per site_id\")\nsns.barplot(data=count_site.reset_index(),x=\"site_id\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:37.228545Z","iopub.execute_input":"2023-02-06T01:11:37.228974Z","iopub.status.idle":"2023-02-06T01:11:37.466825Z","shell.execute_reply.started":"2023-02-06T01:11:37.228934Z","shell.execute_reply":"2023-02-06T01:11:37.46572Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The total images per laterality show an almost equal trend as it shows that the Screening Mammography is done on both breasts.","metadata":{}},{"cell_type":"code","source":"count_lateral=sample_table.groupby(by=\"laterality\").count()[\"patient_id\"]\ncount_lateral.reset_index()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:37.468986Z","iopub.execute_input":"2023-02-06T01:11:37.469333Z","iopub.status.idle":"2023-02-06T01:11:37.498717Z","shell.execute_reply.started":"2023-02-06T01:11:37.469304Z","shell.execute_reply":"2023-02-06T01:11:37.497866Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per laterality\")\nsns.barplot(data=count_lateral.reset_index(),x=\"laterality\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:37.500209Z","iopub.execute_input":"2023-02-06T01:11:37.500534Z","iopub.status.idle":"2023-02-06T01:11:37.729928Z","shell.execute_reply.started":"2023-02-06T01:11:37.500505Z","shell.execute_reply":"2023-02-06T01:11:37.7287Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"However, the first important differences are related to the Mammography view, as in the following figure are six different views, where the main part of images are related to the **CC** and **MLO** categories.","metadata":{}},{"cell_type":"code","source":"count_view=sample_table.groupby(by=\"view\").count()[\"patient_id\"]\ncount_view.reset_index()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:37.731241Z","iopub.execute_input":"2023-02-06T01:11:37.732162Z","iopub.status.idle":"2023-02-06T01:11:37.760242Z","shell.execute_reply.started":"2023-02-06T01:11:37.73213Z","shell.execute_reply":"2023-02-06T01:11:37.759117Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per view\")\nsns.barplot(data=count_view.reset_index(),x=\"view\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:37.761677Z","iopub.execute_input":"2023-02-06T01:11:37.76208Z","iopub.status.idle":"2023-02-06T01:11:38.038845Z","shell.execute_reply.started":"2023-02-06T01:11:37.762049Z","shell.execute_reply":"2023-02-06T01:11:38.037805Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"count_age=sample_table.groupby(by=\"age\").count()[\"patient_id\"]\ncount_age.reset_index()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:38.041862Z","iopub.execute_input":"2023-02-06T01:11:38.042173Z","iopub.status.idle":"2023-02-06T01:11:38.072783Z","shell.execute_reply.started":"2023-02-06T01:11:38.042144Z","shell.execute_reply":"2023-02-06T01:11:38.071758Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"With age, it was found a normal distribution centered on 60 years and with outliers from young (20 to 40 years old) to older women (75 to 90 years old).","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per age\")\nsns.histplot(data=sample_table.reset_index(),x=\"age\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:38.073967Z","iopub.execute_input":"2023-02-06T01:11:38.074774Z","iopub.status.idle":"2023-02-06T01:11:38.559982Z","shell.execute_reply.started":"2023-02-06T01:11:38.074745Z","shell.execute_reply":"2023-02-06T01:11:38.558532Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Then, with the cancer occurrence, it was found that most of the images correspond to Mammographies of non-cancer patients. This could be a challenge for the overall prediction as the percentage of cancer images is 2.11%.","metadata":{}},{"cell_type":"code","source":"count_cancer=sample_table.groupby(by=\"cancer\").count()[\"patient_id\"]\ncount_cancer.reset_index().head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:38.561879Z","iopub.execute_input":"2023-02-06T01:11:38.562873Z","iopub.status.idle":"2023-02-06T01:11:38.589187Z","shell.execute_reply.started":"2023-02-06T01:11:38.562838Z","shell.execute_reply":"2023-02-06T01:11:38.588116Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per cancer\")\nsns.barplot(data=count_cancer.reset_index(),x=\"cancer\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:38.590772Z","iopub.execute_input":"2023-02-06T01:11:38.591351Z","iopub.status.idle":"2023-02-06T01:11:38.8232Z","shell.execute_reply.started":"2023-02-06T01:11:38.591309Z","shell.execute_reply":"2023-02-06T01:11:38.822186Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The biopsy variable follows a similar trend, as it represents that not all the patients that got this procedure got diagnosed with cancer:","metadata":{}},{"cell_type":"code","source":"count_biopsy=sample_table.groupby(by=\"biopsy\").count()[\"patient_id\"]\ncount_biopsy.reset_index().head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:38.8244Z","iopub.execute_input":"2023-02-06T01:11:38.82469Z","iopub.status.idle":"2023-02-06T01:11:38.853145Z","shell.execute_reply.started":"2023-02-06T01:11:38.824664Z","shell.execute_reply":"2023-02-06T01:11:38.851593Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per biopsy\")\nsns.barplot(data=count_biopsy.reset_index(),x=\"biopsy\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:38.854669Z","iopub.execute_input":"2023-02-06T01:11:38.855301Z","iopub.status.idle":"2023-02-06T01:11:39.084734Z","shell.execute_reply.started":"2023-02-06T01:11:38.855269Z","shell.execute_reply":"2023-02-06T01:11:39.08344Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"With the invasive variable, it is presented that not all the cancer images represent an invasive disease:","metadata":{}},{"cell_type":"code","source":"count_invasive=sample_table.groupby(by=\"invasive\").count()[\"patient_id\"]\ncount_invasive.reset_index().head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:39.086301Z","iopub.execute_input":"2023-02-06T01:11:39.087473Z","iopub.status.idle":"2023-02-06T01:11:39.116843Z","shell.execute_reply.started":"2023-02-06T01:11:39.087427Z","shell.execute_reply":"2023-02-06T01:11:39.115687Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per invasive\")\nsns.barplot(data=count_invasive.reset_index(),x=\"invasive\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:39.11858Z","iopub.execute_input":"2023-02-06T01:11:39.118951Z","iopub.status.idle":"2023-02-06T01:11:39.350731Z","shell.execute_reply.started":"2023-02-06T01:11:39.118918Z","shell.execute_reply":"2023-02-06T01:11:39.349809Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The BIRADS variable represents that it was a reduced number of patients that required a follow-up analysis and that got a positive result of cancer:","metadata":{}},{"cell_type":"code","source":"count_BIRADS=sample_table.groupby(by=\"BIRADS\").count()[\"patient_id\"]\ncount_BIRADS.reset_index().head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:39.352232Z","iopub.execute_input":"2023-02-06T01:11:39.352622Z","iopub.status.idle":"2023-02-06T01:11:39.380103Z","shell.execute_reply.started":"2023-02-06T01:11:39.35259Z","shell.execute_reply":"2023-02-06T01:11:39.37894Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per BIRAIDS\")\nsns.barplot(data=count_BIRADS.reset_index(),x=\"BIRADS\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:39.381493Z","iopub.execute_input":"2023-02-06T01:11:39.381889Z","iopub.status.idle":"2023-02-06T01:11:39.643746Z","shell.execute_reply.started":"2023-02-06T01:11:39.381858Z","shell.execute_reply":"2023-02-06T01:11:39.642618Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The patients with implants were low with a similar proportion of the previous variables, but with no initial relationship with cancer:","metadata":{}},{"cell_type":"code","source":"count_implants=sample_table.groupby(by=\"implant\").count()[\"patient_id\"]\ncount_implants.reset_index().head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:39.645574Z","iopub.execute_input":"2023-02-06T01:11:39.645935Z","iopub.status.idle":"2023-02-06T01:11:39.674147Z","shell.execute_reply.started":"2023-02-06T01:11:39.645903Z","shell.execute_reply":"2023-02-06T01:11:39.673109Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per implants\")\nsns.barplot(data=count_implants.reset_index(),x=\"implant\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:39.677188Z","iopub.execute_input":"2023-02-06T01:11:39.677546Z","iopub.status.idle":"2023-02-06T01:11:40.116418Z","shell.execute_reply.started":"2023-02-06T01:11:39.677516Z","shell.execute_reply":"2023-02-06T01:11:40.115532Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The density variable shows that most of the patients have a tissue density in the categories B and C while the number with D is the lowest.","metadata":{}},{"cell_type":"code","source":"count_density=sample_table.groupby(by=\"density\").count()[\"patient_id\"]\ncount_density.reset_index().head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:40.120178Z","iopub.execute_input":"2023-02-06T01:11:40.121051Z","iopub.status.idle":"2023-02-06T01:11:40.15046Z","shell.execute_reply.started":"2023-02-06T01:11:40.121011Z","shell.execute_reply":"2023-02-06T01:11:40.149574Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per density\")\nsns.barplot(data=count_density.reset_index(),x=\"density\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:40.152091Z","iopub.execute_input":"2023-02-06T01:11:40.152832Z","iopub.status.idle":"2023-02-06T01:11:40.338241Z","shell.execute_reply.started":"2023-02-06T01:11:40.152785Z","shell.execute_reply":"2023-02-06T01:11:40.33702Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"After, with the machine_id it was found a total of 10 machines, with the number 49 being the most representative.","metadata":{}},{"cell_type":"code","source":"count_machine=sample_table.groupby(by=\"machine_id\").count()[\"patient_id\"]\ncount_machine.reset_index().head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:40.339862Z","iopub.execute_input":"2023-02-06T01:11:40.34019Z","iopub.status.idle":"2023-02-06T01:11:40.366864Z","shell.execute_reply.started":"2023-02-06T01:11:40.34016Z","shell.execute_reply":"2023-02-06T01:11:40.365842Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per machine_id\")\nsns.barplot(data=count_machine.reset_index(),x=\"machine_id\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:40.36799Z","iopub.execute_input":"2023-02-06T01:11:40.368279Z","iopub.status.idle":"2023-02-06T01:11:40.612382Z","shell.execute_reply.started":"2023-02-06T01:11:40.368252Z","shell.execute_reply":"2023-02-06T01:11:40.611076Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Finally, the difficult negative cases show that only 7000 of 54000 images correspond to a difficult final analysis:","metadata":{}},{"cell_type":"code","source":"# difficult_negative_case\ncount_difficult=sample_table.groupby(by=\"difficult_negative_case\").count()[\"patient_id\"]\ncount_difficult.reset_index().head()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:40.614137Z","iopub.execute_input":"2023-02-06T01:11:40.614612Z","iopub.status.idle":"2023-02-06T01:11:40.64516Z","shell.execute_reply.started":"2023-02-06T01:11:40.614567Z","shell.execute_reply":"2023-02-06T01:11:40.644243Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nplt.grid()\nplt.title(\"Number of images per difficult_negative_case\")\nsns.barplot(data=count_difficult.reset_index(),x=\"difficult_negative_case\",y=\"patient_id\")\nplt.ylabel(\"Total images\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:40.64663Z","iopub.execute_input":"2023-02-06T01:11:40.647299Z","iopub.status.idle":"2023-02-06T01:11:40.873198Z","shell.execute_reply.started":"2023-02-06T01:11:40.647258Z","shell.execute_reply":"2023-02-06T01:11:40.871236Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Additionally, it was checked the sample test table, corresponded with the properties described in the documentation.","metadata":{}},{"cell_type":"code","source":"sample_test=pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/test.csv\")\nsample_test","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:40.874539Z","iopub.execute_input":"2023-02-06T01:11:40.874922Z","iopub.status.idle":"2023-02-06T01:11:40.890929Z","shell.execute_reply.started":"2023-02-06T01:11:40.87489Z","shell.execute_reply":"2023-02-06T01:11:40.889615Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Correlation and additional analysis\n\nTo analyze if there is a correlation with the table data, the following heatmap was built. Here it shows that the strongest correlation corresponds to cancer, biopsy, and invasive variables.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\nsns.heatmap(sample_table.corr(), cmap=\"YlGnBu\", annot=True)","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:40.892577Z","iopub.execute_input":"2023-02-06T01:11:40.892941Z","iopub.status.idle":"2023-02-06T01:11:41.905888Z","shell.execute_reply.started":"2023-02-06T01:11:40.892908Z","shell.execute_reply":"2023-02-06T01:11:41.904693Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"To complement this, the following bar plots show that as in previous plots, the biopsy does have a relation to cancer detection, as it is one of the most specific procedures to check if there is abnormal tissue.","metadata":{}},{"cell_type":"code","source":"sns.countplot(data=sample_table, x=\"cancer\", hue=\"biopsy\");","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:41.907621Z","iopub.execute_input":"2023-02-06T01:11:41.907955Z","iopub.status.idle":"2023-02-06T01:11:42.143722Z","shell.execute_reply.started":"2023-02-06T01:11:41.907925Z","shell.execute_reply":"2023-02-06T01:11:42.142419Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Plotting of images and association\n\nFinally, a sample image was plotted with the pydicom library, where the final shape corresponds to 2776x2082 pixels.","metadata":{}},{"cell_type":"code","source":"# https://www.geeksforgeeks.org/view-dicom-images-using-pydicom-and-matplotlib/\nimport pydicom\nimport pydicom.data\nds = pydicom.dcmread(\"/kaggle/input/rsna-breast-cancer-detection/test_images/10008/1591370361.dcm\")\nplt.imshow(ds.pixel_array, cmap=plt.cm.bone)  # set the color map to bone\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:42.145427Z","iopub.execute_input":"2023-02-06T01:11:42.145834Z","iopub.status.idle":"2023-02-06T01:11:43.529224Z","shell.execute_reply.started":"2023-02-06T01:11:42.145801Z","shell.execute_reply":"2023-02-06T01:11:43.528398Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ds.pixel_array.shape","metadata":{"execution":{"iopub.status.busy":"2023-02-06T01:11:43.530622Z","iopub.execute_input":"2023-02-06T01:11:43.531766Z","iopub.status.idle":"2023-02-06T01:11:43.5385Z","shell.execute_reply.started":"2023-02-06T01:11:43.531727Z","shell.execute_reply":"2023-02-06T01:11:43.537403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Final Insight\n\nThis initial approach helped to recognize trends related to the cancer diagnosis process and at the same time shows that there is a challenge in predicting the probability of cancer.\n\nThe following processes will be related to the prediction model construction, with the use of a GPU and with caution of the RAM memory and time limits. To complement this, the following bar plots show that as in previous plots, the biopsy does have a relation to cancer detection, as it is one of the most specific procedures to check if there is abnormal tissue.","metadata":{}}]}