MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / list2pdict

Function list2pdict

hmm_class/frost.py:68–76  ·  view source on GitHub ↗
(ts)

Source from the content-addressed store, hash-verified

66 initial[t] = c / initial_total
67
68def list2pdict(ts):
69 # turn each list of possibilities into a dictionary of probabilities
70 d = {}
71 n = len(ts)
72 for t in ts:
73 d[t] = d.get(t, 0.) + 1
74 for t, c in iteritems(d):
75 d[t] = c / n
76 return d
77
78for t_1, ts in iteritems(second_word):
79 # replace list with dictionary of probabilities

Callers 1

frost.pyFile · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected