Git Product home page Git Product logo

hmms's People

Contributors

coolshreysh1000 avatar dependabot[bot] avatar lopatovsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hmms's Issues

pip3 install issue

when I use 'pip3 install hmms' command on Centos, it shows[Errno 2] No such file or directory: 'README.md', how can I fix the issue?

MLE errors

I have found two errors in function maximum likelihood estimation:

hmm = hmms.DtHMM.random(2,5)
states, seq = hmm.generate(1000);
hmm.maximum_likelihood_estimation(states, seq)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "hmms/dthmm.pyx", line 332, in hmms.dthmm.DtHMM.maximum_likelihood_estimation (hmms/dthmm.c:11523)
  File "hmms/dthmm.pyx", line 352, in hmms.dthmm.DtHMM.maximum_likelihood_estimation (hmms/dthmm.c:10930)
TypeError: Cannot convert numpy.int64 to numpy.ndarray

This can be fixed using it in following way (which is not too intuitive).

hmm = hmms.DtHMM.random(2,5)
states, seq = hmm.generate(1000);
hmm.maximum_likelihood_estimation(numpy.ndarray(states), numpy.ndarray(seq))

The second problem appears when the sequence is too long.

ValueError: sequence too large; cannot be greater than 32

Does the library support multivariate time series ?

I have a time series where there are at any given point 5 observables Eg. a patient visit- [blood pressure, temperature, blood sugar...]. Is it possible to give this multiple emission to the HMM? As I saw, there is only one emission variable. Please let me know if this is possible?

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I have been using google colab. I would like to work with Hidden markov, so I would like to install a library called hmms On installing pip install hmms, i received the following error.

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I also try to install the same library in Pycharm IDE, I received the same error with some call backs.

Command "python setup.py egg_info" failed with error code 1 in C:\Users\eponr\AppData\Local\Temp\pycharm-packaging\hmms\

Collecting hmms
  Using cached https://files.pythonhosted.org/packages/e9/e4/c070c44ec8a391f6d5501316d1ed7615058f1fd365ff4ed65c9636d0bf62/hmms-0.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\eponr\AppData\Local\Temp\pycharm-packaging\hmms\setup.py", line 22, in <module>
        ext_modules=cythonize(glob.glob('hmms/*.pyx'), language_level=3, include_dirs=[numpy.get_include()]),
      File "C:\Users\eponr\PycharmProjects\untitled1\venv\lib\site-packages\Cython\Build\Dependencies.py", line 955, in cythonize
        c_options = CompilationOptions(**options)
      File "C:\Users\eponr\PycharmProjects\untitled1\venv\lib\site-packages\Cython\Compiler\Main.py", line 563, in __init__
        raise ValueError(message)
    ValueError: got unknown compilation option, please remove: include_dirs


What does it means and how can i rectify this issue ? kindly suggest some solution to get working

Units on Q matrix for CtHMM

I'm trying to do a form of HMM clustering where I fit an HMM to each group of data points, then construct a big HMM that handles the cluster assignment for me. I've done this with regular HMMs in the past and am trying to port the idea over to work with your continuous time HMMs, but I'm a bit unclear on the units of the Q matrix that is passed into the CtHMM constructor.

Your ipython notebooks says # Q is the matrix of transition rates from state [row] to state [column]. Digging into your code, it looks like if I run scipy.linalg.expm(chmm.q) I can get something akin to transition probabilities that should sum to 1, and I can translate probabilities into transition rates by doing the opposite, scipy.linalg.logm(Q_prob) does this sound right to you?

What I'm trying to do is to construct an HMM where there are groups of state that are connected to within group, but not between group and there is a start probability that specifies the probability that a sequence is in any one group. So my parameters might look something like this:

Initial probabilities (π) :
          0
0  0.633333
1  0.000000
2  0.000000
3  0.066667
4  0.300000
5  0.000000
Transition rate matrix (Q):
          0          1          2          3          4         5
0 -0.391591   0.313380   0.078211   0.000000   0.000000  0.000000
1  0.949768  -0.960014   0.010246   0.000000   0.000000  0.000000
2  5.652769  21.046363 -26.699132   0.000000   0.000000  0.000000
3  0.000000   0.000000   0.000000  -0.282953   0.006097  0.276856
4  0.000000   0.000000   0.000000  13.135779 -14.030817  0.895038
5  0.000000   0.000000   0.000000   0.661941   0.003459 -0.665400
Transition probabilities for one time unit :
          0         1         2         3         4         5
0  0.790908  0.206685  0.002406  0.000000  0.000000  0.000000
1  0.526236  0.472067  0.001697  0.000000  0.000000  0.000000
2  0.575279  0.422892  0.001829  0.000000  0.000000  0.000000
3  0.000000  0.000000  0.000000  0.820134  0.000402  0.179464
4  0.000000  0.000000  0.000000  0.801739  0.000399  0.197862
5  0.000000  0.000000  0.000000  0.430510  0.000324  0.569167
Emission probabilities matrix (B):
          0         1         2
0  0.359413  0.000000  0.640587
1  0.000000  1.000000  0.000000
2  0.333333  0.333333  0.333333
3  0.000000  0.583333  0.416667
4  0.000000  1.000000  0.000000
5  1.000000  0.000000  0.000000

I ask about the units of Q because when I try and fit this CtHMM to the data I get the following error:

  File "hmms/cthmm.pyx", line 907, in hmms.cthmm.CtHMM.baum_welch
  File "hmms/cthmm.pyx", line 1060, in hmms.cthmm.CtHMM._baum_welch
ValueError: Parameter error! Matrix Q can't contain unreachable states.

I'm not sure if it is because I specified the units wrong, or if maybe your formulation doesn't like the somewhat strange Q matrix I provided.

I'm curious to hear your thoughts and, if possible, to get a brief description of the units for Q.

Thanks!

Chris

AttributeError: module 'numpy' has no attribute 'int'.

In the function viterbi from dthmm.pyx, on line 262 it is used

 cdef numpy.ndarray[int_t, ndim=2] psi = numpy.empty( (size,states_num), dtype=numpy.int )

Change it to

 cdef numpy.ndarray[int_t, ndim=2] psi = numpy.empty( (size,states_num), dtype=int )

Otherwise I am getting error

AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Cython "include_dirs" option causing installation error

Installation using pip throws the following error. It seems to be caused by the include_dirs option of Cython.

Collecting hmms
  Downloading hmms-0.1.tar.gz (412kB)
    100% |████████████████████████████████| 419kB 2.1MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-6_n03aco/hmms/setup.py", line 22, in <module>
        ext_modules=cythonize(glob.glob('hmms/*.pyx'), language_level=3, include_dirs=[numpy.get_include()]),
      File "/usr/local/lib/python3.5/dist-packages/Cython/Build/Dependencies.py", line 909, in cythonize
        c_options = CompilationOptions(**options)
      File "/usr/local/lib/python3.5/dist-packages/Cython/Compiler/Main.py", line 559, in __init__
        raise ValueError(message)
    ValueError: got unknown compilation option, please remove: include_dirs
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-6_n03aco/hmms/

VERSION INFO:
Python 3.5.2
Cython==0.27.1
numpy==1.13.3

ImportError: No module named 'hmms.dthmm'

After I successfully install by pip install hmms, I got an error when import hmms.

`---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in ()
1 import numpy as np
2 import matplotlib.pyplot as plt
----> 3 import hmms
4
5 get_ipython().run_line_magic('matplotlib', 'inline')

~/work/HMMs/hmms/init.py in ()
----> 1 from .dthmm import *
2 from .cthmm import *
3 from .hmm import *
4 from .art import *
5 from .train import *

ImportError: No module named 'hmms.dthmm'`

glaucoma dataset and Alzheimer's disease dataset

Do you have access to the glaucoma dataset and Alzheimer's disease dataset mentioned in the paper "Efficient Learning of Continuous-Time Hidden Markov Models for Disease Progression"?
Is it possible to produce the same results provided in the paper?

MLE ValueError

Hi,
i love using this library but everytime i try to use the (discrete) maximum_likelihood_estimation i end up with this Error:

dhmm1.maximum_likelihood_estimation(S1, K1)
File "hmms\dthmm.pyx", line 353, in hmms.dthmm.DtHMM.maximum_likelihood_estimation
File "hmms\dthmm.pyx", line 379, in hmms.dthmm.DtHMM.maximum_likelihood_estimation
ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'

even your example Code does not work for me.
Changing the dtype of the input Arrays to int32 didn't help.
I use Pycharm on Windows, maybe it's a Kernel thing.

Do you have any idea?
thx

Is there a way to use different numbers of time points per sequence?

Hi,

I was wondering if there's a way to use different numbers of time points per sequence? Currently when I try to do this, the program complains that the list can't be converted to a numpy array. Apologies for raising this as an issue but I didn't know how to comment here.

Thanks.

Best regards,
DIego

[Question] Support for emission probabilites as a PDF?

Firstly, sorry if this is not the correct place to submit questions such as this one.

I have been reviewing all the Python package for implementing discrete-time HMMs and came across your work. First of all, thanks. Very neat library (plot_hmm is great!).

I am wondering if it's possible to have emission probabilities defined as a PDF (say, multinomial), instead of the current matrix form. In my use case, emissions take continuous values. Is this possible or is it out of the library's scope? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.