netkit.classifiers.io
Class ReadPrior

java.lang.Object
  extended by netkit.classifiers.io.ReadPrior

public final class ReadPrior
extends java.lang.Object

This class reads in class priors from a file such that a user can specify the priors rather than have the classifier use the priors that are estimated from training examples. The prior file should be of the format:

 value,prior-score
 ...
 
Any line that starts with '#' is ignored (treated as a comment). The 'value' in the line is the likelihood that the class attribute takes on that value. The scores are not checked to see if they add to 1.

Author:
Sofus A. Macskassy (sofmac@gmail.com)
See Also:
AttributeCategorical

Constructor Summary
ReadPrior()
           
 
Method Summary
static double[] readPrior(java.io.BufferedReader br, AttributeCategorical attribute)
          Reads in a file using the file format mentioned in the header.
static double[] readPrior(java.io.File f, AttributeCategorical attribute)
          Reads in a file using the file format mentioned in the header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadPrior

public ReadPrior()
Method Detail

readPrior

public static double[] readPrior(java.io.File f,
                                 AttributeCategorical attribute)
Reads in a file using the file format mentioned in the header. It returns the vector of scores for the values in the passed-in AttriuteCategorical--the value read in the file are matched with the index into the categorical attribute list of known values. The values in the attribute are expanded if the attribute does not already know about a given value (and if the attribute is of type AttributeExpandableCategorical).

Parameters:
f - The file to read from
attribute - The attribute whose prior likelihood scores are being read
Returns:
A vector of doubles representing the read in prior likelihood scores of observing each value in the attribute
See Also:
AttributeExpandableCategorical

readPrior

public static double[] readPrior(java.io.BufferedReader br,
                                 AttributeCategorical attribute)
Reads in a file using the file format mentioned in the header. It returns the vector of scores for the values in the passed-in AttriuteCategorical--the value read in the file are matched with the index into the categorical attribute list of known values. The values in the attribute are expanded if the attribute does not already know about a given value (and if the attribute is of type AttributeExpandableCategorical).

Parameters:
f - The file to read from
attribute - The attribute whose prior likelihood scores are being read
Returns:
A vector of doubles representing the read in prior likelihood scores of observing each value in the attribute
See Also:
AttributeExpandableCategorical