weka.classifiers.lazy.kstar
Class KStarNumericAttribute

java.lang.Object
  extended byweka.classifiers.lazy.kstar.KStarNumericAttribute
All Implemented Interfaces:
KStarConstants

public class KStarNumericAttribute
extends java.lang.Object
implements KStarConstants

A custom class which provides the environment for computing the transformation probability of a specified test instance numeric attribute to a specified train instance numeric attribute.

Version:
$Revision 1.0 $
Author:
Len Trigg (len@reeltwo.com), Abdelaziz Mahoui (am14@cs.waikato.ac.nz)

Field Summary
protected  int m_ActualCount
          The number of train instances with no missing attribute values
protected  int m_AttrIndex
          The index of the attribute in the test and train instances
protected  double m_AverageProb
          Average probability of test attribute transforming into train attribute
protected  int m_BlendFactor
          default sphere of influence blend setting
protected  int m_BlendMethod
          0 = use specified blend, 1 = entropic blend setting
protected  KStarCache m_Cache
          A cache for storing attribute values and their corresponding scale parameters
protected  int m_ClassType
          The class attribute type
protected  double[] m_Distances
          The set of disctances from the test attribute to the set of train attributes
protected  int m_MissingMode
          missing value treatment
protected  double m_MissingProb
          Probability of test attribute transforming into train attribute with missing value
protected  int m_NumAttributes
          The number of attributes
protected  int m_NumClasses
          The number of class values
protected  int m_NumInstances
          The number of instances in the dataset
protected  int[][] m_RandClassCols
          Set of colomns: each colomn representing a randomised version of the train dataset class colomn
protected  double m_Scale
          The scale parameter
protected  double m_SmallestProb
          Smallest probability of test attribute transforming into train attribute
protected  Instance m_Test
          The test instance
protected  Instance m_Train
          The train instance
protected  Instances m_TrainSet
          The training instances used for classification.
 
Fields inherited from interface weka.classifiers.lazy.kstar.KStarConstants
B_ENTROPY, B_SPHERE, EPSILON, FLOOR, FLOOR1, INITIAL_STEP, LOG2, M_AVERAGE, M_DELETE, M_MAXDIFF, M_NORMAL, NUM_RAND_COLS, OFF, ON, ROOT_FINDER_ACCURACY, ROOT_FINDER_MAX_ITER
 
Constructor Summary
KStarNumericAttribute(Instance test, Instance train, int attrIndex, Instances trainSet, int[][] randClassCols, KStarCache cache)
          Constructor
 
Method Summary
private  void calculateEntropy(double scale, KStarWrapper params)
          Calculates several parameters aside from the entropy: for a specified scale factor, calculates the actual entropy, a random entropy using a randomized set of class value colomns, and records the average and smallest probabilities (for use in missing value case).
private  void calculateSphereSize(double scale, KStarWrapper params)
          Calculates the size of the "sphere of influence" defined as: sphere = sum(P)^2/sum(P^2) where P(i) = root*exp(-2*i*root).
private  void init()
          Initializes the m_Attributes of the class.
private  double PStar(double x, double scale)
          Calculates the value of P for a given value x using the expression: P(x) = scale * exp( -2.0 * x * scale )
private  double scaleFactorUsingBlend()
          Calculates the scale factor for the attribute indexed "m_AttrIndex" in test instance "m_Test" using a global blending factor (default value is 20%).
private  double scaleFactorUsingEntropy()
          Calculates the scale factor using entropy.
 void setBlendFactor(int factor)
          Set the blending factor
 void setBlendMethod(int method)
          Set the blending method
 void setMissingMode(int mode)
          Set the missing value mode.
 void setOptions(int missingmode, int blendmethod, int blendfactor)
          Set options.
 double transProb()
          Calculates the transformation probability of the attribute indexed "m_AttrIndex" in test instance "m_Test" to the same attribute in the train instance "m_Train".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_TrainSet

protected Instances m_TrainSet
The training instances used for classification.


m_Test

protected Instance m_Test
The test instance


m_Train

protected Instance m_Train
The train instance


m_AttrIndex

protected int m_AttrIndex
The index of the attribute in the test and train instances


m_Scale

protected double m_Scale
The scale parameter


m_MissingProb

protected double m_MissingProb
Probability of test attribute transforming into train attribute with missing value


m_AverageProb

protected double m_AverageProb
Average probability of test attribute transforming into train attribute


m_SmallestProb

protected double m_SmallestProb
Smallest probability of test attribute transforming into train attribute


m_Distances

protected double[] m_Distances
The set of disctances from the test attribute to the set of train attributes


m_RandClassCols

protected int[][] m_RandClassCols
Set of colomns: each colomn representing a randomised version of the train dataset class colomn


m_ActualCount

protected int m_ActualCount
The number of train instances with no missing attribute values


m_Cache

protected KStarCache m_Cache
A cache for storing attribute values and their corresponding scale parameters


m_NumInstances

protected int m_NumInstances
The number of instances in the dataset


m_NumClasses

protected int m_NumClasses
The number of class values


m_NumAttributes

protected int m_NumAttributes
The number of attributes


m_ClassType

protected int m_ClassType
The class attribute type


m_MissingMode

protected int m_MissingMode
missing value treatment


m_BlendMethod

protected int m_BlendMethod
0 = use specified blend, 1 = entropic blend setting


m_BlendFactor

protected int m_BlendFactor
default sphere of influence blend setting

Constructor Detail

KStarNumericAttribute

public KStarNumericAttribute(Instance test,
                             Instance train,
                             int attrIndex,
                             Instances trainSet,
                             int[][] randClassCols,
                             KStarCache cache)
Constructor

Method Detail

init

private void init()
Initializes the m_Attributes of the class.


transProb

public double transProb()
Calculates the transformation probability of the attribute indexed "m_AttrIndex" in test instance "m_Test" to the same attribute in the train instance "m_Train".

Returns:
the probability value

scaleFactorUsingBlend

private double scaleFactorUsingBlend()
Calculates the scale factor for the attribute indexed "m_AttrIndex" in test instance "m_Test" using a global blending factor (default value is 20%).

Returns:
the scale factor value

calculateSphereSize

private void calculateSphereSize(double scale,
                                 KStarWrapper params)
Calculates the size of the "sphere of influence" defined as: sphere = sum(P)^2/sum(P^2) where P(i) = root*exp(-2*i*root). Since there are n different training instances we multiply P(i) by 1/n.


scaleFactorUsingEntropy

private double scaleFactorUsingEntropy()
Calculates the scale factor using entropy.

Returns:
the scale factor value

calculateEntropy

private void calculateEntropy(double scale,
                              KStarWrapper params)
Calculates several parameters aside from the entropy: for a specified scale factor, calculates the actual entropy, a random entropy using a randomized set of class value colomns, and records the average and smallest probabilities (for use in missing value case).


PStar

private double PStar(double x,
                     double scale)
Calculates the value of P for a given value x using the expression: P(x) = scale * exp( -2.0 * x * scale )

Parameters:
x - input value
scale - the scale factor
Returns:
output of the function P(x)

setOptions

public void setOptions(int missingmode,
                       int blendmethod,
                       int blendfactor)
Set options.

Parameters:
missingmode - the missing value treatment to use
blendmethod - the blending method to use
blendfactor - the level of blending to use

setMissingMode

public void setMissingMode(int mode)
Set the missing value mode.

Parameters:
mode - the type of missing value treatment to use

setBlendMethod

public void setBlendMethod(int method)
Set the blending method

Parameters:
method - the blending method to use

setBlendFactor

public void setBlendFactor(int factor)
Set the blending factor

Parameters:
factor - the level of blending to use