---
title: "Analyse GTZAN"
output: html_notebook
---

```{r}
source('../db/access_db.R')
library(tidyverse)
```




```{r}
excerpts_classes <- get_excerpts_classes()

excerpts_artist <- get_excerpts_artists()

classes_artists <- excerpts_classes %>%
  inner_join(excerpts_artist, by = c('ex_id')) %>%
  inner_join(get_class_names(), by = c('class_id'))

```

## Number of artists per class

```{r}
(table_class_artists <- 
  classes_artists %>%
  group_by(class) %>%
  summarise(Unique_Artists = n_distinct(artist_id)))
```

```{r fig.height=2.5, fig.width=6}
ggplot(table_class_artists, aes(class, Unique_Artists)) + 
  geom_bar(stat = 'identity') +
  scale_x_discrete(name = 'GTZAN Class') + 
  scale_y_continuous(name = 'Unique Artists',
                     breaks = c(0, 25, 50, 75),
                     limits = c(0, 75)) +
  theme_bw() +
  theme(axis.title = element_text(size = 24),
        axis.title.x = element_text(vjust = -4),
        axis.text = element_text(size = 22),
        axis.text.x = element_text(angle = 45, vjust = 0.5))


```

## Number of recordings per artist


```{r}
(table_excerpts_artists <- 
  classes_artists %>%
  group_by(class, artist_id) %>%
  summarise(rec = n_distinct(ex_id)))
```

```{r fig.height=2.5, fig.width=6}
ggplot(table_excerpts_artists, aes(class, Unique_Artists)) + 
  geom_boxplot(aes(x = class, y = rec)) +
  scale_x_discrete(name = 'GTZAN Class') + 
  scale_y_continuous(name = 'Excerpts per Artist',
                     limits=c(0,40)) +
  theme_bw() +
  theme(axis.title = element_text(size = 24),
        axis.title.x = element_text(vjust = -4),
        axis.text = element_text(size = 22),
        axis.text.x = element_text(angle = 45, vjust = 0.5))

```
