Skip to content
Snippets Groups Projects

WIP: initial implementation of harmonised plots

Closed Amir MOHAMMADI requested to merge vulnerability into master
1 unresolved thread
Files
9
import numpy as np
def remove_nan(scores):
"""Removes the NaNs from the scores
Parameters
----------
scores : numpy.array
The scores.
Returns
-------
scores : numpy.array
The scores excluding the NaNs.
sum_nans : int
The number of NaNs in the scores.
total : int
The total number of scores before removing the NaNs.
"""
nans = np.isnan(scores)
return scores[np.where(~nans)], sum(nans), len(scores)
def fta(neg_pos):
"""Calculates the Failure To Acquire (FtA) rate.
Calculates how many NaNs are in neg and pos in total and returns the rate.
Parameters
----------
neg_pos : (numpy.array, numpy.array)
A tuple of negative and positive scores
Returns
-------
neg : numpy.array
The negative scores with NaNs removed.
pos : numpy.array
The positive scores with NaNs removed.
fta : float
The FTA rate.
"""
fta_sum, fta_total = 0, 0
neg, sum_nans, total = remove_nan(neg_pos[0])
fta_sum += sum_nans
fta_total += total
pos, sum_nans, total = remove_nan(neg_pos[1])
fta_sum += sum_nans
fta_total += total
return (neg, pos, fta_sum / fta_total)
from . import spoof
Loading