我需要一些关于这个错误的帮助。我正在尝试使用 R 中的 HMM 包构建 HMM 模块。我无法理解我的代码有什么问题。错误在于使用 Baum-Welch 算法训练 HMM
lathmm = initHMM(c("S","M1","M2","M3","M4","E"),c("m","i"),c(1,0,0,0,0,0),
+ matrix(c( 0,0,0,0,0,0,
+ 1,0,0,0,0,0,
+ 0,1,0,0,0,0,
+ 0,0,1,0,0,0,
+ 0,0,0,1,0,0,
+ 0,0,0,0,1,1
+ ),6,6),
+ matrix(c(0,.5,.5,.5,.5,.5,
+ 0,.5,.5,.5,.5,.5
+ ),6,2))
>
> print(lathmm)
$States
[1] "S" "M1" "M2" "M3" "M4" "E"
$Symbols
[1] "m" "i"
$startProbs
S M1 M2 M3 M4 E
1 0 0 0 0 0
$transProbs
to
from S M1 M2 M3 M4 E
S 0 1 0 0 0 0
M1 0 0 1 0 0 0
M2 0 0 0 1 0 0
M3 0 0 0 0 1 0
M4 0 0 0 0 0 1
E 0 0 0 0 0 1
$emissionProbs
symbols
states m i
S 0.0 0.0
M1 0.5 0.5
M2 0.5 0.5
M3 0.5 0.5
M4 0.5 0.5
E 0.5 0.5
-> 初始化 HMM 没有问题。
鲍姆-韦尔奇培训:
> prot = sample(c(rep("m",100),rep("m",300)))
> bw = baumWelch(lathmm,prot,10)
Error in if (d < delta) { : missing value where TRUE/FALSE needed
-> 这是错误。
谁可以帮我这个事。我不确定这个模块有什么问题。