-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add diagnose method #485
Add diagnose method #485
Conversation
Questions to resolve:
My opinion is we do not need it at the moment, but can always add it later if a use-case arises or someone wants to add it.
Currenlty if the diagnose call stops, the entire stdout/stderr is printed. If diagnose finishes normally, there is no actual useful output so I would say we dont need it?
|
Codecov Report
@@ Coverage Diff @@
## master #485 +/- ##
==========================================
- Coverage 93.31% 93.26% -0.06%
==========================================
Files 12 12
Lines 2948 3043 +95
==========================================
+ Hits 2751 2838 +87
- Misses 197 205 +8
Continue to review full report at Codecov.
|
Thanks for working on this.
That sounds good to me.
Ok by me, but we should check with @mitzimorris. If CmdStanPy exposes the diagnose method we can coordinate names.
Yeah I guess we don't need it.
If there's nothing useful to print then I guess it's fine to omit it.
I can't think of anything right now. |
cmdstanpy does not expose this: stan-dev/cmdstanpy#233 But we can agree on names here. |
Here's my $0.02:
agree
also agree - threads don't make sense - threads really only make sense in the context of MCMC methods. the methods on the CmdStanDiagnose object are fine - no opinion on regarding name
I ran this on a model with more parameters - here's the output:
hence the suggestion for a column of parameter names. |
Maybe, though this data frame represents gradients calculated with autodiff and the same gradients calculated with finite_diffs so I think gradient may be more appropriate.
I agree, but cmdstan does not output them. We would have to run an iteration of optimization or something to get the names. Or change it in Stan services. The next version of stanc3 that will be available for cmdstan 2.27 will be able to output the names of the parameters so we could use that in the wrappers to get the names. In both cases I think that is a separate PR as this right now does the bare minimum of what CmdStan offers. |
hi @rok-cesnovar - you're right about no names in the output. also, agree, |
This is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few minor things plus this error I'm getting:
cmdstanr_example(method = "diagnose")
Error in processx::run(command = self$command(), args = self$command_args()[[1]], :
argument 5 matches multiple formal arguments
Also would be good to add a test.
Ok I did the documentation. Any idea why the example errors? Or is that just on my computer? |
Turns out I needed to update my processx version because previous versions didn't have the |
Ah yes, great call, thanks. The ability to store stdout/stderr in a file was added in 3.5.0. Will fix the rest of the minor stuff immediately. |
Addressed the rest of the comments. Thanks so much for the review and fixing up the comments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks! Can you add a test (I think just a simple one checking that it doesn't error and the gradients() method works after)? Other than that I think it's ready to merge. If you don't have time to do the test let me know and I can probably do it tonight or tomorrow.
@rok-cesnovar this should fix the failing check
Thanks! Will add one tomorrow. |
Added tests running the method and reading the CSV. Also did a minor change so that lp is not part of metadata in read_cmdstan_csv. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good to me.
Everything passed so merging now |
Summary
Fixes #156
This is a WIP as I think we need to settle on some of the names and what to expose.
The basic functionality:
Another example:
Diagnose method has the following diagnose-specific args:
Both of these are in the
gradient
argument group. But given that diagnose only diagnoses gradients, this is fine I think.The rest of the commong args are:
Not sure we need
output_dir
andoutput_basename
but they were easy to add.We could add
threads
but I dont think its a real use case for the diagnose method.The run returns a CmdStanDiagnose object that has the following methods:
Copyright and Licensing
Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Rok Češnovar
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses: