Calculates the margin of the prediction probabilities. Args: proba: Prediction probabilities. Returns: Margin of the prediction probabilities.
(proba: np.ndarray)
| 27 | |
| 28 | |
| 29 | def _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 | |
| 49 | def _proba_entropy(proba: np.ndarray) -> np.ndarray: |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…