sandyfloren / HW6-HMM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HW6-HMM

This repository contains code to create Hidden Markov Models, including implementations of the Forward and Viterbi Algorithms.

The Forward algorithm computes the probability of observing a specific sequence of states, given a hidden markov model.

The Viterbi algorithm computes the most likely sequence of hidden states leading to a sequence of observed states generated from the model.

Assignment

Overview

The goal of this assignment is to implement the Forward and Viterbi Algorithms for Hidden Markov Models (HMMs).

For a helpful refresher on HMMs and the Forward and Viterbi Algorithms you can check out the resources here, here, and here.

Tasks and Data

Please complete the forward and viterbi functions in the HiddenMarkovModel class.

We have provided two HMM models (mini_weather_hmm.npz and full_weather_hmm.npz) which explore the relationships between observable weather phenomenon and the temperature outside. Start with the mini_weather_hmm model for testing and debugging. Both include the following arrays:

  • hidden_states: list of possible hidden states
  • observation_states: list of possible observation states
  • prior_p: prior probabilities of hidden states (in order given in hidden_states)
  • transition_p: transition probabilities of hidden states (in order given in hidden_states)
  • emission_p: emission probabilities (hidden_states --> observation_states)

For both datasets, we also provide input observation sequences and the solution for their best hidden state sequences.

  • observation_state_sequence: observation sequence to test
  • best_hidden_state_sequence: correct viterbi hidden state sequence

Create an HMM class instance for both models and test that your Forward and Viterbi implementation returns the correct probabilities and hidden state sequence for each of the observation sequences.

Within your code, consider the scope of the inputs and how the different parameters of the input data could break the bounds of your implementation.

  • Do your model probabilites add up to the correct values? Is scaling required?
  • How will your model handle zero-probability transitions?
  • Are the inputs in compatible shapes/sizes which each other?
  • Any other edge cases you can think of?
  • Ensure that your code accomodates at least 2 possible edge cases.

Finally, please update your README with a brief description of your methods.

Task List

[TODO] Complete the HiddenMarkovModel Class methods
[ ] complete the forward function in the HiddenMarkovModelClass
[ ] complete the viterbi function in the HiddenMarkovModelClass

[TODO] Unit Testing
[ ] Ensure functionality on mini and full weather dataset
[ ] Account for edge cases

[TODO] Packaging
[ ] Update README with description of your methods
[ ] pip installable module (optional)
[ ] github actions (install + pytest) (optional)

Completing the Assignment

Push your code to GitHub with passing unit tests, and submit a link to your repository here

Grading

  • Algorithm implementation (6 points)

    • Forward algorithm is correct (2)
    • Viterbi is correct (2)
    • Output is correct on small weather dataset (1)
    • Output is correct on full weather dataset (1)
  • Unit Tests (3 points)

    • Mini model unit test (1)
    • Full model unit test (1)
    • Edge cases (1)
  • Style (1 point)

    • Readable code and updated README with a description of your methods
  • Extra credit (0.5 points)

    • Pip installable and Github actions (0.5)

About

License:MIT License


Languages

Language:Python 100.0%