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