Fitting the Michaelis-Menten curve (and sigmoid) require the arguments in DataFrame and xarray object. This is great for the use case but makes it hard to interact with for other purposes
I would suggest a function to fit the curve with more direct arguments and then a function to fit based on the channel
def estimate_menten_parameters(x, y, alpha_initial_estimate=None, lam_initial_estimate=0.001, maxfev=5000):
# The actual curve fitting
alpha_initial_estimate = alpha_initial_estimate or max(y)
...
def estimate_channel_menten_parameters(channel, original_dataframe, contribution, **kwargs):
# Function to be used for specific use-case
return estimate_menten_parameters(
x=original_dataframe[channel].to_numpy(),
y=contributions.sel(channel=channel).to_numpy()
**kwargs
)
Fitting the Michaelis-Menten curve (and sigmoid) require the arguments in DataFrame and xarray object. This is great for the use case but makes it hard to interact with for other purposes
https://github.com/pymc-labs/pymc-marketing/blob/30c91ee3568e853a18d7684182b54fa0d2c47b7f/pymc_marketing/mmm/utils.py#L98-L103
I would suggest a function to fit the curve with more direct arguments and then a function to fit based on the channel