Skip to content

Commit 551283f

Browse files
committed
update
1 parent c06bde6 commit 551283f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

hmm_class/hmm_classifier.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ def __init__(self):
2424

2525
def fit(self, X, Y, V):
2626
K = len(set(Y)) # number of classes - assume 0..K-1
27+
N = len(Y)
2728
self.models = []
2829
self.priors = []
2930
for k in range(K):
3031
# gather all the training data for this class
3132
thisX = [x for x, y in zip(X, Y) if y == k]
3233
C = len(thisX)
33-
self.priors.append(np.log(C))
34+
self.priors.append(np.log(C) - np.log(N))
3435

3536
hmm = HMM(5)
3637
hmm.fit(thisX, V=V, print_period=1, learning_rate=1e-2, max_iter=80)

0 commit comments

Comments
 (0)