com.pawjaw.classification.crf.lmcbt
Class CRFInference

java.lang.Object
  extended by com.pawjaw.classification.crf.lmcbt.CRFInference

public class CRFInference
extends java.lang.Object

Class to take trained and serialized CRF model and apply to new data for labeling. Create new instance then use set() method to specify model and configuration. Configuration specified should match that used to train the specified CRF model.


Constructor Summary
CRFInference()
           
 
Method Summary
 double accuracyForwardBackward(java.util.List<Point[]> pointss, java.util.List<int[]> true_labelss)
          Label given sequence sand compare to given labels for testing purposes.
 double accuracyViterbi(java.util.List<Point[]> pointss, java.util.List<int[]> true_labelss)
          Label given sequence sand compare to given labels for testing purposes.
 int correctForwardBackward(ExpandedPointSequence eps, int[] true_labels)
          Label given sequence and compare to given labels for testing purposes.
 int correctVirterbi(ExpandedPointSequence eps, int[] true_labels)
          Label given sequence and compare to given labels for testing purposes.
 int[] labelForwardBackward(ExpandedPointSequence eps)
          Infer the labels of the given sequence using the Forward-Backward method (most likely individual point-wise labels ).
 int[] labelViterbi(ExpandedPointSequence eps)
          Infer the labels of the given sequence using the Viterbi method (most likely overall label sequence).
 void set(Configuration c, double[][][] sbt_k)
          Set the configuration options and the CRF model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRFInference

public CRFInference()
Method Detail

set

public void set(Configuration c,
                double[][][] sbt_k)
Set the configuration options and the CRF model. Configuration options should match those used to train CRF model.

Parameters:
c - configuration options
sbt_k - serialized CRF model

correctVirterbi

public int correctVirterbi(ExpandedPointSequence eps,
                           int[] true_labels)
Label given sequence and compare to given labels for testing purposes. Use Viterbi method for labeling (most likely overall label sequence).

Parameters:
eps - sequence to label
true_labels - true labels of the points in the sequence
Returns:
number of labels correctly identified by the CRF model

correctForwardBackward

public int correctForwardBackward(ExpandedPointSequence eps,
                                  int[] true_labels)
Label given sequence and compare to given labels for testing purposes. Use Forward-Backward method for labeling (most likely individual point-wise labels).

Parameters:
eps - sequence to label
true_labels - true labels of the points in the sequence
Returns:
number of labels correctly identified by the CRF model

accuracyViterbi

public double accuracyViterbi(java.util.List<Point[]> pointss,
                              java.util.List<int[]> true_labelss)
Label given sequence sand compare to given labels for testing purposes. Use Viterbi method for labeling (most likely overall label sequence).

Parameters:
pointss - sequences to label
true_labelss - true labels of the points in the sequences
Returns:
percentage of correctly labeled points

accuracyForwardBackward

public double accuracyForwardBackward(java.util.List<Point[]> pointss,
                                      java.util.List<int[]> true_labelss)
Label given sequence sand compare to given labels for testing purposes. Use Forward-Backward method for labeling (most likely individual point-wise labels).

Parameters:
pointss - sequences to label
true_labelss - true labels of the points in the sequences
Returns:
percentage of correctly labeled points

labelViterbi

public int[] labelViterbi(ExpandedPointSequence eps)
Infer the labels of the given sequence using the Viterbi method (most likely overall label sequence). Labels are in the range specified in the configuration given to the set() method.

Parameters:
eps - given sequence to label
Returns:
the labels of each point in the sequence

labelForwardBackward

public int[] labelForwardBackward(ExpandedPointSequence eps)
Infer the labels of the given sequence using the Forward-Backward method (most likely individual point-wise labels ). Labels are in the range specified in the configuration given to the set() method.

Parameters:
eps - given sequence to label
Returns:
the labels of each point in the sequence