Skip to content

Add controlled emission HMM.#143

Open
rsenne wants to merge 24 commits into
JuliaStats:mainfrom
rsenne:control_
Open

Add controlled emission HMM.#143
rsenne wants to merge 24 commits into
JuliaStats:mainfrom
rsenne:control_

Conversation

@rsenne
Copy link
Copy Markdown
Collaborator

@rsenne rsenne commented Jan 20, 2026

Adds the ControlledHMM type we discussed here. This is a tested version of what I already proposed. I figured I would get things rolling and I can edit as we see fit. A few ongoing questions I had:

  1. Should I add documentation for this new model? I'm happy to do so.
  2. Do you want me document in the above or an existing tutorial making a custom emission model for a ControlledHMM? E.g., highlighting difference between the general HMM type like the extension of logdensityof?
  3. Any additional tests/code documentation you would like?

Happy to work on any changes you'd like!

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 98.90110% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.83%. Comparing base (91f35ba) to head (48745c7).

Files with missing lines Patch % Lines
src/types/controlled_emission_hmm.jl 98.86% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
+ Coverage   95.28%   95.83%   +0.54%     
==========================================
  Files          18       19       +1     
  Lines         509      600      +91     
==========================================
+ Hits          485      575      +90     
- Misses         24       25       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@rsenne
Copy link
Copy Markdown
Collaborator Author

rsenne commented Jan 20, 2026

Okay so on the Standard test suite everything passes except the JuliaFormatter test which passes locally for me. Not sure why as I am using version 2.2.0 which seems to be what CI installs too. All tests related to the code (e.g., using the test_coherence) pass.

I also skipped the tests for the ControlledHMM when doing the HMMBase test suite. Not sure if this was the right thing to do.

@rsenne
Copy link
Copy Markdown
Collaborator Author

rsenne commented Mar 17, 2026

just wanted to ping this

Copy link
Copy Markdown
Member

@gdalle gdalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I had quite a bit of time off work. Here are a few remarks, the most important one being on the semantics of obs_distributions and whether it is worth such a big change

Comment thread src/types/controlled_emission_hmm.jl Outdated
Comment thread src/types/controlled_emission_hmm.jl Outdated
Comment thread src/types/controlled_emission_hmm.jl Outdated
Comment thread src/types/controlled_emission_hmm.jl Outdated
Introduce ControlledEmission and ControlledEmissions wrappers that bind a control value to emission distributions and integrate with DensityInterface/Random. Rename ControlledHMM to ControlledEmissionHMM and update its API: obs_distributions(hmm, control) now returns a lazy ControlledEmissions vector, fit!/rand require a control sequence, and exports updated accordingly.
@rsenne
Copy link
Copy Markdown
Collaborator Author

rsenne commented Mar 19, 2026

Okay so I implemented the ControlledEmission wrapper. I did have to re-add the log_transition_matrix(hmm::ControlledEmissionHMM, ::Nothing) = hmm.logtrans and transition_matrix(hmm::ControlledEmissionHMM, ::Nothing) = hmm.trans to resolve a method ambiguity. I'll take a look later today to see if there is a cleaner way around this, but the new API could be examined now

Copy link
Copy Markdown
Member

@gdalle gdalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are a few more remarks (I didn't go into detail yet while we refine the general structure)

Comment thread examples/gradientdescent.jl Outdated
Comment thread src/inference/logdensity.jl Outdated
Comment thread src/types/controlled_emission_hmm.jl
Comment thread src/types/controlled_emission_hmm.jl Outdated
Comment thread src/types/controlled_emission_hmm.jl Outdated
Comment thread src/types/controlled_emission_hmm.jl
Comment thread src/types/controlled_emission_hmm.jl Outdated
Comment thread src/types/controlled_emission_hmm.jl Outdated
@rsenne
Copy link
Copy Markdown
Collaborator Author

rsenne commented May 5, 2026

Hey @gdalle I got the error hint approach working. I also expanded the docs to reflect this new type--I left the old docs intact as they seem still helpful for insight into modifying the relevant HMM functions for custom types. Please let me know if there is anything else i can do

@gdalle
Copy link
Copy Markdown
Member

gdalle commented May 6, 2026

Thanks! Can you try to hit the missing lines in codecov? The end after the @threads block is a false positive ofc

@rsenne
Copy link
Copy Markdown
Collaborator Author

rsenne commented May 6, 2026

All lines are now covered!

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.

2 participants