Last active
January 3, 2019 08:51
-
-
Save wheresalice/ae32fb19a785f3a97a90060ae8b30e07 to your computer and use it in GitHub Desktop.
Predict future growth of your Slack org using R and Facebook's Prophet library
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
library("prophet") | |
# Import the CSV file generated from my.slack.com/stats | |
slack <- read.csv("~/tmp/slack.csv") | |
# Do some cleaning up | |
clean_slack <- slack[slack$Total.Users != 0,] | |
dates <- as.POSIXct(strptime(clean_slack$Date, "%Y-%m-%d")) | |
# Pick which variable to predict (Total.Users is most useful) | |
prophet_df <- data.frame(dates, clean_slack$Total.Users) | |
# Make a dataframe that prophet is happy with | |
names(prophet_df) =c("ds","y") | |
m <- prophet(prophet_df) | |
# Predict the next two years | |
future = make_future_dataframe(m, periods = 365 * 2) | |
forecast = predict(m, future) | |
# Generate a dataframe with predicted values | |
future_df <- forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')] | |
# Plot the graph | |
plot(m, forecast) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment