1 Reply Latest reply on Dec 11, 2018 5:23 PM by Nathan Mannheimer

    using prophet to forecast

    Hunter Maxfield

      Hey forums

       

      I am trying to use the forecasting package prophet using the r integration inside of tableau.  I have learned it within R studio, but would like to extend it to tableau now.  I have looked through the different threads bora beran has answered, along with his blog post.  However, I am still having a hard time.  Here are the problems I am facing:

      • Prophet requires a column that has the metric that needs to be forecasted.  However, I want to forecast by the number of rows we have for each day.  So there isn't really a column, however it is a very easy viz to create in tableau by just adding day date to the viz, along with count(number of records).  So far, I have just created that viz, then exported to excel, then done the forecast in r studio.  I would like to make this more dynamic.
      • The first question might also answer this question, but here is my calc field with an r script:

       

      SCRIPT_REAL("library(prophet);

      df <- data.frame(ds = seq(as.Date('2017/7/1'), by = 'day', length.out = 295), y=.arg1);

      m <- prophet(df)

      future <- make_future_dataframe(m, periods=92)

      forecast <- predict (m, future)

      forecast$yhat[1:295]

      ", COUNT([Row Id]))

       

      I know this is wrong, but it was what I was able to piece together with my limited prophet and r knowledge.  This spits out an error because the number of days since 2017/7/1 is different than the length.out number.  Like I said, I am not exactly sure if this script is even headed in the right direction, so feel free to go about it a completely different ways.

       

      Any help would be greatly appreciated. 

       

      Bora Beran - Tagging you because you have answered all questions i've found about this topic. 

       

      Thanks

        • 1. Re: using prophet to forecast
          Nathan Mannheimer

          Hi Hunter,

           

          The middle section of my session at Tableau Conference on using R and Python in Tableau should answer a lot of these questions. To do forecasting with code, you have to modify the date field to expand values into the future, so that you can show both your current and forecasted values. The video walks through how:

           

          Data science applications with TabPy/R - YouTube

           

          The attached workbook is the one used in the video and has the working example in both R and Python!

           

          As long as what is in the visualization (ie days of the date field you are using) is the right level at which to aggregate the number of rows, you should be able to use COUNT([Row ID]) as your value. You can also pass your dates as a value from Tableau as seen in the above examples. I would be very interested to learn more about your use case for forecasting, so don't hesitate to reach out to me at nmannheimer@tableau.com (I'm the PM for the Advanced Analytics team which owns this feature).

           

          Sincerely,

          Nathan