{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"import os\nimport gc\nimport json\nimport math\nimport cv2\nimport PIL\nfrom PIL import Image\nimport numpy as np\n\nimport matplotlib.pyplot as plt\nimport pandas as pd\nimport seaborn as sns\n\nimport scipy\nfrom tqdm import tqdm\nimport pandas as pd\n\n%matplotlib inline\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Reading data","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train = pd.read_csv(\"../input/siim-isic-melanoma-classification/train.csv\")\ndf_test = pd.read_csv(\"../input/siim-isic-melanoma-classification/test.csv\")\nm_train = df_train.shape[0]\nprint('number of training images ',m_train)\ndf_train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"m_test = df_test.shape[0]\nprint('number of testing images ',m_test)\ndf_test.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train.describe(include ='O')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Classes\n","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"malignant_df = df_train[df_train['target']==1]\nprint('number of malignant images ', len(malignant_df))\nbenign_df = df_train[df_train['target']==0]\nprint('number of benign images ', len(benign_df))\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# classes\nsns.set_style('whitegrid')\nsns.countplot(x='benign_malignant',data=df_train)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Images Visualization","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"### Samples of malignant images\n","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig,axes = plt.subplots(4,4,figsize=[10,10])\nfor i,iax in enumerate( axes.flatten()):\n    ind = np.random.randint(0,500)\n    fname = malignant_df.image_name.tolist()[ind]\n    img = Image.open('../input/siim-isic-melanoma-classification/jpeg/train/'+fname+'.jpg')\n    iax.imshow(img)\n    iax.set_xticks([])\n    iax.set_yticks([])\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Samples of benign images\n","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig,axes = plt.subplots(4,4,figsize=[10,10])\nfor i,iax in enumerate( axes.flatten()):\n    ind = np.random.randint(0,10000)\n    fname = benign_df.image_name.tolist()[ind]\n    img = Image.open('../input/siim-isic-melanoma-classification/jpeg/train/'+fname+'.jpg')\n    iax.imshow(img)\n    iax.set_xticks([])\n    iax.set_yticks([])\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Histogram of benign  images with sex","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(x='sex',data=benign_df)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Histogram of malignant  images with sex","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(x='sex',data=malignant_df)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Histogram of benign  images with Age","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"benign_df['age_approx'].hist(bins = 16)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Histogram of malignant  images with Age\n","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"malignant_df['age_approx'].hist(bins = 16)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize=(12, 7))\nsns.boxplot(x='target',y='age_approx',data=df_train,palette='winter')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Histogram of benign images with diagnosis","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(y='diagnosis',data=benign_df,orient = 'h')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"benign_df.groupby('diagnosis')['image_name'].nunique()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## The diagnosis of malignant images is melanoma ","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"malignant_df.groupby('diagnosis')['image_name'].nunique()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Histogram of benign images with images' location","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(y='anatom_site_general_challenge',data=benign_df,orient = 'h')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Histogram of malignant images with images' location","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(y='anatom_site_general_challenge',data=malignant_df,orient = 'h')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Missing values","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"# training\nprint(df_train.isnull().sum())\nprint(len(df_train))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# testing\nprint(df_test.isnull().sum())\nprint(m_test)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"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":4,"nbformat_minor":4}