confidenceMachine
Class ConfidenceClassifier

java.lang.Object
  |
  +--weka.classifiers.Classifier
        |
        +--confidenceMachine.ConfidenceClassifier
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable
Direct Known Subclasses:
TCMBartsRMI, TCMKNearestNeighbours

public abstract class ConfidenceClassifier
extends Classifier

Abstract classification model that produces (for each test instance) a valid confidence estimation of the membership in each class (ie. Used in Transductive/Inductive/Mondrian Confidence Machines).

Version:
$Revision: 1.0 $
Author:
David Lindsay (davidl@cs.rhul.ac.uk)
See Also:
Serialized Form

Constructor Summary
ConfidenceClassifier()
           
 
Method Summary
static double[] calculateConfidenceAndCredibility(double[] pValues)
          Calculates the pseudo-probabilistic measures using the p-values calculated for an instance like so: 'Confidence' = 1-2nd largest p-value (percentage) 'Credibility' = = Largest p-value (percentage)
static double calculatePValue(double[] alphaValues, double alphaNew)
          Calculate the p-value using the formula described by Vovk et al.
static double calculatePValue(double[] alphaValues, double alphaNew, double seed)
          Calculate the randomised p-value using the formula manipulating the strangeness values for training and test example described by Vovk et al.
 double classifyInstance(Instance instance)
          Classifies the given test instance.
abstract  double[] pValuesForInstance(Instance instance)
          Predicts the confidence p-values for class memberships a given instance.
static int[] returnRegionPrediction(double[] pValues, double sigLevel)
          Returns a region prediction (subset of possible classes) that are valid at a given significance level.
 
Methods inherited from class weka.classifiers.Classifier
buildClassifier, debugTipText, distributionForInstance, forName, getDebug, getOptions, listOptions, makeCopies, setDebug, setOptions
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfidenceClassifier

public ConfidenceClassifier()
Method Detail

pValuesForInstance

public abstract double[] pValuesForInstance(Instance instance)
                                     throws java.lang.Exception
Predicts the confidence p-values for class memberships a given instance. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of the elements that determine the region? (Have to consider how to work with numeric classes as these work very different to the nominal case).

Parameters:
instance - the instance to be classified
Returns:
an array containing the p-values of the test instance in each class (not neccesarily sum to 1)
Throws:
java.lang.Exception - if distribution could not be computed successfully

classifyInstance

public double classifyInstance(Instance instance)
                        throws java.lang.Exception
Classifies the given test instance. The instance has to belong to a dataset when it's being classified.

Overrides:
classifyInstance in class Classifier
Parameters:
instance - the instance to be classified
Returns:
the predicted most likely class for the instance or Instance.missingValue() if no prediction is made
Throws:
java.lang.Exception - if an error occurred during the prediction

calculateConfidenceAndCredibility

public static double[] calculateConfidenceAndCredibility(double[] pValues)
Calculates the pseudo-probabilistic measures using the p-values calculated for an instance like so:

Parameters:
pValues - the p-values of an instance to be classified
Returns:
the confidence and credibility value for the instance (returned in that order for the array), return Instance.missingValue() if no p-values are passed

returnRegionPrediction

public static int[] returnRegionPrediction(double[] pValues,
                                           double sigLevel)
Returns a region prediction (subset of possible classes) that are valid at a given significance level.

Parameters:
pValues - the p-values of an instance to be classified
sigLevel - the significance level to construct the region prediction
Returns:
the indexs of the classifications that are valid at the significance level, if there are none then return null (empty prediction)

calculatePValue

public static double calculatePValue(double[] alphaValues,
                                     double alphaNew)
Calculate the p-value using the formula described by Vovk et al.

Parameters:
alphaValues - the alpha 'strangeness' values of the training examples
alphaNew - the alpha 'strangeness' value of new test example
Returns:
the p-value using the formula

calculatePValue

public static double calculatePValue(double[] alphaValues,
                                     double alphaNew,
                                     double seed)
Calculate the randomised p-value using the formula manipulating the strangeness values for training and test example described by Vovk et al. Only really useful in online setting.

Parameters:
alphaValues - the alpha 'strangeness' values of the training examples
alphaNew - the alpha 'strangeness' value of new test example
seed - the random number used to break ties in equal alpha values
Returns:
the p-value using the formula


Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London