Comments (3)
It's a very interesting question.
I don't have the answer sadly.
In general the half normal is the standard for Bayesian Inference, but you can use also other distribution based on this discussion with some reference.
Probably the answer is in this piece of the code, but I don't know enough numpyro to provide a useful solution.
Source Code
def _preprocess_custom_priors(
self,
custom_priors: Dict[str, Prior]) -> MutableMapping[str, Prior]:
"""Preprocesses the user input custom priors to Numpyro distributions.
If numpyro distributions are given they remains untouched, however if any
other option is passed, it is passed to the default distribution to alter
its constructor values.
Args:
custom_priors: Mapping of the name of the prior to its custom value.
Returns:
A mapping of names to numpyro distributions based on user input and
default values.
"""
from lightweight_mmm.
Thanks for your answer, @uomodellamansarda!
from lightweight_mmm.
I am still struggling to understand how to provide previous information to the model.
I don't know @gustfon if you were able to do that.
Based on the documentation to use prior information, it seems that we need to provide to the LightweightMMM
object a custom_priors
argument.
custom_priors: MutableMapping[str, Prior] = dataclasses.field( init=False, repr=False, hash=False, compare=True)
It takes a str
and a Prior
.
How should be the right format to provide Prior
?
For example, if I know that:
- YouTube follows an Half Normal Numpyro Distribution with a mean value of 0.025 and variance 0.01.
- I have other three media channels, Facebook - Radio - TV where I don't know the coefficient mean value
How can I provide this information to my model?
custom_priors = { "YouTube" : dist.Normal( mean = 0.025,variance = 0.01) "Facebook": "" "Radio": "" "TV": "" }
Because I am struggling to understand this step:
"""
default_priors = {
**models._get_default_priors(),
**models._get_transform_default_priors()[self.model_name]
}
# Checking that the key is contained in custom_priors has already been done
# at this point in the fit function.
for prior_name in custom_priors:
if isinstance(custom_priors[prior_name], numbers.Number):
custom_priors[prior_name] = default_priors[prior_name].__class__(
custom_priors[prior_name])
elif (isinstance(custom_priors[prior_name], collections.abc.Sequence) and
not isinstance(custom_priors[prior_name], str)):
custom_priors[prior_name] = default_priors[prior_name].__class__(
*custom_priors[prior_name])
elif isinstance(custom_priors[prior_name], dict):
custom_priors[prior_name] = default_priors[prior_name].__class__(
**custom_priors[prior_name])
elif not isinstance(custom_priors[prior_name], dist.Distribution):
raise ValueError(
"Priors given must be a Numpyro distribution or one of the "
"following to fit in the constructor of our default Numpyro "
"distribution. It could be given as args or kwargs as long as it "
"is the correct format for such object. Please refer to our "
"documentation on custom priors to know more.")
return custom_priors
from lightweight_mmm.
Related Issues (20)
- What is the best way to contribute to this library?
- INVALID_ARGUMENT: Python buffer protocol is only defined for CPU buffers. HOT 1
- In trying to plot the the response curves I get an error
- NumbaWarning: Compilation is falling back to object mode WITH looplifting enabled because Function "histogram" failed type inference due to: non-precise type pyobject During: typing of argument at /usr/local/lib/python3.10/dist-packages/arviz/stats/density_utils.py (979)
- Potential Improvments on Price and Extrafeature
- ValueError: Einstein sum subscript 'c' does not contain the correct number of indices for operand 1. HOT 1
- All predictions start with an offset HOT 1
- Kpi is smaller than spend on response curve
- GPU Performance Issues HOT 2
- Adstock Normalization
- What is budget in media optimization
- previous_extra_features data in predict function
- Not able to install the packages
- What are media_mix_model.trace["media_transformed"], media_mix_model.trace["coef_media"] ? Media Contribution Calculation Understanding HOT 6
- Model prediction decomposition HOT 2
- JAX GPU with Apple M2
- Response Curve : Adstock and Carryover models HOT 14
- Feature Names HOT 2
- RuntimeError (This version of jaxlib was built using AVX instructions) on importing `optimize_media` from `lightweight_mmm` in a conda environment on M1 mac.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lightweight_mmm.