MCPcopy Create free account
hub / github.com/modAL-python/modAL / _proba_margin

Function _proba_margin

modAL/uncertainty.py:29–46  ·  view source on GitHub ↗

Calculates the margin of the prediction probabilities. Args: proba: Prediction probabilities. Returns: Margin of the prediction probabilities.

(proba: np.ndarray)

Source from the content-addressed store, hash-verified

27
28
29def _proba_margin(proba: np.ndarray) -> np.ndarray:
30 """
31 Calculates the margin of the prediction probabilities.
32
33 Args:
34 proba: Prediction probabilities.
35
36 Returns:
37 Margin of the prediction probabilities.
38 """
39
40 if proba.shape[1] == 1:
41 return np.zeros(shape=len(proba))
42
43 part = np.partition(-proba, 1, axis=1)
44 margin = - part[:, 0] + part[:, 1]
45
46 return margin
47
48
49def _proba_entropy(proba: np.ndarray) -> np.ndarray:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…