Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to forecast when x axis is month(booking date). Forecast seems not to work. #108

Open
labasmuse opened this issue Sep 2, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@labasmuse
Copy link

Is your feature request related to a problem? Please describe.
Your instruction for the app "Sample_App_Forecasting_Simple" is very clear. The installation and the trial of the app immediately worked. Great!
However I do not know what to do when I have for the y axis an aggreation function where the Month_Date is not included: for example: " (sum({$<FSA = {EE10}>}Saldo_Buchung)+sum({$<FSA = {EA10}>}Saldo_Buchung))/sum({$<FSA = {EE10}>}Saldo_Buchung)". Here the percentual gross margin is calculated. The x axis is Month(Booking date).

Describe the solution you'd like
More examples. I think the PyTools.Prophet formula is not well explained. What do the parameters mean exactly? Easy examples would help a lot.

How to do a forecast for Month ()-functions.... I would be happy to get help....

Thank you in advance.

Kind regards
Andy
1
2
3
4

@labasmuse labasmuse added the enhancement New feature or request label Sep 2, 2020
@nabeel-oz
Copy link
Owner

Hi @labasmuse , have you seen the documentation here: https://github.com/nabeel-oz/qlik-py-tools/blob/master/docs/Prophet.md

You can do a monthly forecast by passing the freq=M parameter to the PyTools.Prophet function. You do need to choose a granularity for the forecast, so having a drill down dimension would complicate things.

@labasmuse
Copy link
Author

labasmuse commented Sep 3, 2020 via email

@nabeel-oz
Copy link
Owner

Hi Andy,

For the monthly granularity you're currently using the Month function which returns an integer. The Prophet function requires a datetime dimension so you'll need to use MonthName, MonthStart or MonthEnd instead. Also, your line chart seems to have the Year as a dimension. The chart to plot the forecast should take the form of one datetime dimension and multiple measures (actual, forecast, etc.).

I'd recommend that you first build separate charts for monthly and daily forecasts to decide which granularity works best for your app. The measure for the monthly forecast may look like this:

PyTools.Prophet(MonthName([Buchungsdatum]), (sum({$<FSA = {EE10}>}Saldo_Buchung)+sum({$<FSA = {EA10}>}Saldo_Buchung))/sum({$<FSA = {EE10}>}Saldo_Buchung), 'freq=M, return=yhat, debug=True')

And the daily one like this:

PyTools.Prophet([Buchungsdatum], (sum({$<FSA = {EE10}>}Saldo_Buchung)+sum({$<FSA = {EA10}>}Saldo_Buchung))/sum({$<FSA = {EE10}>}Saldo_Buchung), 'freq=D, return=yhat, debug=True')

A drilldown dimension going from month to date won't work well for forecasting as selecting a month would generate predictions based on just one month of data, which won't be of much use.

If you want to calculate a daily forecast and roll it up to the monthly level, you could use a time-aware line chart with a continuous axis and let Qlik do the aggregation. You could also pre-calculate the forecast through the Qlik load script.

By the way, your value for changepoint_prior_scale is very high. I'd keep it close to the default value of 0.05 initially.

Nabeel

@labasmuse
Copy link
Author

labasmuse commented Sep 7, 2020 via email

@nabeel-oz
Copy link
Owner

nabeel-oz commented Sep 9, 2020

Hi Andy,

The image you posted doesn't show up on GitHub. You seem to be using MonthName in the measure, but MonthStart in the dimension. The function you use in the measure should match the dimension.

The future periods need to be added in a way that if you put your dimension and actual values (the measure part of the forecast expression) in a table you get one row for each month, will NULL values for the future months. The left join may not be doing what you expect. You could also use the forecasting calendar approach described in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants