edu.harvard.seas.iis.abilities.classify
Class MovementClassifier

java.lang.Object
  extended by edu.harvard.seas.iis.abilities.classify.MovementClassifier

public class MovementClassifier
extends java.lang.Object

A front end class with high level tools for classifying pointing movements as deliberate or distracted; uses pre-trained classifiers to perform the classification so it is all ready to go.

Author:
kgajos

Field Summary
static java.lang.String DELIBERATE_PROBABILITY_KEY
           
static java.lang.String PREDICTED_CLASS_KEY
           
static java.lang.String REPORT_HEADER
           
 
Constructor Summary
MovementClassifier()
          Initializes the class and loads the default serialized versions of the classifiers from the following location in the classpath: edu/harvard/seas/iis/abilities/classify/resources/
MovementClassifier(java.lang.String classifierDirectory)
          Initializes the class and loads serialized classifiers from the location indicated in classifierDirectory variable
 
Method Summary
 void classifyMovements(java.util.Collection<Movement> movements, java.util.Vector<Movement> deliberate, java.util.Vector<Movement> distracted, boolean useTargetInformation)
          Takes movements and classifies them; classified movements are added to the deliberate and distracted vectors
 DataSet classifyMovements(DataSet movements, boolean useTargetInformation)
          Assumes the movements data set has "Predicted class" and "Prediction probability" attributes present.
 double getDeliberateProbability(weka.core.Instance movement, boolean useTargetInformation)
          Returns the probability that the movement was deliberate
 double getDeliberateProbability(Movement movement, boolean useTargetInformation)
          Returns the probability that the movement was deliberate; also modifies the movement object by adding two pieces of meta data: "deliberate probability" and "predicted class"
static void main(java.lang.String[] args)
           
 java.util.Vector<Movement> parseAndClassify(java.io.File[] files, MovementFilter filter, Parser parser, boolean useTargetInformation, boolean returnParsedMovements, java.util.Vector<java.lang.String> report)
          Reads log files, uses the parser to extract movements out of the log files, uses the filter to select only the subset of the movements that are of interest, and classifies them.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIBERATE_PROBABILITY_KEY

public static final java.lang.String DELIBERATE_PROBABILITY_KEY
See Also:
Constant Field Values

PREDICTED_CLASS_KEY

public static final java.lang.String PREDICTED_CLASS_KEY
See Also:
Constant Field Values

REPORT_HEADER

public static final java.lang.String REPORT_HEADER
See Also:
Constant Field Values
Constructor Detail

MovementClassifier

public MovementClassifier()
Initializes the class and loads the default serialized versions of the classifiers from the following location in the classpath: edu/harvard/seas/iis/abilities/classify/resources/


MovementClassifier

public MovementClassifier(java.lang.String classifierDirectory)
Initializes the class and loads serialized classifiers from the location indicated in classifierDirectory variable

Parameters:
classifierDirectory - the location where the serialized classifiers may be found
Method Detail

classifyMovements

public void classifyMovements(java.util.Collection<Movement> movements,
                              java.util.Vector<Movement> deliberate,
                              java.util.Vector<Movement> distracted,
                              boolean useTargetInformation)
                       throws java.lang.Exception
Takes movements and classifies them; classified movements are added to the deliberate and distracted vectors

Parameters:
movements - movement objects to be classified
deliberate - movements classified as deliberate will be added to this vector
distracted - movements classified as distracted will be added to this vector
useTargetInformation - if set to true, the classifier will make use of features that rely on the knowledge of the target size; if set to false, the classification will be done in a target agnostic manner
Throws:
java.lang.Exception

getDeliberateProbability

public double getDeliberateProbability(Movement movement,
                                       boolean useTargetInformation)
                                throws java.lang.Exception
Returns the probability that the movement was deliberate; also modifies the movement object by adding two pieces of meta data: "deliberate probability" and "predicted class"

Parameters:
movement - Movement to classify
useTargetInformation - if set to true, the classifier will make use of features that rely on the knowledge of the target size; if set to false, the classification will be done in a target agnostic manner
Returns:
probability that the movement was deliberate or -1 if the movement could not be classified
Throws:
java.lang.Exception

getDeliberateProbability

public double getDeliberateProbability(weka.core.Instance movement,
                                       boolean useTargetInformation)
                                throws java.lang.Exception
Returns the probability that the movement was deliberate

Parameters:
movement - movement already encoded as a Weka Instance, transformed to include additional features, and normalized!
useTargetInformation - if set to true, the classifier will make use of features that rely on the knowledge of the target size; if set to false, the classification will be done in a target agnostic manner
Returns:
Throws:
java.lang.Exception

classifyMovements

public DataSet classifyMovements(DataSet movements,
                                 boolean useTargetInformation)
                          throws java.lang.Exception
Assumes the movements data set has "Predicted class" and "Prediction probability" attributes present. This method classifies each movement and sets the value of these two attributes and returns such annotated data set

Parameters:
movements - movements encoded as Weka Intances; they have to have had additional features already computed and they have to have been normalized before being passed here
useTargetInformation -
Returns:
Throws:
java.lang.Exception

parseAndClassify

public java.util.Vector<Movement> parseAndClassify(java.io.File[] files,
                                                   MovementFilter filter,
                                                   Parser parser,
                                                   boolean useTargetInformation,
                                                   boolean returnParsedMovements,
                                                   java.util.Vector<java.lang.String> report)
                                            throws java.lang.Exception
Reads log files, uses the parser to extract movements out of the log files, uses the filter to select only the subset of the movements that are of interest, and classifies them. For now it just prints an aggregate report to the stdout

Parameters:
files - log files from which the movements are to be extracted
filter - filter for selecting a subset of the movements to be classified; if null, all movements get classified
parser - instance of Parser for extracting Movements from the log
useTargetInformation - if set to true, the classifier will make use of features that rely on the knowledge of the target size; if set to false, the classification will be done in a target agnostic manner
returnParsedMovements - will return a vector of Movement objects if this parameter is set to true; will return an empty vector otherwise; useful, if all that is needed is the report and not the movements themselves
report - a string report will be appended to this variable
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Parameters:
args -
Throws:
java.lang.Exception