{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\ntrain_data = pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/train.csv\")\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-12-27T13:02:32.601959Z","iopub.execute_input":"2022-12-27T13:02:32.602436Z","iopub.status.idle":"2022-12-27T13:02:32.68353Z","shell.execute_reply.started":"2022-12-27T13:02:32.602379Z","shell.execute_reply":"2022-12-27T13:02:32.682105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport plotly.figure_factory as ff\nimport plotly.express as px\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:02:35.863002Z","iopub.execute_input":"2022-12-27T13:02:35.863439Z","iopub.status.idle":"2022-12-27T13:02:35.870085Z","shell.execute_reply.started":"2022-12-27T13:02:35.863401Z","shell.execute_reply":"2022-12-27T13:02:35.868594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"type(train_data)","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:02:39.247283Z","iopub.execute_input":"2022-12-27T13:02:39.247682Z","iopub.status.idle":"2022-12-27T13:02:39.25596Z","shell.execute_reply.started":"2022-12-27T13:02:39.24765Z","shell.execute_reply":"2022-12-27T13:02:39.254525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:02:43.570921Z","iopub.execute_input":"2022-12-27T13:02:43.571298Z","iopub.status.idle":"2022-12-27T13:02:43.591083Z","shell.execute_reply.started":"2022-12-27T13:02:43.571266Z","shell.execute_reply":"2022-12-27T13:02:43.589665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:02:47.948874Z","iopub.execute_input":"2022-12-27T13:02:47.949309Z","iopub.status.idle":"2022-12-27T13:02:47.955882Z","shell.execute_reply.started":"2022-12-27T13:02:47.949271Z","shell.execute_reply":"2022-12-27T13:02:47.954777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.columns","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:02:51.880177Z","iopub.execute_input":"2022-12-27T13:02:51.880601Z","iopub.status.idle":"2022-12-27T13:02:51.889161Z","shell.execute_reply.started":"2022-12-27T13:02:51.880567Z","shell.execute_reply":"2022-12-27T13:02:51.887634Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.info","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:02:54.587382Z","iopub.execute_input":"2022-12-27T13:02:54.587922Z","iopub.status.idle":"2022-12-27T13:02:54.611835Z","shell.execute_reply.started":"2022-12-27T13:02:54.587873Z","shell.execute_reply":"2022-12-27T13:02:54.610405Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:02:58.775169Z","iopub.execute_input":"2022-12-27T13:02:58.775576Z","iopub.status.idle":"2022-12-27T13:02:58.804993Z","shell.execute_reply.started":"2022-12-27T13:02:58.775542Z","shell.execute_reply":"2022-12-27T13:02:58.804116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:03:02.432466Z","iopub.execute_input":"2022-12-27T13:03:02.433669Z","iopub.status.idle":"2022-12-27T13:03:02.452081Z","shell.execute_reply.started":"2022-12-27T13:03:02.43362Z","shell.execute_reply":"2022-12-27T13:03:02.450833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.describe()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:03:06.737612Z","iopub.execute_input":"2022-12-27T13:03:06.738035Z","iopub.status.idle":"2022-12-27T13:03:06.794883Z","shell.execute_reply.started":"2022-12-27T13:03:06.737997Z","shell.execute_reply":"2022-12-27T13:03:06.793661Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.corr()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:03:10.073079Z","iopub.execute_input":"2022-12-27T13:03:10.073556Z","iopub.status.idle":"2022-12-27T13:03:10.115088Z","shell.execute_reply.started":"2022-12-27T13:03:10.073514Z","shell.execute_reply":"2022-12-27T13:03:10.114145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(train_data['age'])\nplt.title(\"Age of participants vs their count\")","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:03:14.102792Z","iopub.execute_input":"2022-12-27T13:03:14.104471Z","iopub.status.idle":"2022-12-27T13:03:15.072226Z","shell.execute_reply.started":"2022-12-27T13:03:14.104424Z","shell.execute_reply":"2022-12-27T13:03:15.070988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.cancer.unique()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['cancer'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:03:21.791121Z","iopub.execute_input":"2022-12-27T13:03:21.791659Z","iopub.status.idle":"2022-12-27T13:03:21.801515Z","shell.execute_reply.started":"2022-12-27T13:03:21.79161Z","shell.execute_reply":"2022-12-27T13:03:21.800577Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"benign = len(train_data[\"cancer\"][train_data.cancer == 1])\nmalignant = len(train_data.cancer[train_data.cancer == 0])\n\narr = np.array([benign, malignant])\nlabels = [\"tumor is benign\", \"tumor is malignant\"]\n\nplt.pie(arr, labels=labels, shadow=True,autopct='%1.2f%%')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:49:55.926275Z","iopub.execute_input":"2022-12-27T13:49:55.926707Z","iopub.status.idle":"2022-12-27T13:49:56.057093Z","shell.execute_reply.started":"2022-12-27T13:49:55.926672Z","shell.execute_reply":"2022-12-27T13:49:56.055562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(train_data['cancer'])\nplt.xlabel('tumor')\nplt.ylabel('No of people')\nplt.title('cancer vs Number of people')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:09:55.615301Z","iopub.execute_input":"2022-12-27T13:09:55.615788Z","iopub.status.idle":"2022-12-27T13:09:55.794294Z","shell.execute_reply.started":"2022-12-27T13:09:55.615747Z","shell.execute_reply":"2022-12-27T13:09:55.793304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv('/kaggle/input/rsna-breast-cancer-detection/train.csv')\nsample_submission = pd.read_csv('/kaggle/input/rsna-breast-cancer-detection/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:16:43.732698Z","iopub.execute_input":"2022-12-27T13:16:43.73396Z","iopub.status.idle":"2022-12-27T13:16:43.823523Z","shell.execute_reply.started":"2022-12-27T13:16:43.733906Z","shell.execute_reply":"2022-12-27T13:16:43.822387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pydicom\nfrom os import listdir\n\ndcmpath = \"/kaggle/input/rsna-breast-cancer-detection/train_images/10006/1459541791.dcm\"\nimg = pydicom.dcmread(dcmpath)\nimg","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:32:40.864704Z","iopub.execute_input":"2022-12-27T13:32:40.865142Z","iopub.status.idle":"2022-12-27T13:32:40.881843Z","shell.execute_reply.started":"2022-12-27T13:32:40.865108Z","shell.execute_reply":"2022-12-27T13:32:40.880797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['BIRADS'] = train_data['BIRADS'].fillna(\"Not Available\")\ntrain_data['density'] = train_data['density'].fillna('x')  #x = NaN","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:43:13.427452Z","iopub.execute_input":"2022-12-27T13:43:13.428003Z","iopub.status.idle":"2022-12-27T13:43:13.442816Z","shell.execute_reply.started":"2022-12-27T13:43:13.427956Z","shell.execute_reply":"2022-12-27T13:43:13.441852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['BIRADS'].isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:43:43.875184Z","iopub.execute_input":"2022-12-27T13:43:43.875678Z","iopub.status.idle":"2022-12-27T13:43:43.887436Z","shell.execute_reply.started":"2022-12-27T13:43:43.875641Z","shell.execute_reply":"2022-12-27T13:43:43.886131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['density'].isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T13:44:07.201635Z","iopub.execute_input":"2022-12-27T13:44:07.202089Z","iopub.status.idle":"2022-12-27T13:44:07.215001Z","shell.execute_reply.started":"2022-12-27T13:44:07.202052Z","shell.execute_reply":"2022-12-27T13:44:07.213228Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Import label encoder\nfrom sklearn import preprocessing\n# label_encoder object knows how to understand word labels.\nlabel_encoder = preprocessing.LabelEncoder()\n# Encode labels in column 'species'.\ntrain_data['laterality']= label_encoder.fit_transform(train_data['laterality'])\ntrain_data['laterality'].unique()\n","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:00:37.876823Z","iopub.execute_input":"2022-12-27T14:00:37.877395Z","iopub.status.idle":"2022-12-27T14:00:37.903999Z","shell.execute_reply.started":"2022-12-27T14:00:37.877347Z","shell.execute_reply":"2022-12-27T14:00:37.902683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn import preprocessing\nlabel_encoder = preprocessing.LabelEncoder()\n\ntrain_data['view']= label_encoder.fit_transform(train_data['view'])\n\ntrain_data['view'].unique()\n","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:02:29.185489Z","iopub.execute_input":"2022-12-27T14:02:29.185925Z","iopub.status.idle":"2022-12-27T14:02:29.209588Z","shell.execute_reply.started":"2022-12-27T14:02:29.185891Z","shell.execute_reply":"2022-12-27T14:02:29.208188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:04:06.187503Z","iopub.execute_input":"2022-12-27T14:04:06.188954Z","iopub.status.idle":"2022-12-27T14:04:06.199345Z","shell.execute_reply.started":"2022-12-27T14:04:06.188896Z","shell.execute_reply":"2022-12-27T14:04:06.198363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(train_data['age'])","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:15:17.310432Z","iopub.execute_input":"2022-12-27T14:15:17.310836Z","iopub.status.idle":"2022-12-27T14:15:17.558797Z","shell.execute_reply.started":"2022-12-27T14:15:17.310803Z","shell.execute_reply":"2022-12-27T14:15:17.557639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(train_data['cancer'])","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:15:59.292528Z","iopub.execute_input":"2022-12-27T14:15:59.292992Z","iopub.status.idle":"2022-12-27T14:15:59.524626Z","shell.execute_reply.started":"2022-12-27T14:15:59.292958Z","shell.execute_reply":"2022-12-27T14:15:59.523401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(train_data['implant'])","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:16:45.507851Z","iopub.execute_input":"2022-12-27T14:16:45.508629Z","iopub.status.idle":"2022-12-27T14:16:45.734244Z","shell.execute_reply.started":"2022-12-27T14:16:45.508584Z","shell.execute_reply":"2022-12-27T14:16:45.732902Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.plot(x='age', y='cancer', kind='hist')","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:19:57.499371Z","iopub.execute_input":"2022-12-27T14:19:57.500754Z","iopub.status.idle":"2022-12-27T14:19:57.785043Z","shell.execute_reply.started":"2022-12-27T14:19:57.500697Z","shell.execute_reply":"2022-12-27T14:19:57.783859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.plot(x='cancer', y='implant', kind='hist')","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:21:04.717708Z","iopub.execute_input":"2022-12-27T14:21:04.718802Z","iopub.status.idle":"2022-12-27T14:21:04.981379Z","shell.execute_reply.started":"2022-12-27T14:21:04.718737Z","shell.execute_reply":"2022-12-27T14:21:04.980109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.plot(kind='scatter', x='implant', y='density', \\\n        color='dodgerblue', figsize=(30,10), s=40)","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:44:47.974559Z","iopub.execute_input":"2022-12-27T14:44:47.974945Z","iopub.status.idle":"2022-12-27T14:44:48.482886Z","shell.execute_reply.started":"2022-12-27T14:44:47.974914Z","shell.execute_reply":"2022-12-27T14:44:48.48167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['age'].value_counts().head().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:51:07.468775Z","iopub.execute_input":"2022-12-27T14:51:07.469177Z","iopub.status.idle":"2022-12-27T14:51:07.675896Z","shell.execute_reply.started":"2022-12-27T14:51:07.469146Z","shell.execute_reply":"2022-12-27T14:51:07.674649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['density'].value_counts().head().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:52:04.108855Z","iopub.execute_input":"2022-12-27T14:52:04.109289Z","iopub.status.idle":"2022-12-27T14:52:04.321152Z","shell.execute_reply.started":"2022-12-27T14:52:04.109258Z","shell.execute_reply":"2022-12-27T14:52:04.320064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['invasive'].value_counts().head().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:56:37.548233Z","iopub.execute_input":"2022-12-27T14:56:37.549178Z","iopub.status.idle":"2022-12-27T14:56:37.739579Z","shell.execute_reply.started":"2022-12-27T14:56:37.549133Z","shell.execute_reply":"2022-12-27T14:56:37.738195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['BIRADS'].value_counts().head().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:57:41.222155Z","iopub.execute_input":"2022-12-27T14:57:41.222692Z","iopub.status.idle":"2022-12-27T14:57:41.437054Z","shell.execute_reply.started":"2022-12-27T14:57:41.222652Z","shell.execute_reply":"2022-12-27T14:57:41.43622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = sns.lineplot(x=\"density\", y=\"implant\", train_data=train_data)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-27T14:49:25.477817Z","iopub.execute_input":"2022-12-27T14:49:25.478201Z","iopub.status.idle":"2022-12-27T14:49:25.509346Z","shell.execute_reply.started":"2022-12-27T14:49:25.478169Z","shell.execute_reply":"2022-12-27T14:49:25.507762Z"},"trusted":true},"execution_count":null,"outputs":[]}]}