---
title: "Melanoma Classification"
author: "Anshuman Moudgil"
date: "28 May 2020"
output:
  html_document:
    number_sections: true
    toc: true
    fig_width: 7
    fig_height: 4.5
    theme: readable
    highlight: tango
    code_folding: hide
---

# Data

```{r, message=FALSE, warning=FALSE}

library(ggplot2)
library(dplyr)
library(ggthemes)
library(stringr)

```

```{r, message=FALSE, warning=FALSE}

Mel <- read.csv("../input/siim-isic-melanoma-classification/train.csv", header = TRUE)
MelT <- read.csv("../input/siim-isic-melanoma-classification/test.csv", header = TRUE)

```

The **training set** is 33126 x 8 matrix and the **test set** is 10982 x 6 matrix. All most all of the data in these two files are categorical but for age group.

```{r, message=FALSE, warning=FALSE}

str(Mel)

```


```{r, message=FALSE, warning=FALSE}

str(MelT)

```

# Base Graph

```{r, message=FALSE, warning=FALSE}

Mel$sex <- as.factor(str_to_title(Mel$sex, locale = "en"))
Mel$anatom_site_general_challenge <- as.factor(str_to_title(Mel$anatom_site_general_challenge, locale = "en"))
Mel$diagnosis <- as.factor(str_to_title(Mel$diagnosis, locale = "en"))
Mel$benign_malignant <- as.factor(str_to_title(Mel$benign_malignant, locale = "en"))

MelT <- MelT %>% mutate(Case = "...and from TEST Set")
MelT$sex <- as.factor(str_to_title(MelT$sex, locale = "en"))
MelT$anatom_site_general_challenge <- as.factor(str_to_title(MelT$anatom_site_general_challenge, locale = "en"))

```

```{r, message=FALSE, warning=FALSE, fig.align='center', fig.height=5}

MT <- MelT %>% group_by(anatom_site_general_challenge, Case) %>% summarise(CountT = n())
MC <- Mel %>% group_by(anatom_site_general_challenge, diagnosis) %>% summarise(Count = n()) 

MC %>% ggplot(aes(y = diagnosis, x = anatom_site_general_challenge))+theme_tufte()+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1))+
  geom_label(aes(label = Count), size = 3.5, color = if_else(MC$diagnosis == "Melanoma","red", "grey36"))+
  geom_label(data = MT, aes(y = Case, x = anatom_site_general_challenge, label = CountT), fontface = "bold",size = 3.5, color = "steelblue", inherit.aes = FALSE)+
  labs(y = "Diagnosis", x = "Anatomy Site", title = "Number of cases per Site per Diagnosis")

```

Should you like this tiny notebook - please do **UPVOTE**.

Thanks
Cheers


