def __init__(self, sequence, predicted, expected): self.sequence = check.check_not_empty(sequence) self.predicted = check.check_instance(predicted, SequenceStats) self.expected = check.check_instance(expected, SequenceStats) check.check_length(self.predicted.values, len(self.sequence)) check.check_length(self.expected.values, len(self.sequence)) self.perplexity = perplexity(self.expected.probabilities)
def __init__(self, values, probabilities, ranks=None): self.values = check.check_iterable(values) self.probabilities = check.check_length( check.check_iterable(probabilities), len(self.values)) self.ranks = check.check_length(check.check_iterable(ranks, noneable=True), len(self.values), noneable=True)
def __init__(self, labels, array): self.labels = check.check_instance(labels, Labels) self.array = check.check_length(array, len(self.labels)) self._prediction = None self._prediction_probability = None self._distribution = None self._ranked_items = None
def vector_encode(self, value, handle_oov=False): check.check_length(value, len(self.fields)) return np.concatenate([ self.fields[i].vector_encode(v, handle_oov) for i, v in enumerate(value) ])