Created
September 17, 2013 17:46
-
-
Save randyzwitch/6597905 to your computer and use it in GitHub Desktop.
elbow plot
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
#Calculate lm's for emphasis | |
lm(cost_df$cost[1:10] ~ cost_df$cluster[1:10]) | |
lm(cost_df$cost[10:19] ~ cost_df$cluster[10:19]) | |
lm(cost_df$cost[20:100] ~ cost_df$cluster[20:100]) | |
cost_df$fitted <- ifelse(cost_df$cluster <10, (19019.9 - 550.9*cost_df$cluster), | |
ifelse(cost_df$cluster <20, (15251.5 - 116.5*cost_df$cluster), | |
(13246.1 - 35.9*cost_df$cluster))) | |
#Cost plot | |
ggplot(data=cost_df, aes(x=cluster, y=cost, group=1)) + | |
theme_bw(base_family="Garamond") + | |
geom_line(colour = "darkgreen") + | |
theme(text = element_text(size=20)) + | |
ggtitle("Reduction In Cost For Values of 'k'\n") + | |
xlab("\nClusters") + | |
ylab("Within-Cluster Sum of Squares\n") + | |
scale_x_continuous(breaks=seq(from=0, to=100, by= 10)) + | |
geom_line(aes(y= fitted), linetype=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks