Skip to content

Conversation

whart222
Copy link
Collaborator

@whart222 whart222 commented Oct 7, 2025

Changes to create an HMM API that uses composition rather than inheritance.

Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 87.93343% with 87 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.10%. Comparing base (e5c9ca9) to head (ea54d29).

Files with missing lines Patch % Lines
conin/hmm/inference/a_star.py 80.41% 10 Missing and 9 partials ⚠️
conin/hmm/hmm_application.py 40.00% 12 Missing ⚠️
conin/hmm/tests/examples.py 78.78% 7 Missing ⚠️
conin/hmm/constrained_hmm.py 91.80% 2 Missing and 3 partials ⚠️
conin/hmm/hmm.py 94.84% 1 Missing and 4 partials ⚠️
conin/inference/tests/test_AStarInference.py 88.37% 5 Missing ⚠️
conin/hmm/chmm.py 66.66% 2 Missing and 2 partials ⚠️
conin/hmm/tests/test_inference.py 75.00% 4 Missing ⚠️
conin/hmm/tests/test_oracle_chmm.py 90.00% 4 Missing ⚠️
conin/hmm/chmm_algebraic.py 86.95% 3 Missing ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #125      +/-   ##
==========================================
- Coverage   85.12%   83.10%   -2.02%     
==========================================
  Files          83       84       +1     
  Lines        5390     5458      +68     
  Branches      575      594      +19     
==========================================
- Hits         4588     4536      -52     
- Misses        688      795     +107     
- Partials      114      127      +13     

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

Copy link

Choose a reason for hiding this comment

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

Viterbi is spelled wrong!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Copy link

@clmatt clmatt left a comment

Choose a reason for hiding this comment

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

I like the idea a lot! I don't know how I feel about the naming convention though. It was hard in my head to keep track of HMM vs. HiddenMarkovModel. Also, for things like Bayes Nets, it would be less obvious what the acronym vs. non-acronym version would be.

Maybe HMM and _HMM? Or Matrix_HMM or something? It's not obvious to me what's best.

@whart222
Copy link
Collaborator Author

whart222 commented Oct 9, 2025

@clmatt I agree that the naming convention HiddenMarkovModel/HMM isn't intrinsically better. I'm trying to have a consistent camel-case convention for end-user classes (e.g. MarkovNetwork, DiscreteBayesianNetwork).

I like the idea of a more explicit class name than HMM. It's clear now that HMM is only used to drive a few specific inference methods. For example, it isn't being used for the LP/IP inference methods. Hence, I don't think we can/should promote it as a general "internal" representation for all inference methods. Similarly, I think I'm going to shift the code to not automatically generate this representation (since it isn't always used).

I'm leaning towards your recommendation. How about HMM_Matrix? Or HMM_MatVec?

What about instance naming convention? Right now the HiddenMarkovModel has an hmm property for the HMM_Matrix instance. Maybe we should call that hmm_matvec to be more explicit? Or something else? Maybe use a convention like hmm_ to reference internal matrix representations?

whart222 and others added 3 commits October 9, 2025 09:54
The use of the ConstrainedHiddenMarkovModel is now done underneath the
hood of this method.  Thus, lp_inference accepts a HiddenMarkovModel,
and ip_inference accepts a ConstrainedHiddenMarkovModel
@whart222
Copy link
Collaborator Author

whart222 commented Oct 9, 2025

FYI, I've started reworking the scripts in clio_collab to confirm that this refactoring is not disruptive. The main changes were w.r.t. the use of the new *Inference() classes to execute map_queries, rather than directly calling inference functions.

Otherwise, minimal changes are needed to account for this refactor (and other conin changes since the move from clio)!

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