facebookexperimental / Robyn

Robyn is an experimental, AI/ML-powered and open sourced Marketing Mix Modeling (MMM) package from Meta Marketing Science. Our mission is to democratise modeling knowledge, inspire the industry through innovation, reduce human bias in the modeling process & build a strong open source marketing science community.
https://facebookexperimental.github.io/Robyn/
MIT License
1.16k stars 346 forks source link

Hill function never saturates #922

Open Serge3006 opened 9 months ago

Serge3006 commented 9 months ago

Project Robyn

Describe issue

hello i'm trying to replicate the saturation hill function and it seems that even though I increase the investment it does not saturates, here is the code that is based on the definition you have in R: ` def saturation_hill(x, alpha, gamma, x_marginal=None): inflexion = np.dot(np.array([1 - gamma, gamma]), np.array([np.min(x), np.max(x)])) if x_marginal is None: x_scurve = xalpha / (xalpha + inflexionalpha) else: x_scurve = x_marginalalpha / (x_marginalalpha + inflexionalpha) x_scurve = 1 / (1 + (gamma / x) ** alpha) return x_scurve

investment_array = np.linspace(0, 5000, 50) saturated_investment = saturation_hill(investment_array, params["alpha"], params["gamma"]) saturated_investment = params["coef"] * saturated_investment

    plt.figure(figsize=(10, 6))
    plt.plot(investment_array, saturated_investment, label='Inflow contribution', marker='o', linestyle='-', markersize=5)

    plt.title(f'Response curve - Inflow contribution by {str.upper(media)}')
    plt.xlabel('Raw investment')
    plt.ylabel('Inflow')
    plt.legend()
    plt.grid(True)
    plt.show()

` image

gufengzhou commented 9 months ago

What do you mean by "saturation"? If it's ROAS == 1 (media break even), then by eyeballing your curve, it'll be around 1.3k raw investment. At 5k you got ROAS of 0.5 or so. What is "saturated" for you?