{"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":"markdown","source":"# Explorations\n\n* Largely based on the work by https://www.kaggle.com/code/datark1/eda-images-processing-and-exploration\n","metadata":{}},{"cell_type":"code","source":"# Read in csvs\nimport pandas as pd\ntrain_df = pd.read_csv('../input/mayo-clinic-strip-ai/train.csv')\ntest_df = pd.read_csv('../input/mayo-clinic-strip-ai/test.csv')\nother_df = pd.read_csv('../input/mayo-clinic-strip-ai/other.csv')\n\nprint(train_df.sample(3))\nprint(test_df.sample(3))\nprint(other_df.sample(3))","metadata":{"execution":{"iopub.status.busy":"2022-09-01T20:14:28.876509Z","iopub.execute_input":"2022-09-01T20:14:28.877136Z","iopub.status.idle":"2022-09-01T20:14:28.973159Z","shell.execute_reply.started":"2022-09-01T20:14:28.876986Z","shell.execute_reply":"2022-09-01T20:14:28.971725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#numerically understand what is in the csvs\n\nprint(train_df.describe())\nprint(test_df.describe())\nprint(other_df.describe())","metadata":{"execution":{"iopub.status.busy":"2022-09-01T20:14:28.975145Z","iopub.execute_input":"2022-09-01T20:14:28.976343Z","iopub.status.idle":"2022-09-01T20:14:29.021775Z","shell.execute_reply.started":"2022-09-01T20:14:28.976297Z","shell.execute_reply":"2022-09-01T20:14:29.020602Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#visually understand what is in the csvs\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# target variable distribution\nlabels = train_df.groupby('label')['label'].count()\n#labels = labels.reset_index(drop=True)\nprint(\"Labels\", labels)\n\n## target variable distribution\ncenters = train_df.groupby('center_id')['center_id'].count()\nprint(\"Centers\", centers)\n\nplt.style.use('Solarize_Light2')\nfig, ax = plt.subplots(1,2, figsize=(16,5))\n\nsns.barplot(x=labels.index, y=labels.values, ax=ax[0])\nax[0].set_title(\"Distribution of a target variable\"), ax[0].set_ylabel(\"%\")\n\nsns.barplot(x=centers.index, y=centers.values, ax=ax[1])\nax[1].set_title(\"Images per clinic center\"), ax[1].set_ylabel(\"%\")","metadata":{"execution":{"iopub.status.busy":"2022-09-01T20:14:29.023308Z","iopub.execute_input":"2022-09-01T20:14:29.023733Z","iopub.status.idle":"2022-09-01T20:14:30.211592Z","shell.execute_reply.started":"2022-09-01T20:14:29.023694Z","shell.execute_reply":"2022-09-01T20:14:30.210135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# What is in those images\nfrom glob import glob\n\ntrain_images = glob(\"/kaggle/input/mayo-clinic-strip-ai/train/*\")\nprint (len(train_images))\n\nimport cv2\nimg = cv2.imread(train_images[200], cv2.IMREAD_COLOR)\nplt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-09-01T20:14:30.214309Z","iopub.execute_input":"2022-09-01T20:14:30.214768Z","iopub.status.idle":"2022-09-01T20:15:24.954906Z","shell.execute_reply.started":"2022-09-01T20:14:30.21473Z","shell.execute_reply":"2022-09-01T20:15:24.953175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\n\n# plot a histogram of the image\n\nimg_matrix_g = img[:,:,1].ravel()\nprint(img_matrix_g)\n#sns.histplot(img_matrix_g, bins=np.arange(0,255))\n\n#plt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-09-01T20:15:24.956682Z","iopub.execute_input":"2022-09-01T20:15:24.957089Z","iopub.status.idle":"2022-09-01T20:15:25.48587Z","shell.execute_reply.started":"2022-09-01T20:15:24.957053Z","shell.execute_reply":"2022-09-01T20:15:25.48429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Masking images\n\n# https://towardsdatascience.com/image-data-analysis-using-python-edddfdf128f4\n\n# Only Blue Pixel value\nblue_mask = img[:, :, 2] < 180\nblue_img = img[:, :, 2].copy()\nblue_img[blue_mask] = 0\nplt.figure(figsize=(5,5))\nplt.imshow(blue_img)","metadata":{"execution":{"iopub.status.busy":"2022-09-01T20:20:34.768701Z","iopub.execute_input":"2022-09-01T20:20:34.769223Z","iopub.status.idle":"2022-09-01T20:20:52.300036Z","shell.execute_reply.started":"2022-09-01T20:20:34.769181Z","shell.execute_reply":"2022-09-01T20:20:52.298803Z"},"trusted":true},"execution_count":null,"outputs":[]}]}