Closed jgzga closed 1 week ago
I saw this example on documentation:
"""Create a PyMC variable from the prior.
Must be used in a PyMC model context.
Parameters
----------
name : str
The name of the variable.
Returns
-------
pt.TensorVariable
The PyMC variable.
Examples
--------
Create a hierarchical normal variable in larger PyMC model.
.. code-block:: python
dist = Prior(
"Normal",
mu=Prior("Normal"),
sigma=Prior("HalfNormal"),
dims="channel",
)
coords = {"channel": ["C1", "C2", "C3"]}
with pm.Model(coords=coords):
var = dist.create_variable("var")
"""
But I don't know how can I include this variable called "var" in the class MMM
Hi @jgzga
I recommend that you follow the latest notebook mmm_example.ipynb in case you want to start playing around with PyMC-Marketing and use the out-of-the-box model.
If you need to build a custom model, follow this notebook mmm_components.ipynb then.
Both examples use the same Prior
class you mentioned and will be available in release 0.8.0
.
In the meanwhile, install the main branch using this cmd to use the latest updates in your code
pip install git+https://github.com/pymc-labs/pymc-marketing.git
I'm installing the library with this command.
pip install git+https://github.com/pymc-labs/pymc-marketing.git
And importing the Prior class as in this notebook with command
from pymc_marketing.prior import Prior
But gives me this error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
[<ipython-input-2-895cc36dd95d>](https://localhost:8080/#) in <cell line: 11>()
9 from pymc_marketing.mmm import MMM
10 #from pymc_marketing.mmm.plot import plot_curve
---> 11 from pymc_marketing.prior import Prior
12 from pymc_marketing.mmm.components.adstock import geometric_adstock
13 from pymc_marketing.mmm.components.saturation import logistic_saturation
ModuleNotFoundError: No module named 'pymc_marketing.prior'
@jgzga
Try to uninstall and re-install the package as the main branch is labelled as 0.7.0 and might be causing issues when installing directly from the main Github branch.
pip uninstall pymc-marketing
pip install git+https://github.com/pymc-labs/pymc-marketing.git
I'm installing the library with this command.
pip install git+https://github.com/pymc-labs/pymc-marketing.git
And importing the Prior class as in this notebook with command
from pymc_marketing.prior import Prior
But gives me this error:
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) [<ipython-input-2-895cc36dd95d>](https://localhost:8080/#) in <cell line: 11>() 9 from pymc_marketing.mmm import MMM 10 #from pymc_marketing.mmm.plot import plot_curve ---> 11 from pymc_marketing.prior import Prior 12 from pymc_marketing.mmm.components.adstock import geometric_adstock 13 from pymc_marketing.mmm.components.saturation import logistic_saturation ModuleNotFoundError: No module named 'pymc_marketing.prior'
You will likely have to pip uninstall pymc-marketing first then run command again
Related to #860
After doing this, it worked.
pip uninstall pymc-marketing
pip install git+https://github.com/pymc-labs/pymc-marketing.git
Thanks
Hi @jgzga, did this resolve? The original question may have gotten lost. If you have an further questions, let me know.
I have the following code where I define certain priors and derived variables with these priors. However, it seems that they are not working because, despite restricting the distribution to be positive (in this case with a HalfNormal), they are not turning out positive. The documentation provides some information about the Prior class but nothing related to how to create a variable with those priors.
The priors and variables are based on this post: https://juanitorduz.github.io/pymc_mmm/ Any help would be appreciated. Thank you