Created
March 7, 2021 08:22
-
-
Save audhiaprilliant/d372e46ef65ba6be8c728cd957192c9e to your computer and use it in GitHub Desktop.
Cluster Ensemble - Data Visualization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Group customer by their customer segment | |
| rfm_level_agg = rfm %>% | |
| group_by(`Customer Segment`) %>% | |
| summarize( | |
| Recency = mean(Recency), | |
| Frequency = mean(Frequency), | |
| `Monetary Mean` = mean(Monetary), | |
| `Monetary Count` = n(), | |
| `Marketing Action` = unique(`Marketing Action`) | |
| ) | |
| # Visualize the RFM | |
| ggplot(data = rfm)+ | |
| geom_density(aes(x = Recency), | |
| fill = '#c22d6d', | |
| col = 'white')+ | |
| labs(title = "Distribution of Customer's Recency", | |
| subtitle = 'Olist Customer Data')+ | |
| xlab('Recency')+ | |
| ylab('Density')+ | |
| theme_bw() | |
| ggplot(data = rfm)+ | |
| geom_density(aes(x = Frequency), | |
| fill = '#c22d6d', | |
| col = 'white')+ | |
| labs(title = "Distribution of Customer's Frequency", | |
| subtitle = 'Olist Customer Data')+ | |
| xlab('Frequency')+ | |
| ylab('Density')+ | |
| theme_bw() | |
| ggplot(data = rfm)+ | |
| geom_density(aes(x = Monetary), | |
| fill = '#c22d6d', | |
| col = 'white')+ | |
| labs(title = "Distribution of Customer's Monetary", | |
| subtitle = 'Olist Customer Data')+ | |
| xlab('Monetary')+ | |
| ylab('Density')+ | |
| theme_bw() | |
| # Visualize RFM Segment | |
| ggplot(rfm_level_agg, | |
| aes(area = Frequency, | |
| fill = `Customer Segment`, | |
| label = `Customer Segment`))+ | |
| geom_treemap(show.legend = FALSE)+ | |
| geom_treemap_text(fontface = 'italic', | |
| colour = 'white', | |
| place = 'centre', | |
| grow = TRUE)+ | |
| scale_fill_brewer(palette = 'Dark2') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment