Giter VIP home page Giter VIP logo

Comments (10)

shubhamgupta568 avatar shubhamgupta568 commented on June 4, 2024 1

@entzyeung can you please share your code ? I too faced similar issue and I am able to resolve it.

from lightweight_mmm.

shubhamgupta568 avatar shubhamgupta568 commented on June 4, 2024 1

@entzyeung I can see only 2 problems i.e the way you defined prices and budget. I am using below code to find price and budget. Please try this and let me know if this fix your issue.
Note, here costs and media_data are unscaled values.

prices = costs / media_data.sum(axis=0)
budget = jnp.sum(jnp.dot(prices, media_data.mean(axis=0)))* n_time_periods

from lightweight_mmm.

shubhamgupta568 avatar shubhamgupta568 commented on June 4, 2024 1

@entzyeung The changes in price and budget i suggested earlier, was to sync your prices and budget with original data. I think the reason you might be getting same distribution can be the upper and lower bound percentages. Can you try changing that too ? May be something like upper bound 2 and lower bound 0.5.

from lightweight_mmm.

shubhamgupta568 avatar shubhamgupta568 commented on June 4, 2024 1

@entzyeung Its part of find_optimal_budgets function. By default both of them are 0.2
image

from lightweight_mmm.

entzyeung avatar entzyeung commented on June 4, 2024

Dear LMMM Team,

I want to express my sincere appreciation for the hard work you've dedicated to creating this remarkable model. It's truly impressive and has proven to be user-friendly and easy to install, unlike my previous attempt with the FB Robyn model, which I eventually abandoned due to its complexity. Discovering your model felt like a ray of sunshine after a cloudy day.

To cut to the chase, I've encountered a similar issue to that of @DongHarry-Kang. I've spent considerable time experimenting with various datasets and fine-tuning for two weeks. However, I consistently obtain similar results when calling the plot_pre_post_budget_allocation_comparison function.

I've included some sample outputs below:

Output 1

Output 2

I've thoroughly examined data quality using check_data_quality(), assessed variances with highlight_variances(), reviewed spend fractions with highlight_low_spend_fractions(), and analyzed variance inflation factors with highlight_high_vif_values(). The datasets appear to be in good shape and suitable for analysis. I even trained the best model with parameters obtained from Gridsearches. However, when it comes to the critical aspect of budget allocation, it seems there may be an issue.

Regardless of how I adjust the budget and cost parameters, the model consistently produces the same outcome: maintaining the same channel ratios while suggesting a higher budget allocation.

Allow me to illustrate this with an example.
Screenshot 2024-01-07 at 22 55 23

As you can see from the investigation, the model did suggest me different and higher budget while maintaining the same channel ratios. I am so confused that why the model not reallocating the budgets as the documentation said? and keep increasing our budget instead?
is there any params I missed? if not, is there any way to fix it?

Here is my syntax when calling the optimizatin function:

Run optimization with the parameters of choice.

solution, kpi_without_optim, previous_media_allocation = optimize_media.find_optimal_budgets(
            n_time_periods= n_time_periods,
            media_mix_model= mmm,
            extra_features= extra_features_test[:n_time_periods],# it has been scaled.
            budget= budget,
            prices= prices,
            media_scaler = media_scaler,
            target_scaler = target_scaler,
            )

Plot out pre post optimization budget allocation and predicted target variable comparison.

plot.plot_pre_post_budget_allocation_comparison(media_mix_model=mmm, 
                                                kpi_with_optim=solution['fun'], 
                                                kpi_without_optim=kpi_without_optim,
                                                optimal_buget_allocation=optimal_buget_allocation, 
                                                previous_budget_allocation=previous_budget_allocation, 
                                                figure_size=(10,10))

Thank you in advance.

from lightweight_mmm.

entzyeung avatar entzyeung commented on June 4, 2024

@shubhamgupta568 thank you for dropping by, here is the link to the notebook.
please let me know why was that and which pieces of code should be corrected. Appreciated!

from lightweight_mmm.

entzyeung avatar entzyeung commented on June 4, 2024

Thank you @shubhamgupta568 for the solution, i am running the code again now. The first run gave me the same distribution, so i am running it again. WIll keep you posted. What caused the problem? is it the dtype of the media_data?

from lightweight_mmm.

entzyeung avatar entzyeung commented on June 4, 2024

Hello @shubhamgupta568 , I have tried many times, and have made sure both costs, and media_data are unscaled jnp array. Here are the results:
Screenshot 2024-01-11 at 21 17 49
Screenshot 2024-01-11 at 21 18 07

As you can see, the budget allocation percentages are the same, just the total budget is inflated a bit. I was thinking if it was the data type problem. But I have ensured they are unscaled jnp array. So i really have no clue what is happening here. Do you have any idea? I don't mind to exchange our notebooks if you want to.

from lightweight_mmm.

entzyeung avatar entzyeung commented on June 4, 2024

from lightweight_mmm.

entzyeung avatar entzyeung commented on June 4, 2024

Hello @shubhamgupta568 , here is my code:

solution, kpi_without_optim, previous_media_allocation = optimize_media.find_optimal_budgets(
    n_time_periods= n_time_periods,
    media_mix_model= mmm,
    extra_features= extra_features_test[:n_time_periods],#### transformed, and the forecasted period [:n_time_periods]
    budget= budget,
    prices= prices,
    media_scaler = media_scaler,
    target_scaler = target_scaler,

    seed= SEED,
    bounds_upper_pct = 0.05, 
    bounds_lower_pct = 0.05
    )

I tried multiple sets of upper and lower pct, all of them gave me the same percentage of distribution, but if i set the upper and lower smaller than 0.2, there would be a height differences between bars, while remaining the same pct. If i set the upper and lower bigger than 0.2, the height between bars would be exactly the same.

The graph below is bounds pct = 0.3 (upper bound 2 and lower bound 0.5 gives me exactly the same distributions, and same heights as the graph below too)
0 3

The graph below is bounds pct = 0.05
0 05

from lightweight_mmm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.