项目作者: AntoinePassemiers

项目描述 :
A Cython Machine Learning library dedicated to Hidden Markov Models, Markov Random Fields, etc.
高级语言: Python
项目地址: git://github.com/AntoinePassemiers/ArchMM.git
创建时间: 2016-09-21T11:47:24Z
项目社区:https://github.com/AntoinePassemiers/ArchMM

开源协议:MIT License

下载


Build status
Code analysis

ArchMM

Flexible and efficient library for designing Hidden Markov Models using arbitrary topologies and underlying statistical distributions.

  1. from archmm import HMM, HiddenState, Architecture
  2. from archmm.distributions import MultivariateGaussian
  3. # Create a HMM with 3 fully-connected hidden states
  4. # and 4-dimensional multivariate Gaussian distributions
  5. model = HMM()
  6. states = [HiddenState(MultivariateGaussian(4)) for _ in range(3)]
  7. Architecture.ergodic(states) # Fully-connected
  8. model.add_states(states)
  9. # Train the model with the Baum-Welch algorithm.
  10. # `sequences` is either a NumPy array or a list of NumPy arrays.
  11. # If a list, elements are treated as different sequences.
  12. # Arrays can have arbitrary dimensions, as long as it complies
  13. # with the support of the distributions. In the present case,
  14. # arrays have shape (n, 4), and n is sequence-dependent.
  15. model.fit(sequences)
  16. # Decode sequences with Viterbi algorithm
  17. print(model.decode(sequences))
  18. # Compute log-likelihood
  19. print(model.score(sequences))
  20. # Generate random sequence from trained model
  21. print(model.sample(15))

Custom distributions can be defined as hidden states.
More examples can be found in the examples folder.

Install the library

Please make sure you have Cython installed first.
Then you can build the library simply with:

  1. python setup.py install

Ongoing work

  • Improved initialization
  • NaN support
  • Input-Output HMM
  • MRF, etc.