autoemulate icon indicating copy to clipboard operation
autoemulate copied to clipboard

Refactor: add transforms and transformed emulators

Open sgreenbury opened this issue 6 months ago • 3 comments
trafficstars

Closes #348.

sgreenbury avatar May 16 '25 09:05 sgreenbury

Codecov Report

Attention: Patch coverage is 91.40271% with 38 lines in your changes missing coverage. Please review.

Project coverage is 78.11%. Comparing base (5e90347) to head (ef26951).

Files with missing lines Patch % Lines
...emulate/experimental/emulators/transformed/base.py 85.39% 13 Missing :warning:
autoemulate/experimental/transforms/utils.py 67.85% 9 Missing :warning:
autoemulate/experimental/transforms/vae.py 91.42% 6 Missing :warning:
autoemulate/experimental/transforms/base.py 90.69% 4 Missing :warning:
autoemulate/experimental/transforms/pca.py 90.62% 3 Missing :warning:
autoemulate/experimental/transforms/standardize.py 90.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #474      +/-   ##
==========================================
+ Coverage   77.51%   78.11%   +0.59%     
==========================================
  Files         121      130       +9     
  Lines        8758     9198     +440     
==========================================
+ Hits         6789     7185     +396     
- Misses       1969     2013      +44     

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

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar May 16 '25 09:05 codecov-commenter

Coverage report

Click to see where and how coverage changed
FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  autoemulate/experimental/emulators
  __init__.py
  base.py
  autoemulate/experimental/emulators/neural_processes
  conditional_neural_process.py
  autoemulate/experimental/emulators/transformed
  base.py 180-182, 351-352, 375-378, 383-388, 392-396
  autoemulate/experimental/transforms
  __init__.py
  base.py 35-36, 43-44
  pca.py 53-55
  standardize.py 45-47
  utils.py 60, 67-75
  vae.py 90, 118-122, 142-144
  tests
  test_compare.py
  tests/experimental
  conftest.py
  test_experimental_conditional_neural_process.py
  test_experimental_transformed.py
  tests/experimental/transforms
  test_transforms.py
Project Total  

This report was generated by python-coverage-comment-action

github-actions[bot] avatar May 16 '25 09:05 github-actions[bot]

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Following discussion:

  • It would be good to double check if implications of using torch Transform for a VAE since the call and inv methods do not guarantee $f^{-1}(f(x)) = x$
  • make_positive_definite might be useful to pass params too but we can revisit if there are issues that arise in using
  • Subclassing ComposeTransform to AutoEmulateComposeTransform might benefit the API but this could potentially be considered as part of #531 if it seems useful in the top-level API?

sgreenbury avatar Jun 19 '25 13:06 sgreenbury

One last minor thought I had was about whether we want the input args to the inverse transform methods to be z rather than x or y? It might just be easier to track what's what but I am also more than happy to be told that's wrong.

radka-j avatar Jun 19 '25 16:06 radka-j

One last minor thought I had was about whether we want the input args to the inverse transform methods to be z rather than x or y? It might just be easier to track what's what but I am also more than happy to be told that's wrong.

Yeah I think this could definitely be clearer, perhaps the following refactor would be useful:

  • Since torch's Transform refers to x in the domain and y in the codomain, I think the AutoEmulateTransform might be best if consistent with this and update the input API to x for call and y for inverses
  • For the TransformedEmulator, since this works with x for emulator inputs and y for targets, using z to refer to inputs in the codomain of the transforms for x seems like a good option.
  • Some of the method names in TransformedEmulator might be worth revisiting too (e.g. some refer to y like _inv_transform_y_mvn while the y transforms in the attribute are called target_transforms) - perhaps we could rename the y in method names to target for consistency. Or alternativelu target_transforms to y_transforms.

sgreenbury avatar Jun 20 '25 08:06 sgreenbury

@radka-j: thanks for the review comments! I've aimed to address these now and also more generally:

  • Added docstrings for all _methods in TransformedEmulator and AutoEmulateTransform
  • Renamed function arguments / attributes in AutoEmulateTransform and TransformedEmulator
  • Renamed methods in AutoEmulateTransform for clarity

sgreenbury avatar Jun 24 '25 15:06 sgreenbury

Thanks @radka-j!

sgreenbury avatar Jun 25 '25 14:06 sgreenbury