【发布时间】:2011-10-30 03:13:20
【问题描述】:
我正在开发一个使用马尔可夫链的应用程序。
此代码的示例如下:
chain = MarkovChain(order=1)
train_seq = ["","hello","this","is","a","beautiful","world"]
for i, word in enum(train_seq):
chain.train(previous_state=train_seq[i-1],next_state=word)
我正在寻找的是迭代 train_seq,但保留最后 N 个元素。
for states in unknown(train_seq,order=1):
# states should be a list of states, with states[-1] the newest word,
# and states[:-1] should be the previous occurrences of the iteration.
chain.train(*states)
希望我的问题描述足够清楚
【问题讨论】:
-
所以您希望迭代连续的对?
unknown是什么?这是您要求我们填写的内容还是您已经拥有的功能? -
不一定要配对,因为我将使用任意命令构建马尔可夫链。未知是我试图弄清楚的任务功能。