Skip to content

Conversation

@rsenne
Copy link

@rsenne rsenne commented Jan 2, 2026

Adds a documentation example to resolve #51. Adds two examples 1.) fitting an hmm inside EM with GD and 2.) fitting an HMM by using autodiff + GD over all parameters. Let me know how this looks! happy to make changes


EDIT by @gdalle:

  • Bumped Julia lower bound to 1.10
  • Bumped package version to 0.7.1

Copilot AI review requested due to automatic review settings January 2, 2026 00:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive documentation examples demonstrating two approaches for fitting HMMs using gradient descent, resolving issue #51. The tutorial covers: (1) using gradient-based optimization within the EM algorithm for observation models without closed-form updates, and (2) end-to-end gradient-based fitting of all HMM parameters using automatic differentiation with the forward algorithm.

  • Implements a custom NormalModel observation model with gradient-based fit! method using BFGS optimization
  • Demonstrates fitting HMMs via Baum-Welch EM with gradient descent in the M-step for observation parameters
  • Shows how to optimize all HMM parameters jointly using autodiff over the forward algorithm's log-likelihood

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
examples/gradientdescent.jl New tutorial file demonstrating gradient descent approaches for HMM fitting with comprehensive examples and tests
docs/make.jl Adds the gradient descent tutorial to the documentation build configuration
docs/Project.toml Adds Optim.jl dependency for documentation examples
test/Project.toml Adds Optim.jl dependency for running tutorial tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.28%. Comparing base (39ae66b) to head (f9dff3f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #142   +/-   ##
=======================================
  Coverage   95.28%   95.28%           
=======================================
  Files          18       18           
  Lines         509      509           
=======================================
  Hits          485      485           
  Misses         24       24           

☔ 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.

Copy link
Owner

@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.

I like the idea very much! Here are a few suggestions, thank you for the initiative

@rsenne rsenne requested a review from gdalle January 7, 2026 04:27
@rsenne
Copy link
Author

rsenne commented Jan 10, 2026

Test for current version of Julia failed as Optim has API changes in recent breaking version 2.0.0. I changed tutorial to reflect this new API. All other tests pass locally

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.

Examples of fitting with gradient descent

2 participants