laplace_sample: expose CmdStan's diagnostic_file (the Hessian at the mode)
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start from CmdStanModel.laplace_sample and compare it with how sample handles save_diagnostics, since the issue proposes mirroring that argument. The result would be exposed on CmdStanLaplace as a hessian attribute. Pull request #870 is already open against this issue, so check it before starting. Done means the diagnostic file is requested, parsed, and its Hessian is available when requested.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
CmdStan's laplace method can write a diagnostic file (output diagnostic_file=...), but CmdStanModel.laplace_sample has no argument to request it. That file is where CmdStan reports the Hessian at the mode, so cmdstanpy users can't get the Hessian the Laplace approximation was built from.
Details
laplace_sample's signature in 1.3.0 is(data, mode, draws, *, jacobian, seed, output_dir, sig_figs, save_profile, show_console, refresh, time_fmt, timeout, opt_args). There is nodiagnostic_fileorsave_diagnostics, unlikesample(save_diagnostics=...).- In CmdStan 2.40.0, running
laplace mode=<mode.csv> ... output file=lap.csv diagnostic_file=lap_diag.jsonwrites a JSON file whose"Hessian"key holds the Hessian of the log density at the mode, on the unconstrained scale. We confirmed this by running it directly.
Use case
We fit a model by optimize (MLE, jacobian=False) and want observed-information standard errors at the optimum. The Hessian at the mode is that object. Through cmdstanpy we can only get the Laplace draws, and from those we'd have to re-estimate a covariance that CmdStan has already computed exactly.
Suggested API
Add a save_diagnostics: bool = False argument, mirroring sample. It would pass diagnostic_file=<output_dir>/<name>-diagnostic.json to CmdStan, and expose the parsed file on CmdStanLaplace. For example, CmdStanLaplace.hessian would return an np.ndarray, or None if the diagnostic file wasn't requested.
We are happy to open a PR with a test, if this API is acceptable.
Versions
cmdstanpy 1.3.0, CmdStan 2.40.0, Python 3.12, Linux x86_64.
- Lingua principale
- Python
- Stelle
- 198
- Fork
- 82
- Merge medio
- 4g 11h
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un 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 stan-dev/cmdstanpy
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Release 2.0Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
-
feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
Tutte le issue di stan-dev/cmdstanpy
Issue simili
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_waitApertaneeds-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
krkn-chaos/krkn#1627 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NousResearch/hermes-agent#136483 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last elementForse già presa @peterdsharpe l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pytorch/tensordict#2307 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno