All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.m5.M5Utils

java.lang.Object
   |
   +----weka.classifiers.m5.M5Utils

public final class M5Utils
extends Object
Class for some small methods used in M5Java

Version:
$Revision: 1.2 $
Author:
Yong Wang (yongwang@cs.waikato.ac.nz)

Constructor Index

 o M5Utils()

Method Index

 o absDev(int, Instances)
Returns the absolute deviation value of the instances values of an attribute
 o correlation(double[], double[], int)
Returns the correlation coefficient of two double vectors
 o deleteTrailingZerosAndDot(StringBuffer)
Deletes the trailing zeros and decimal point in a stringBuffer
 o doubleToStringF(double, int, int)
Rounds a double and converts it into a formatted right-justified String.
 o doubleToStringG(double, int, int)
Rounds a double and converts it into a formatted right-justified String.
 o eqDouble(double, double)
Tests if two double values are equal to each other
 o errorMsg(String)
Prints error message and exits
 o floorDouble(double)
Returns the largest (closest to positive infinity) long integer value that is not greater than the argument.
 o hasEnumAttr(Instances)
Tests if enumerated attribute(s) exists in the instances
 o hasMissing(Instances)
Tests if missing value(s) exists in the instances
 o headToString()
Prints the head lines of the output
 o roundDouble(double)
Rounds a double
 o separatorToString()
Prints sepearating line
 o smoothenValue(double, double, int, int)
Returns the smoothed values according to the smoothing formula (np+kq)/(n+k)
 o sqrSum(int, Instances)
Returns the squared sum of the instances values of an attribute
 o stdDev(int, Instances)
Returns the standard deviation value of the instances values of an attribute
 o sum(int, Instances)
Returns the sum of the instances values of an attribute
 o variance(int, Instances)
Returns the variance value of the instances values of an attribute

Constructors

 o M5Utils
 public M5Utils()

Methods

 o hasEnumAttr
 public static final boolean hasEnumAttr(Instances inst)
Tests if enumerated attribute(s) exists in the instances

Parameters:
inst - instances
Returns:
true if there is at least one; false if none
 o hasMissing
 public static final boolean hasMissing(Instances inst)
Tests if missing value(s) exists in the instances

Parameters:
inst - instances
Returns:
true if there is missing value(s); false if none
 o sum
 public static final double sum(int attr,
                                Instances inst)
Returns the sum of the instances values of an attribute

Parameters:
attr - an attribute
inst - instances
Returns:
the sum value
 o sqrSum
 public static final double sqrSum(int attr,
                                   Instances inst)
Returns the squared sum of the instances values of an attribute

Parameters:
attr - an attribute
inst - instances
Returns:
the squared sum value
 o stdDev
 public static final double stdDev(int attr,
                                   Instances inst)
Returns the standard deviation value of the instances values of an attribute

Parameters:
attr - an attribute
inst - instances
Returns:
the standard deviation value
 o absDev
 public static final double absDev(int attr,
                                   Instances inst)
Returns the absolute deviation value of the instances values of an attribute

Parameters:
attr - an attribute
inst - instances
Returns:
the absolute deviation value
 o variance
 public static final double variance(int attr,
                                     Instances inst)
Returns the variance value of the instances values of an attribute

Parameters:
attr - an attribute
inst - instances
Returns:
the variance value
 o roundDouble
 public static final long roundDouble(double value)
Rounds a double

Parameters:
value - the double value
Returns:
the double rounded
 o floorDouble
 public static final long floorDouble(double value)
Returns the largest (closest to positive infinity) long integer value that is not greater than the argument.

Parameters:
value - the double value
Returns:
the floor integer
 o doubleToStringF
 public static final String doubleToStringF(double value,
                                            int width,
                                            int afterDecimalPoint)
Rounds a double and converts it into a formatted right-justified String. It is like %f format in C language.

Parameters:
value - the double value
width - the width of the string
afterDecimalPoint - the number of digits after the decimal point
Returns:
the double as a formatted string
 o doubleToStringG
 public static final String doubleToStringG(double value,
                                            int width,
                                            int precision)
Rounds a double and converts it into a formatted right-justified String. If the double is not equal to zero and not in the range [10e-3,10e7] it is returned in scientific format. It is like %g format in C language.

Parameters:
value - the double value
width - the width of the string
precision - the number of valid digits
Returns:
the double as a formatted string
 o deleteTrailingZerosAndDot
 public static final StringBuffer deleteTrailingZerosAndDot(StringBuffer stringBuffer)
Deletes the trailing zeros and decimal point in a stringBuffer

Parameters:
stringBuffer - string buffer return string buffer with deleted trailing zeros and decimal point
 o smoothenValue
 public static final double smoothenValue(double p,
                                          double q,
                                          int n,
                                          int k)
Returns the smoothed values according to the smoothing formula (np+kq)/(n+k)

Parameters:
p - a double, normally is the prediction of the model at the current node
q - a double, normally is the prediction of the model at the up node
n - the number of instances at the up node
k - the smoothing constance, default =15
Returns:
the smoothed value
 o correlation
 public static final double correlation(double y1[],
                                        double y2[],
                                        int n)
Returns the correlation coefficient of two double vectors

Parameters:
y1 - double vector 1
y2 - double vector 2
n - the length of two double vectors
Returns:
the correlation coefficient
 o eqDouble
 public static final boolean eqDouble(double a,
                                      double b)
Tests if two double values are equal to each other

Parameters:
a - double 1
b - double 2
Returns:
true if equal; false if not equal
 o errorMsg
 public static final void errorMsg(String err)
Prints error message and exits

Parameters:
err - error message
 o separatorToString
 public static final String separatorToString()
Prints sepearating line

 o headToString
 public static final String headToString()
Prints the head lines of the output


All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home