pedl.frameworks.util module

pedl.frameworks.util.binary_error_rate(predictions: numpy.ndarray, labels: numpy.ndarray) → float

Return the classification error rate for binary classification.

pedl.frameworks.util.binary_error_rate_batched(predictions: numpy.ndarray, labels: numpy.ndarray) → Tuple[float, int]

Batched version of binary_error_rate(); use with mean_reducer().

pedl.frameworks.util.elementwise_mean(batches: List[numpy.ndarray]) → numpy.ndarray

Reducer that constructs an elementwise mean.

pedl.frameworks.util.error_rate(predictions: numpy.ndarray, labels: numpy.ndarray) → numpy.float64

Return the error rate based on dense predictions and dense labels.

pedl.frameworks.util.error_rate_batched(predictions: numpy.ndarray, labels: numpy.ndarray) → Tuple[numpy.float64, int]

Batched version of error_rate(); use with error_rate_reducer().

pedl.frameworks.util.error_rate_reducer(batches: List[Tuple[numpy.float64, int]]) → numpy.float64

Reducer for error_rate_batched().

pedl.frameworks.util.mean_reducer(batches: List[Tuple[float, int]]) → float

Reducer that constructs a mean; see binary_error_rate_batched().

pedl.frameworks.util.predicted_class_frequencies(predictions: numpy.ndarray, true_labels: numpy.ndarray) → List[Dict[str, Any]]

Given an ndarray containing predicted class probabilities, returns the number of times each class was predicted with the highest probability. The return value is a list of two-element dictionaries: [{"label": n_0, "count": c_0}, ...], meaning that the n_0 ‘th class was predicted c_0 times. If a class is never predicted, it is omitted from the return value.

NOTE: true_labels are ignored.

pedl.frameworks.util.sparse_multiclass_error_rate(predictions: numpy.ndarray, labels: numpy.ndarray) → numpy.float64

Return the error rate based on dense predictions and sparse labels.