API

You can re-use part of the functionality of this code to input data into your own python scripts for fusing scores or any other task you might need to achieve. To do so, you need to be able to import the trstk library into your script. You should set the path leading to trstk so the python interpreter knows how to find it. There are two basic ways to do this.

  1. Set the environment variable $PYTHONPATH to point to the directory containing the trstk:

    $ vim ./myScriptThatUsesStk.py #create the script
    $ export PYTHONPATH=/path/to/ScoreToolKit
    $ python ./myScriptThatUsesStk.py
    
  2. Or, you can change directories to the ScoreToolKit root directory and have your scripts inside that directory. Python automatically searches the current working directory for imports:

    $ cd /path/to/ScoreToolKit
    $ vim ./myScriptThatUsesStk.py
    $ python ./myScriptThatUsesStk.py
    

Reference Manual

The ScoreToolKit (or simply “stk”) provides functionality to load TABULA RASA conformant score files, for either plotting DET curves or for the validation of multi-file score matching.

trstk.checkModalities(data1, filename1, data2, filename2, presorted=False)[source]

Double-checks score files for fusion.

This method checks two score files to make sure they match w.r.t. to the number of clients, imposter and models. It is equivalent to making sure the first 4 columns of such files contain the same fields, after ordering.

Parameters:

data1
The pre-loaded data set using load_file()
filename1
The first score file name (string)
data2
The (second) pre-loaded data set using load_file()
filename2
The second score file name (string)
presorted
A flag indicating if the files have been pre-sorted (boolean)

Here is how to sort your score files using shell utilities sort and uniq:

$ sort my-scores.txt | uniq > my-sorted-scores.txt

Returns None.

trstk.evalDET(negatives, positives, points)[source]

Evaluates the DET curve.

This method evaluates the DET curve given a set of positives and negatives, returning two numpy arrays containing the FARs and the FRRs.

trstk.evalROC(negatives, positives, points)[source]

Evaluates the ROC curve.

This method evaluates the ROC curve given a set of positives and negatives, returning two numpy arrays containing the FARs and the FRRs.

trstk.farfrr(negatives, positives, threshold)[source]

Calculates the FAR and FRR for a given set of positives and negatives and a threshold

trstk.load_file(filename, no_labels=False)[source]

Loads a score set from a single file to memory.

Verifies that all fields are correctly placed and contain valid fields.

Returns a python list of tuples containg the following fields:

[0]
claimed identity (string)
[1]
model label (string)
[2]
real identity (string)
[3]
test label (string)
[4]
score (float)
trstk.plotDET(negatives, positives, filename='det.pdf', points=100, limits=None, title='DET Curve', labels=None, colour=False)[source]

Plots Detection Error Trade-off (DET) curve

Keyword parameters:

positives
numpy.array of positive class scores in float64 format
negatives
numpy.array of negative class scores in float64 format
filename
the output filename where to save the plot. If not specified, we output to ‘det.pdf’
points
an (optional) number of points to use for the plot. Defaults to 100.
limits
an (optional) tuple containing 4 elements that determine the maximum and minimum values to plot. Values have to exist in the internal desiredLabels variable.
title
an (optional) string containg a title to be inprinted on the top of the plot
labels
an (optional) list of labels for a legend. If None or empty, the legend is suppressed
colour
flag determining if the plot is coloured or monochrome. By default we plot in monochrome scale.
trstk.split(data)[source]

Splits the input tuple list (as returned by load_file()) into positives and negative scores.

Returns 2 numpy arrays as a tuple with (negatives, positives)

Table Of Contents

Previous topic

Score Toolkit

This Page