Module Contents

This documentation is automatically generated by scanning all the source code. Parts may be incomplete.

DataRaw

class pyWitness.DataRaw(fileName, excelSheet='data used', dataMapping=None)

Bases: object

DataRaw : wrapper for raw eyewitness data

Parameters
  • fileName (str) – input file name (either csv or excel)

  • excelSheet (str) – name of the excel sheet to use

  • dataMapping (map) – python map to change columns and values

dataSelected

Data frame of selected data for processing

fileName

Raw data file name

excelSheet

Excel sheet name

dataMapping

Map of columns and values for renaming

data

Data frame of all raw data for processing

loadData()

Load data from file using panda functions

Return type

None

setLineupSize(header)

Set the lineupSize column name in the dataMapping

Return type

None

setTargetLineup(header)

Set the targetLineup column name in the dataMapping

Return type

None

setTargetLineupPresent(value)

Set the targetPresent value in the dataMapping

Return type

None

setTargetLineupAbsent(value)

Set the targetAbsent value in the dataMapping

Return type

None

setResponseType(header)

Set the responseType column name in the dataMapping

Return type

None

setResponseTypeSuspectId(value)

Set the suspectId value in the dataMapping

Return type

None

setResponseTypeFillerId(value)

Set the fillerId value in the dataMapping

Return type

None

setResponseTypeRejectId(value)

Set the reject value in the dataMapping

Return type

None

descriptiveStatistics(column)
renameRawData()

Remap column and values to a consistent set

Return type

None

checkData()
columnValues(columnName)
checkColumn(columnName)
collapseTargetAbsentSuspectId()

Convert targetAbsent suspectIds to targetAbsent fillerIds

Returns

collapseCategoricalData(column='confidence', map={0: 30, 10: 30, 20: 30, 30: 30, 40: 30, 50: 30, 60: 30, 70: 75, 80: 75, 90: 95, 100: 95}, reload=False)

Take values of column and convert to new values in map

Parameters
  • column (str) – data column to map

  • map (map) – value map

  • reload (bool) – flag to reaload data

Return type

None

collapseContinuousData(column='confidence', bins=[- 1, 60, 80, 100], labels=[1, 2, 3])

Take values of column and rebin to new keys in bins

Parameters
  • column (str) – data column to create bin catagories

  • bins (map) – Map of categories and bins

:rtype:None

resampleWithReplacement()

Resample data with replacement and return copy of object. Required for bootstrapping the confidence interval calcualations

shuffle()
resampleParticipantTrial(nTrial=100, iParticipant=0)
addParticipant(participantId=None, lineupSize=6, targetLineup='targetPresent', responseType='suspectId', confidence=0, n=1)
cutData(column='', value='', option='keep')

Data to keep

Parameters
  • column

  • value

Returns

isDesignateId()
removeDesignates()
process(column='', condition='', reverseConfidence=False, pAUCLiberal=1.0, levels=None, option='all', dependentVariable='confidence', baseRate=0.5)

Process the raw data and returns DataProcessed object

Parameters
  • column (str) – Dataframe column which is tselected for processing

  • condition (bool) – condition for the column

  • reverseConfidence – flip the confidence (usually low number to high)

Return type

DataProcessed

writeCsv(fileName)

Write raw data Dataframe to csv file

Parameters

fileName (str) – File name of the excel file to write

writeExcel(fileName, engine='openpyxl')

Write raw data Dataframe to excel file

Parameters
  • fileName (str) – File name of the excel file to write

  • engine (str) – Excel output engine

Return type

None

DataTranslator

DataProcessed

class pyWitness.DataProcessed(dataRaw, reverseConfidence=False, lineupSize=1, pAUCLiberal=1.0, levels=None, option='all', dependentVariable='confidence', baseRate=0.5)

Bases: object

Processed data class

Parameters
  • dataRaw (str or DataRaw) – Instance of raw data class or csv file name with binned data

  • reverseConfidence (bool) – Flag if confidence decreases with increasing numerical value

  • lineupSize (int) – Number of people in the lineup

calculatePivot()

Calculate fequency pivot table against ‘confidence’

Return type

None

calculateRates()

Calculate cumulative rates from data_pivot. Result stored in data_rates

Return type

None

calculateConfidence()

Calculate average confidence for a bin. Result stored in data_rates[‘confidence’]

calculateRelativeFrequency()

Calculate relative frequency from data_pivot. Result stored in data_rates[‘cf’]

calculateCAC()

Calculate confidence accuracy characteristic from data_pivot. Result stored in data_rates[‘cac’]

calculatePAUC(xmax=1.0)

Calculate partial area under the curve from (0,0) to (xmax, y(xmax))

Parameters

xmax (float) – Upper integration limit

Return type

float

calculateNormalisedAUC()
calculateDPrime()
calculateConfidenceBootstrap(nBootstraps=200, cl=95, plotROC=False, plotCAC=False)
comparePAUC(other)

Statistical test compare two pAUCs

Parameters

other (DataProcessed) – object to compare against

Returns

plotROC(label='ROC', relativeFrequencyScale=800, errorType='bars', color=None, alpha=1)

Plot the receiver operating characteristic (ROC) for the data. The symbol size is proportional to relative frequency. If confidence limits are calculated using calculateConfidenceBootstrap they are also plotted

Parameters
  • label (str) – plot label for legends

  • relativeFrequencyScale (float) – scale of relative frequency (RF) to symbol size.

Return type

None

plotCAC(relativeFrequencyScale=800, errorType='bars', color=None, label='', oldLabels=None, newLabels=None, alpha=1)

Plot the confidence accuracy characteristic (CAC) for the data. The symbol size is proportional to relative frequency. If confidence limits are calculated using calculateConfidenceBootstrap they are also plotted.

Parameters
  • label (str) – plot label for legends

  • relativeFrequencyScale – scale of relative frequncy (RF) to symbol size.

Return type

None

plotRAC()
plotHitVsFalseAlarmRate()
printPivot()
printRates()
printDescriptiveStats()
isDesignateId()
property numberConditions

Number of confidences or other conditions

Return type

int

property numberLineups
property liberalTargetAbsentSuspectId

Returns the maximum targetAbsent suspectId rate

Return type

float

property liberalTargetAbsentFillerId

Returns the maximum targetAbsent falseId rate

Return type

float

writeRatesCsv(fileName)

Write data_rates Dataframe to CSV file :rtype: None

writeRatesExcel(fileName, engine='openpyxl')

Write data_rates Dataframe to excel file

Parameters
  • fileName (str) – File name of the excel file to write

  • engine (str) – Excel output engine

Return type

None

writePivotCsv(fileName)

Write data_rates Dataframe to CSV file

Parameters

fileName (str) – File name of the CSV file to write

Return type

None

writePivotSimpleCsv(fileName)

Write data_pivot Dataframe to CSV file

Parameters

fileName (str) – File name of the CSV file to write

Return type

None

writePivotExcel(fileName, engine='openpyxl')

Write data_pivot Dataframe to excel file

Parameters
  • fileName (str) – File name of the excel file to write

  • engine (str) – Excel output engine

Return type

None

ModelFit

class pyWitness.ModelFitIndependentObservation(processedData, debug=False, integrationSigma=8, chi2Var='expected')

Bases: pyWitness.ModelFits.ModelFit

setEqualVariance()
setUnequalVariance()
monteCarloDecision(pred_tafid_array, pred_tpsid_array, pred_tpfid_array, memoryStrength)
calculateCumulativeFrequencyForCriterion(c)