Tik-76.115 Individual Project: Guinea Pig
$Id: gpTestAnalysis.html,v 1.2 1996/04/20 16:13:39 hynde Exp $
Module gpTestAnalysis for result analysis and filtering
The python module gpTestAnalysis defines a new class derived
from gpTest and functions
for reading, analyzing and filtering the result files.
The gpTestLogic module uses following modules:
- gpTestLogic
- gpTestItems for test item
object classes (imported by gpTestLogic).
- gpDefaults for some defaults
- Various standard python modules
Load the gpTestAnalysis module this way:
import gpTestAnalysis
or
from gpTestAnalysis import *
Module gpTestAnalysis defines the
gpTestAnalysis class some
functions
for digging information out of the test items.
1 · Class gpTestAnalysis - for analyzing test results
The gpTestAnalysis class is derived from the
gpTest class. Many of the
gpTest's methods are not needed so they are redefined as dummy
functions to prevent their use accidentally.
A new test object is created, as always in python, by calling the
gpTestAnalysis class as a function:
test = gpTestAnalysis()
1.1 · Instance variables
The gpTestAnalysis class defines no new instance
variables. However, note the meaning of these variables:
- test.test_items
(list of test items)
- List of test items, one for each item ID. During analysis, one
test item contains all the answers (by all subjects being
analyzed at the same time) to that item in the item's
result list.
- test.Subjects
(list of test subjects)
- A list of test subjects whose result files are analyzed
at the same time. Usually contains many subjects in contrast to
only one when test is being performed for some subject.
1.2 · Methods
- test.load_items([filename],
[subjects])
- Load the test items from the result files of subjects.
If subjects is not given, uses the test's
subjects list.
Load_items() loads all subjects' result files and merges
results from multiple test items with the same ID into one test
item. The item's
result
dictionary then holds all answers for that test item given by
all subjects.
After loading the items are in the test object's
test_items list.
1.3 · Using the test analysis class
The usage is pretty similar to the
using of the gpTest class.
First create a new instance of the
gpTestAnalysis class:
from gpTestAnalysis import *
# ...
test = gpTestAnalysis()
Then load the configuration information:
test.load_config()
(Assumed that config information is found in the current
directory). Then add all the
test subjects to
the test:
for gpid in gpIDs:
subject = gpTestSubject(test, gpid)
subject.read_info()
where gpIDs is a list of subject IDs (giving the test object to
gpTestSubject will automatically add that subject to the test's
subjects list).
Then load test items (no need to load playlists):
test.load_items()
Now the items are loaded and you can start doing whatever you want
with the results. (See
functions' examples
for examples)
2 · Functions for extracting information from the test
- get_answers(list)
- Returns a list of answers given to items in list (which
can be a list of test items or a test object (which acts as a
list)). The result list may contain 'None' items which
means timeout/no answer.
- get_times(list)
- Returns a list of answer times from items in list. The
result list may contain 'None' items which means
timeout/no answer.
- average(list)
- Takes a list of numbers and returns a tuple
(average, variance) calculated from the list.
2.1 · Examples
If you have first done as told in
using test analysis class, you can now try
some examples. (The >>> is python's promt.)
To get a list of answers (from a AB or ABX test):
>>> l1 = get_answers(test)
>>> l1
['B', 'A', 'A', 'B', 'B', 'A', 'B', 'B', 'B', 'B', 'A', 'A', 'B', 'B',
'A', 'B', 'A', 'A', 'A', 'A', 'B', 'A']
To get a list of answer times:
>>> l2 = get_times(test)
>>> l2
[7.81689, 33.9026, 3.33335, 0.929281, 5.49302, 4.14411, 1.92197,
0.380971, 0.682314, 0.401833, 6.14924, 0.550957, 3.12145,
0.402895, 31.0784, 0.585162, 20.4645, 0.393222, 5.42638, 0.423826,
0.432659, 3.68162]
To calculate average and variance of l2:
>>> average(l2)
(5.98712045455, 89.1919732625)
·
Test Logic index
·
Document index
·
Guinea Pig
·