I work with scikit-learn GaussianHMM and get the next ValueError when I try to fit it to some observations. here is the code that demonstrates the error:
>>> from sklearn.hmm import GaussianHMM >>> arr = np.matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> arr matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> gmm = GaussianHMM () >>> gmm.fit (arr) /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/function_base.py:2005: RuntimeWarning: invalid value encountered in divide return (dot(X, XTconj()) / fact).squeeze() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Python/2.7/site-packages/sklearn/hmm.py", line 427, in fit framelogprob = self._compute_log_likelihood(seq) File "/Library/Python/2.7/site-packages/sklearn/hmm.py", line 737, in _compute_log_likelihood obs, self._means_, self._covars_, self._covariance_type) File "/Library/Python/2.7/site-packages/sklearn/mixture/gmm.py", line 58, in log_multivariate_normal_density X, means, covars) File "/Library/Python/2.7/site-packages/sklearn/mixture/gmm.py", line 564, in _log_multivariate_normal_density_diag + np.dot(X ** 2, (1.0 / covars).T)) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/matrixlib/defmatrix.py", line 343, in __pow__ return matrix_power(self, other) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/matrixlib/defmatrix.py", line 160, in matrix_power raise ValueError("input must be a square array") ValueError: input must be a square array >>>
How can i fix this? It seems that I give him reliable data. Thank you