Comments (9)
Thanks!
Yes, the main tasks are updating to use v4 and ArviZ and to update the metadata and style, see pymc-devs/pymc#5460 for example. Everything should be written in the jupyter style guide and the webinar from the PyMC-Data Umbrella series, if you have any questions let me know
from pymc-examples.
As long as notebooks move progressively towards the Done column all PRs will be welcome 😄
from pymc-examples.
Hi @OriolAbril, I can work on this task.
Just want to confirm that the main tasks are upgrading the notebook into PyMC v4 and new ArviZ version right? Thanks
from pymc-examples.
I re-run this notebook with the latest pymc version 4.0.0b6
.
There seems a problem in pm.find_MAP
.
with pm.Model() as model:
.........................
# The Gaussian process is a sum of these three components
gp = gp_seasonal + gp_medium + gp_trend
# Since the normal noise model and the GP are conjugates, we use `Marginal` with the `.marginal_likelihood` method
y_ = gp.marginal_likelihood("y", X=t, y=y, noise=cov_noise)
# this line calls an optimizer to find the MAP
mp = pm.find_MAP(include_transformed=True)
The results of estimated parameters from pymc v4 are:
['period:1.0',
'α:2.5',
'η_med:0.10000000000000002',
'η_noise:0.05000000000000001',
'η_per:1.0',
'η_trend:2.0',
'σ:0.05000000000000001',
'ℓ_med:2.6666666666666665',
'ℓ_noise:0.5',
'ℓ_pdecay:133.33333333333337',
'ℓ_psmooth :1.3333333333333333',
'ℓ_trend:40.0']
While the expected (in pymc 3.9.3) should be:
['period:1.0003904457696988',
'α:1.1826444920780308',
'η_med:0.02432146950697816',
'η_noise:0.007821354118990929',
'η_per:0.09941238570897516',
'η_trend:1.8391949691730372',
'σ:0.0067995598981081',
'ℓ_med:1.4999510109600107',
'ℓ_noise:0.17053127928697115',
'ℓ_pdecay:125.90347217600561',
'ℓ_psmooth :0.7309756296087601',
'ℓ_trend:53.345284025570486']
The wrong estimated params from find_MAP lead to a big standard deviation in model prediction
My local PyMC v4 environment config:
Python version : 3.9.10
IPython version : 8.2.0
pymc : 4.0.0b6
aesara: 2.5.1
arviz : 0.12.0
pandas: 1.4.2
numpy : 1.22.3
Watermark: 2.3.0
from pymc-examples.
There seems a similar issue at pymc-devs/pymc#5443 (comment)
from pymc-examples.
What happens without that include_transformed
argument? And how are you printing the parameter values, I don't see any transformed variable names in the output of MAP that you printed. There would be a bunch of _log__
suffixes
from pymc-examples.
The same [wrong] results when set include_transformed=False
or remove it in pm.find_MAP()
with pm.Model() as model:
# ........ removed .........
# The Gaussian process is a sum of these three components
gp = gp_seasonal + gp_medium + gp_trend
# Since the normal noise model and the GP are conjugates, we use `Marginal` with the `.marginal_likelihood` method
y_ = gp.marginal_likelihood("y", X=t, y=y, noise=cov_noise)
# this line calls an optimizer to find the MAP
mp = pm.find_MAP(include_transformed=False)
This code prints the variables:
# display the results, dont show transformed parameter values
sorted([name + ":" + str(mp[name]) for name in mp.keys() if not name.endswith("_")])
Outputs:
['period:1.0',
'α:2.5',
'η_med:0.10000000000000002',
'η_noise:0.05000000000000001',
'η_per:1.0',
'η_trend:2.0',
'σ:0.05000000000000001',
'ℓ_med:2.6666666666666665',
'ℓ_noise:0.5',
'ℓ_pdecay:133.33333333333337',
'ℓ_psmooth :1.3333333333333333',
'ℓ_trend:40.0']
May be you want to see all variables, so I print it all here:
# display the results, dont show transformed parameter values
sorted([name + ":" + str(mp[name]) for name in mp.keys()])
Outputs:
['period:1.0',
'α:2.5',
'α_log__:0.9162907318741551',
'η_med:0.10000000000000002',
'η_med_log__:-2.3025850929940455',
'η_noise:0.05000000000000001',
'η_noise_log__:-2.995732273553991',
'η_per:1.0',
'η_per_log__:0.0',
'η_trend:2.0',
'η_trend_log__:0.6931471805599453',
'σ:0.05000000000000001',
'σ_log__:-2.995732273553991',
'ℓ_med:2.6666666666666665',
'ℓ_med_log__:0.9808292530117262',
'ℓ_noise:0.5',
'ℓ_noise_log__:-0.6931471805599453',
'ℓ_pdecay:133.33333333333337',
'ℓ_pdecay_log__:4.892852258439873',
'ℓ_psmooth :1.3333333333333333',
'ℓ_psmooth _log__:0.28768207245178085',
'ℓ_trend:40.0',
'ℓ_trend_log__:3.6888794541139363']
from pymc-examples.
Hi @OriolAbril, I have also re-run this notebook in pymc3 v3.11.4
, and it works.
Is it okie if I do some General updates and ArviZ related things and make a PR to move this one to Best practices (v3)
tag first.
from pymc-examples.
The problem with using this notebook in v4 is possibly due to the buggy find_MAP
behavior mentioned in pymc-devs/pymc#5923.
from pymc-examples.
Related Issues (20)
- Notebook Profiling needs to update to v5
- Slight Mis-Interpretation of Discrete Choice Theory HOT 2
- Broken link in MLDA example notebook HOT 1
- Broken link in MLDA intro page HOT 1
- Propensity Score Non-Parametric Models HOT 1
- Should you buy a house battery? HOT 2
- wrapping jax example code cell 22 returns error HOT 14
- Notebook Proposal : Time Series Modeling with HSGP: Baby Births Example HOT 2
- Do operator example still mentions PyMC-Experimental HOT 4
- pre-commit-ci fails HOT 6
- Divergences in Bayesian Non-parametric Causal Inference PyMC 5.10+
- Errors in "Introduction to Variational Inference with PyMC" notebook HOT 1
- Proposal: Add HSGP reference and examples
- Bug copying URL on iPhone HOT 1
- Divergences in examples/generalized_linear_models/GLM-ordinal-regression.ipynb HOT 5
- Bug in "Variational Inference: Bayesian Neural Networks" notebook
- Highlight backends in "faster sampler nb"
- Math rendering issue in golf putting example HOT 4
- Update data container notebook to reflect changes to `pm.Data`
- Broken link in Weibull Accelerated Failure Time Model notebook
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 pymc-examples.