Here is my problem, I'm trying to teach a Hidden Markov Models using hmmlearn. I'm new to the language, and I have some difficulties to understand the differences between lists and arrays. Here is my code:
from hmmlearn import hmm
from babel import lists
import numpy as np
import unidecode as u
from numpy import char
l = []
data = []
gods_egypt = ["Amon","Anat","Anouket","Anubis","Apis","Atoum","Bastet","Bès","Gheb","Hâpy","Harmachis","Hathor","Heh","Héket","Horus","Isis","Ka","Khepri","Khonsou","Khnoum","Maât","Meresger","Mout","Nefertoum","Neith","Nekhbet","Nephtys","Nout","Onouris","Osiris","Ouadjet","Oupaout","Ptah","Rê","Rechef","Renenoutet","Satet","Sebek","Sekhmet","Selkis","Seth","Shou","Sokaris","Tatenen","Tefnout","Thot","Thouéris"]
for i in range(0, len(gods_egypt)):
data.append([])
for j in range(0, len(gods_egypt[i])):
data[i].append([u.unidecode(gods_egypt[i][j].lower())])
l.append(len(data[i]))
data = np.asarray(data).reshape(-1,1)
model = hmm.MultinomialHMM(20, verbose=True)
model = model.fit(data, l)
and the resulting output
Traceback (most recent call last):
File "~~~\HMM_test.py", line 17, in <module>
model = model.fit(data, l)
File "~~~\Python\Python36\site-packages\hmmlearn\base.py", line 420, in fit
X = check_array(X)
File "~~~\Python36-32\lib\site-packages\sklearn\utils\validation.py", line 402, in check_array
array = np.array(array, dtype=dtype, order=order, copy=copy)
ValueError: setting an array element with a sequence.
I have seen at ValueError: setting an array element with a sequence that it might be a problem of different array length, but I can't figure out how to solve it.
Any suggestion ?