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

Method log_prob

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

Source from the content-addressed store, hash-verified

183 self.n_tokens = len(vocab) if vocab is not None else len(tokens)
184
185 def log_prob(self, words, N):
186 assert N in self.counts, "You do not have counts for {}-grams".format(N)
187
188 if N > len(words):
189 err = "Not enough words for a gram-size of {}: {}".format(N, len(words))
190 raise ValueError(err)
191
192 total_prob = 0
193 for ngram in nltk.ngrams(words, N):
194 total_prob += self._log_ngram_prob(ngram)
195 return total_prob
196
197 def _log_ngram_prob(self, ngram):
198 N = len(ngram)

Callers 1

test_additiveFunction · 0.95

Calls 1

_log_ngram_probMethod · 0.95

Tested by

no test coverage detected