public final class M5
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
MODEL_LINEAR_REGRESSION |
static int |
MODEL_MODEL_TREE |
static int |
MODEL_REGRESSION_TREE |
Constructor and Description |
---|
M5(MyDataset data,
double prune_factor,
boolean unsmoothed,
int verbosity) |
M5(parseParameters paramFile)
Constructor by parameters file.
|
Modifier and Type | Method and Description |
---|---|
static double |
absDev(int attr,
MyDataset inst)
Returns the absolute deviation value of the itemsets values of an attribute
|
void |
buildClassifier(MyDataset inst)
Construct a model tree by training itemsets
|
static double |
correlation(double[] y1,
double[] y2,
int n)
Returns the correlation coefficient of two double vectors
|
static java.lang.StringBuffer |
deleteTrailingZerosAndDot(java.lang.StringBuffer stringBuffer)
Deletes the trailing zeros and decimal point in a stringBuffer
|
static java.lang.String |
doubleToStringF(double value,
int width,
int afterDecimalPoint)
Rounds a double and converts it into a formatted right-justified String.
|
static java.lang.String |
doubleToStringG(double value,
int width,
int precision)
Rounds a double and converts it into a formatted right-justified String.
|
static boolean |
eqDouble(double a,
double b)
Tests if two double values are equal to each other
|
static void |
errorMsg(java.lang.String err)
Prints error message and exits
|
static long |
floorDouble(double value)
Returns the largest (closest to positive infinity) long integer value that is not greater than the argument.
|
double |
getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure
|
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier.
|
double |
getPruningFactor()
Get the value of PruningFactor.
|
M5TreeNode |
getTree() |
boolean |
getUseUnsmoothed()
Get the value of UseUnsmoothed.
|
int |
getVerbosity()
Get the value of Verbosity.
|
static boolean |
hasEnumAttr(MyDataset inst)
Tests if enumerated attribute(s) exists in the itemsets
|
static boolean |
hasMissing(MyDataset inst)
Tests if missing value(s) exists in the itemsets
|
double |
measureNumLeaves()
return the number of leaves in the tree
|
double |
measureNumLinearModels()
return the number of linear models
|
double |
measureNumRules()
return the number of rules
|
static long |
roundDouble(double value)
Rounds a double
|
void |
setPruningFactor(double v)
Set the value of PruningFactor.
|
void |
setUseUnsmoothed(boolean v)
Set the value of UseUnsmoothed.
|
void |
setVerbosity(int v)
Set the value of Verbosity.
|
static double |
smoothenValue(double p,
double q,
int n,
int k)
Returns the smoothed values according to the smoothing formula (np+kq)/(n+k)
|
static double |
sqrSum(int attr,
MyDataset inst)
Returns the squared sum of the itemsets values of an attribute
|
static double |
stdDev(int attr,
MyDataset inst)
Returns the standard deviation value of the itemsets values of an attribute
|
static double |
sum(int attr,
MyDataset inst)
Returns the sum of the itemsets values of an attribute
|
java.lang.String |
toString()
Converts the output of the training process into a string
|
static double |
variance(int attr,
MyDataset inst)
Returns the variance value of the itemsets values of an attribute
|
public static final int MODEL_LINEAR_REGRESSION
public static final int MODEL_REGRESSION_TREE
public static final int MODEL_MODEL_TREE
public M5(parseParameters paramFile) throws java.lang.Exception
paramFile
- the parsed parameters filejava.lang.Exception
- if the class for the dataset is not numeric.public M5(MyDataset data, double prune_factor, boolean unsmoothed, int verbosity) throws java.lang.Exception
java.lang.Exception
public final void buildClassifier(MyDataset inst) throws java.lang.Exception
inst
- training itemsetsjava.lang.Exception
- if the classifier can't be builtpublic java.lang.String[] getOptions()
public final java.lang.String toString()
toString
in class java.lang.Object
public double measureNumLinearModels()
public double measureNumLeaves()
public double measureNumRules()
public double getMeasure(java.lang.String additionalMeasureName)
additionalMeasureName
- the name of the measure to query for its valuejava.lang.IllegalArgumentException
- if the named measure is not supportedpublic boolean getUseUnsmoothed()
public void setUseUnsmoothed(boolean v)
v
- Value to assign to UseUnsmoothed.public double getPruningFactor()
public void setPruningFactor(double v)
v
- Value to assign to PruningFactor.public M5TreeNode getTree()
public int getVerbosity()
public void setVerbosity(int v)
v
- Value to assign to Verbosity.public static final boolean hasEnumAttr(MyDataset inst)
inst
- itemsetspublic static final boolean hasMissing(MyDataset inst)
inst
- itemsetspublic static final double sum(int attr, MyDataset inst)
attr
- an attributeinst
- itemsetspublic static final double sqrSum(int attr, MyDataset inst)
attr
- an attributeinst
- itemsetspublic static final double stdDev(int attr, MyDataset inst)
attr
- an attributeinst
- itemsetspublic static final double absDev(int attr, MyDataset inst)
attr
- an attributeinst
- itemsetspublic static final double variance(int attr, MyDataset inst)
attr
- an attributeinst
- itemsetspublic static final long roundDouble(double value)
value
- the double valuepublic static final long floorDouble(double value)
value
- the double valuepublic static final java.lang.String doubleToStringF(double value, int width, int afterDecimalPoint)
value
- the double valuewidth
- the width of the stringafterDecimalPoint
- the number of digits after the decimal pointpublic static final java.lang.String doubleToStringG(double value, int width, int precision)
value
- the double valuewidth
- the width of the stringprecision
- the number of valid digitspublic static final java.lang.StringBuffer deleteTrailingZerosAndDot(java.lang.StringBuffer stringBuffer)
stringBuffer
- string bufferpublic static final double smoothenValue(double p, double q, int n, int k)
p
- a double, normally is the prediction of the model at the current nodeq
- a double, normally is the prediction of the model at the up noden
- the number of itemsets at the up nodek
- the smoothing constance, default =15public static final double correlation(double[] y1, double[] y2, int n)
y1
- double vector 1y2
- double vector 2n
- the length of two double vectorspublic static final boolean eqDouble(double a, double b)
a
- double 1b
- double 2public static final void errorMsg(java.lang.String err)
err
- error message