Hi there, I am trying to utilize the budget allocation function using pymc-marketing version 0.7.0…
I put the total budget as 5 (representing 5 Million) for 2 weeks… Below are my code… The result came out to weird decimal points and did not add up to 5… What could be happening here?
Thanks in advanced!
total_budget = 5
# Define your channels
channels = spend_cols
# The initial split per channel
budget_per_channel = total_budget / len(channels)
# Initial budget per channel as dictionary.
initial_budget_dict = {channel: budget_per_channel for channel in channels}
# bounds for each channel
budget_bounds = {'spend_youtube': [0.5, 2],
'spend_linkedin': [0.5, 1],
'spend_ctv': [0.01, 1],
'spend_facebook': [0.01, 1],
'spend_other_display_prospecting': [0.01, 1],
'spend_nonbrand_bing_low': [0.01, 1],
'spend_nonbrand_google_low': [0.01, 1],
'spend_pinterest': [0.01, 1],
'spend_radio': [0.01, 2],
'spend_dm': [1, 4]
}
response = mmm.allocate_budget_to_maximize_response(
budget=total_budget,
num_days=2,
time_granularity="weekly",
budget_bounds=budget_bounds,
)
budgetalloc=mmm.optimal_allocation_dict
budgetalloc
Hi @JenniferSiwu ,
I am facing a similar issue as well and then I started to retest my model and question the rsq of my model. I would love help here as well.
Hi @Alfredo_Delgado
Thanks for the update - I tried this as I was also facing a similar issue but even after rescaling the the budget splits don’t add up to the total (500K).
Here’s the code and output that I am getting. Are you facing something similar @JenniferSiwu
total_budget = 500000
hey both @Alfredo_Delgado@YT19 , I’m running into another issue with the budget_bounds… it seems like the minimizer isn’t really taking into consideration the lower bound constraints… I put minimum constraint at 100K and the optimizer still outputted ~1K for some channels… Are you experiencing this as well?
As for the channel_contribution plot, is it based on the optimal spend level outputted by then optimizer?
@JenniferSiwu have you looked at the saturation curves? Maybe your bounds are too high and are above the inflection and saturation points.
Also, the response vs spent chart looks odd. Small spend gets a high contribution, and high spend gets small contribution so I suspect something is wrong in your model
My problem is the same but I am sure that it is not the answer if there will be not point to spend more then if I increase the hole budget, the budget allocation should not increase. In fact - it does.
Second thing - example notebook suggest it should allocate hole budget as the next step is limiting the budget based on saturation curves to show that it almost doesn’t affect outcome.
Finally and the most important, in library code it is impossible to not allocate hole budget, from budget_allocation.py
Hi All, I am facing the same issue. Even with lower bound constraints, I am getting less budget. Were you able to resolve this issue? @JenniferSiwu@Alfredo_Delgado
I just realised that the below will never be equal to the budget to allocate because the budget is scaled using the max channel transformer scaler self.channel_transformer["scaler"].scale_.max()
So if we want to get the re-scaled allocated budget from self.optimal_allocation_dict we need to use the same scaler. Note the extra .max() below
Got it, also to confirm how would the model understand the granularity. If the data is on weekly level and we would want to predict for 12 weeks, how would that be taken into consideration? Do you happen to have any idea on it?
I modified the code to include max() at the end for optimized budget allocation. In the allocate_budget_to_maximize_response() function, I set the budget per unit (e.g., for a total budget of 50 over 10 weeks, I used 5 as the budget). However, after running the allocation, one channel gets the maximum budget while the rest are assigned the minimum values.
Could you clarify how the min and max bounds work and what values should be set to achieve a more balanced budget allocation?
Indeed, the budget that goes into the optimizer and the bounds is per unit of time. If you set a budget of 5 dollars and you have 5 weeks, the total is 25 dollars for the 5 weeks.
If you have a budget bound the 10 for each channel, basically that channel should not spend more than 10*N weeks (days or months) based on your time unit. @VT02