Skip to content
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

Parameter transformer #150

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Parameter transformer #150

wants to merge 19 commits into from

Conversation

zihaoxu98
Copy link
Collaborator

@zihaoxu98 zihaoxu98 commented Mar 11, 2024

This PR adds a new class called Transformer which applies transformation of the parameters. Some of the previous code is slightly modified but should not interfere any previous code.

To define a transformer, you need to specify its 1. domain 2. codomain 3. transform (domain to codomain) and inverse transform (codomain to domain) 4. Jacobian. In principle everything should already be defined by giving transform, however we will rely on the users to define the symbolic inverse transform and Jacobian. The Jacobian is needed to transform the log posterior pdf. An example is also added to the test.

The Transformer can act on almost all appletree classes by simply doing something like

transformer = TestTransformer()
transformed_obj = transformer(obj)

where obj can be 1. a dictionary of parameters 2. apt.Parameter 3. apt.Component 4. apt.Likelihood 5. apt.Context

@coveralls
Copy link

coveralls commented Mar 12, 2024

Pull Request Test Coverage Report for Build 8289067506

Details

  • 146 of 186 (78.49%) changed or added relevant lines in 6 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.5%) to 84.613%

Changes Missing Coverage Covered Lines Changed/Added Lines %
appletree/parameter.py 10 14 71.43%
appletree/component.py 13 21 61.9%
appletree/transform.py 117 145 80.69%
Files with Coverage Reduction New Missed Lines %
appletree/parameter.py 3 86.86%
Totals Coverage Status
Change from base Build 8190832365: -0.5%
Covered Lines: 2403
Relevant Lines: 2840

💛 - Coveralls

@zihaoxu98 zihaoxu98 changed the title Transformer Parameter transformer Mar 14, 2024
@zihaoxu98 zihaoxu98 marked this pull request as ready for review March 14, 2024 23:54
@zihaoxu98 zihaoxu98 requested a review from dachengx March 14, 2024 23:54
@dachengx
Copy link
Collaborator

Thanks @zihaoxu98 . This PR is gorgeous, but maybe appletree currently does not strongly need it. I will convert it to draft and if we need it we can come back in the future.

@dachengx dachengx marked this pull request as draft April 16, 2024 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants