Support pointwise marginal log-densities
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 64/100
Direzione di ricerca
Inizia tracciando pointwise_logdensities, pointwise_prior_logdensities e pointwise_loglikelihoods e la loro gestione attuale di factorize, quindi esamina le API di PartitionedDistributions per la log-densità condizionale e marginale punto per punto. Il lavoro è completo quando sono supportati nothing, :conditional e :marginal, viene mantenuto il comportamento di compatibilità per true e false e per la nuova modalità vengono utilizzate log-densità marginali punto per punto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I propose the factorize keyword of pointwise_logdensities, pointwise_prior_logdensities and pointwise_loglikelihoods be generalized to accept 3 values: nothing, :conditional, :marginal with true => :conditional deprecated but left for backwards-compatibility and same for false => nothing.
Internally, factorize=:conditional continues to call PartitionedDistributions.pointwise_conditional_logpdfs, while factorize=:marginal calls the new PartitionedDistributions.pointwise_marginal_logpdfs.
Background and motivating use-case
For model selection/comparison of a model $M$ via cross-validation with $n$ observations $y$, we can partition the observations into training sets $T_k$ and a non-overlapping evaluation set $E_k$. We can then define a pointwise ELPD estimate as (e.g. https://arxiv.org/abs/2301.08276)
\widehat{\text{elpd}}_{CV}(M | y) = \sum_{k=1}^K \sum_{i \in E_k} w_{ik} \log p(y_i \mid y_{T_k}, M)
for some data-independent weights $w$ (e.g. $w_{ik} = 1$ if the eval sets don't overlap).
Other ELPDs could be written depending on the predictive task. This one though is most comparable to the ELPD estimated by LOO. If e.g. PSIS-LOO fails for many more than 10 observations, it's often going to be less expensive to run 10-fold CV for model selection with this pointwise utility than to do exact LOO for each of the failed observations.
If we get $S$ posterior draws $\theta_s \sim p(\theta \mid y_{T_k})$, then we can estimate the summand with $\text{logsumexp}_{s=1}^S\left(\log p(y_i \mid y_{T_k}, \theta_s) \right) - \log S$. If the observation model is conditionally independent, then currently the quantity inside the log-sum-exp can be computed with pointwise_loglikelihoods with factorize=true.
If the observation model is not factorizable (e.g. an MvNormal with non-diagonal covariance), then computing the desired quantity will probably need to be done manually outside of the model using PartitionedDistributions, something like:
fold_inds = vcat(eval_inds, train_inds)
y_fold = y[fold_inds]
eval_inds_in_fold = first(eachindex(y_fold), length(eval_inds))
likelihood = ... # dist representing p(y_{E_k}, y_{T_k} | theta)
likelihood_eval = conditional(likelihood, y_fold, eval_inds_in_fold) # dist representing p(y_{E_k} | y_{T_k}, theta)
ll_pw = pointwise_marginal_logpdfs(likelihood_eval, y[eval_inds]) # log p(y_{i} | y_{T_k}, theta) for each i in E_k
This complexity is as far as I see it unavoidable. Since the training set could be much larger then the evaluation set, the construction of the conditional could be quite expensive, and it needs to be done for every Monte Carlo draw $s$ for each fold. However, there's a special case that simplifies. If the the train/eval sets are chosen so the eval obs are conditionally independent from the training obs (i.e. $p(y_{E_k} | y_{T_k}, \theta_s) = p(y_{E_k} | \theta_s)$), then we can do
likelihood_eval = ... # dist representing p(y_{E_k} | theta)
ll_pw = pointwise_marginal_logpdfs(likelihood_eval, y[eval_inds])
It's substantially cheaper but still requires the user to duplicate their likelihood outside of their model, which is error-prone. Or, with the proposal in this issue, they could reuse their model:
model_eval = ... # build model with just `y[eval_inds]`
ll_pw = pointwise_loglikelihoods(model_eval, chains; factorize=:marginal)
- Lingua principale
- Julia
- Stelle
- 291
- Fork
- 43
- Merge medio
- 1g 23h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TuringLang/DynamicPPL.jl
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
TuringLang/DynamicPPL.jl#1480 ·
I maintainer di solito rispondono entro 2 giorni
-
Separate model-evaluation inputs from outputsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertadata-structures enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
TuringLang/DynamicPPL.jl#1469 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
TuringLang/DynamicPPL.jl#1466 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
documentation
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
TuringLang/DynamicPPL.jl#1390 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
`pointwise_logdensities`, `returned`, `logjoint`, etc. APIs are weirdForse di nuovo libera @ArpanC6 l’ha presa 217 giorni fa e non c’è nessuna pull request aperta. Apertagood first issue interface-design
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
TuringLang/DynamicPPL.jl#1332 · 4 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di TuringLang/DynamicPPL.jl
Issue simili
-
Release CorleoneInverse as 0.1.1Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
SciML/Corleone.jl#200 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
JuliaAI/MLJTransforms.jl#120 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
exercism/julia#1205 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
SciML/OrdinaryDiffEq.jl#5175 ·
I maintainer di solito rispondono entro 1 giorno