Created
September 22, 2015 15:21
-
-
Save MarkEdmondson1234/43548374576916f22296 to your computer and use it in GitHub Desktop.
For Machine Learning and Web Analytics blogpost http://markedmondson.me/intro-to-machine-learning-with-web-analytics-random-forests-and-k-means
This file contains 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
kResults <- data.frame(k_data, cluster = k$cluster) | |
## Transform data for columns of cluster, rows of Sku with value of mean total for each | |
rl <- as.data.frame(lapply(1:4, function(x){ r3 <- kResults[kResults$cluster == x, | |
setdiff(names(kResults), 'cluster')] | |
r4 <- colSums(r3) / nrow(r3) | |
r4 | |
})) | |
names(rl) <- paste("cluster",1:4) | |
## plot using d3heatmap library | |
library(d3heatmap) | |
d3heatmap(rl, theme="dark", scale = 'row') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment