Skip to content

Add check for strictly positive training data for CategoricalHMM #421

Open

Description

@abuzarmahmood

Apologies if I missed this but I wasn't able to find in the documentation the CategoricalHMM takes positive values only. I only realized it when I noticed my predictions from fitted models behaving weirdly.
It would be useful to add a warning (or even a transform of the inputs) when fitting the HMM.
Happy to submit a PR if this would be useful.

Activity

  1. changed the title [-]Add check for strictly positive values for CategoricalHMM[/-] [+]Add check for strictly positive training data for CategoricalHMM[/+] on Jun 3, 2025
  2. PeerAhammad commented on Oct 3, 2026

    @PeerAhammad

    I’ve prepared a fix for this issue that validates CategoricalHMM emissions before entering the JAX-transformed fit_em/fit_sgd code. The fix raises a ValueError for out-of-range or non-integer labels rather than silently fitting incorrect data.

    I chose an error rather than an automatic 1-based → 0-based transformation because silently recoding the data could hide input mistakes. I’m happy to adjust this to a warning or another behavior if maintainers prefer.

    I’ll open a PR with the fix and regression tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions