Safe Haskell | Safe-Infered |
---|

Data.HMM is a library for using Hidden Markov Models (HMMs) with Haskell. HMMs are a common method of machine learning. All of the most frequently used algorithms---the forward and backwards algorithms, Viterbi, and Baum-Welch---are implemented in this library.

- data HMM stateType eventType = HMM {}
- type Prob = LogFloat
- forward :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> [eventType] -> Prob
- backward :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> [eventType] -> Prob
- viterbi :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> Array Int eventType -> [stateType]
- baumWelch :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> Array Int eventType -> Int -> HMM stateType eventType
- baumWelchItr :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> Array Int eventType -> HMM stateType eventType
- simpleMM :: (Eq a1, Eq a, Num a, Show a1) => [a1] -> a -> HMM [a1] a1
- simpleHMM :: (Eq stateType, Show eventType, Show stateType) => [stateType] -> [eventType] -> HMM stateType eventType
- hmmJoin :: (Eq stateType, Eq eventType, Read stateType, Show stateType) => HMM stateType eventType -> HMM stateType eventType -> Prob -> HMM (Int, stateType) eventType
- verifyhmm :: HMM stateType eventType -> IO ()
- loadHMM :: (Eq eventType, Eq stateType, Read stateType, Read eventType, Show eventType, Show stateType) => FilePath -> IO (HMM stateType eventType)
- saveHMM :: (Show stateType, Show eventType) => String -> HMM stateType eventType -> IO ()

# Documentation

forward :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> [eventType] -> ProbSource

forward algorithm determines the probability that a given event array would be emitted by our HMM

backward :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> [eventType] -> ProbSource

backwards algorithm does the same thing as the forward algorithm, just a different implementation

viterbi :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> Array Int eventType -> [stateType]Source

Viterbi's algorithm calculates the most probable path through our states given an event array

baumWelch :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> Array Int eventType -> Int -> HMM stateType eventTypeSource

Baum-Welch is used to train an HMM

baumWelchItr :: (Eq eventType, Eq stateType, Show eventType, Show stateType) => HMM stateType eventType -> Array Int eventType -> HMM stateType eventTypeSource

simpleMM :: (Eq a1, Eq a, Num a, Show a1) => [a1] -> a -> HMM [a1] a1Source

Use simpleMM to create an untrained standard Markov model

simpleHMM :: (Eq stateType, Show eventType, Show stateType) => [stateType] -> [eventType] -> HMM stateType eventTypeSource

Use simpleHMM to create an untrained hidden Markov model

hmmJoin :: (Eq stateType, Eq eventType, Read stateType, Show stateType) => HMM stateType eventType -> HMM stateType eventType -> Prob -> HMM (Int, stateType) eventTypeSource

Joins 2 HMMs by connecting every state in the first HMM to every state in the second, and vice versa, with probabilities based on the join ratio

verifyhmm :: HMM stateType eventType -> IO ()Source

initProbs should always equal 1; the others should equal the number of states