MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / log_prob

Method log_prob

numpy_ml/tests/test_ngram.py:90–100  ·  view source on GitHub ↗
(self, words, N)

Source from the content-addressed store, hash-verified

88 self.n_tokens = len(vocab) if vocab is not None else len(tokens)
89
90 def log_prob(self, words, N):
91 assert N in self.counts, "You do not have counts for {}-grams".format(N)
92
93 if N > len(words):
94 err = "Not enough words for a gram-size of {}: {}".format(N, len(words))
95 raise ValueError(err)
96
97 total_prob = 0
98 for ngram in nltk.ngrams(words, N):
99 total_prob += self._log_ngram_prob(ngram)
100 return total_prob
101
102 def _log_ngram_prob(self, ngram):
103 N = len(ngram)

Callers 1

test_mleFunction · 0.95

Calls 1

_log_ngram_probMethod · 0.95

Tested by

no test coverage detected