File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 2
2
# https://udemy.com/unsupervised-machine-learning-hidden-markov-models-in-python
3
3
# http://lazyprogrammer.me
4
4
# Create a Markov model for site data.
5
+ from __future__ import print_function , division
6
+ from future .utils import iteritems
5
7
import numpy as np
6
8
7
9
transitions = {}
14
16
row_sums [s ] = row_sums .get (s , 0. ) + 1
15
17
16
18
# normalize
17
- for k , v in transitions . iteritems ():
19
+ for k , v in iteritems (transitions ):
18
20
s , e = k
19
21
transitions [k ] = v / row_sums [s ]
20
22
21
23
# initial state distribution
22
- print "initial state distribution:"
23
- for k , v in transitions . iteritems ():
24
+ print ( "initial state distribution:" )
25
+ for k , v in iteritems (transitions ):
24
26
s , e = k
25
27
if s == '-1' :
26
- print e , v
28
+ print ( e , v )
27
29
28
30
# which page has the highest bounce?
29
- for k , v in transitions . iteritems ():
31
+ for k , v in iteritems (transitions ):
30
32
s , e = k
31
33
if e == 'B' :
32
- print "bounce rate for %s: %s" % (s , v )
34
+ print ( "bounce rate for %s: %s" % (s , v ) )
You can’t perform that action at this time.
0 commit comments