anesthetic icon indicating copy to clipboard operation
anesthetic copied to clipboard

NDE implementation

Open htjb opened this issue 1 year ago • 8 comments

Description

Adding in optional neural density estimator plot functions as an alternative to KDE and histogram plotters.

Fixes #334

Checklist:

  • [ ] I have performed a self-review of my own code
  • [ ] My code is PEP8 compliant (flake8 anesthetic tests)
  • [ ] My code contains compliant docstrings (pydocstyle --convention=numpy anesthetic)
  • [ ] New and existing unit tests pass locally with my changes (python -m pytest)
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have appropriately incremented the semantic version number in both README.rst and anesthetic/_version.py

htjb avatar Nov 08 '23 14:11 htjb

Just at a glance, you might want to have a look at how the optional dependency of fastkde is handled so you can do something similar with margarine

AdamOrmondroyd avatar Nov 09 '23 18:11 AdamOrmondroyd

Codecov Report

Attention: Patch coverage is 11.11111% with 136 lines in your changes are missing coverage. Please review.

Project coverage is 90.35%. Comparing base (54170d8) to head (f351caa).

Files Patch % Lines
anesthetic/plot.py 1.53% 128 Missing :warning:
anesthetic/plotting/_matplotlib/hist.py 62.50% 6 Missing :warning:
anesthetic/plotting/_core.py 50.00% 2 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##            master     #353      +/-   ##
===========================================
- Coverage   100.00%   90.35%   -9.65%     
===========================================
  Files           36       36              
  Lines         3043     3195     +152     
===========================================
- Hits          3043     2887     -156     
- Misses           0      308     +308     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 12 '23 10:12 codecov[bot]

tests now failing as expected (I'd forgotten to add margarine to the 'all' dependency!)

AdamOrmondroyd avatar Dec 12 '23 20:12 AdamOrmondroyd

@AdamOrmondroyd Cant remember what needs doing here? is it just the tests need tidying? and master merging?

htjb avatar Feb 09 '24 14:02 htjb

@AdamOrmondroyd Cant remember what needs doing here? is it just the tests need tidying? and master merging?

The tests need a rethink, because simply adding nde everywhere we previously saw kde slows everything down too much

Also at least one of them appears to have failed at the last time of running, and you're missing some coverage

AdamOrmondroyd avatar Feb 09 '24 15:02 AdamOrmondroyd

Ahh yes the NDEs are not particularly quick... maybe like a few minutes for a few thousands of samples (dependent on the architecture). Has the potential to slow the tests down...

Looks like the test failed because of a version mismatch between TensorFlow and TensorFlow Probability. What does the extras flag turn on in the tests?

htjb avatar Mar 11 '24 10:03 htjb

@AdamOrmondroyd Cant remember what needs doing here? is it just the tests need tidying? and master merging?

This also needed waiting for the margarine docs to work, which is now the case. So now the NDE docstrings properly link to the margarine docs.

lukashergt avatar Mar 12 '24 01:03 lukashergt

@AdamOrmondroyd pointed out that I might have set the code up to train a new NDE for every panel in the corner plot if I just replaced KDE with NDE in the plotting script. I think it should be possible to train an nD NDE and use this to plot contours on a corner plot. Need to check over the code though.

htjb avatar Mar 12 '24 08:03 htjb