public class VarGain extends Function
The algorithm is different to InformationGain
by the way that it evaluates the
dataset and also how the data is presented. Each list in the dataset should be a set of
distinct values for a variable. The tabular dataset is again created by adding columns of
type MetricValue
to a MetricDataset
and passing this as the parameter.
For example:
dataPoints = new ArrayList();
dataPoints.add("a");
dataPoints.add("b");
dataPoints.add("d");
metricValue = MetricValue.toValue("dp1", valueType, dataPoints);
allDatasets.add(metricValue);
dataPoints = new ArrayList();
dataPoints.add("b");
dataPoints.add("d");
dataPoints.add("e");
metricValue = MetricValue.toValue("dp2", valueType, dataPoints);
allDatasets.add(metricValue);
dataPoints = new ArrayList();
dataPoints.add("a");
dataPoints.add("c");
dataPoints.add("e");
metricValue = MetricValue.toValue("dp3", valueType, dataPoints);
allDatasets.add(metricValue);
...
//repeat for the other data columns
...
MetricDataset evalDataset = MetricDataset.toDataset("ds1", valueType, allDatasets);
//initialise and run the algorithm
VarGain varGain = new VarGain(valueType);
double result = (Double)varGain.evaluate(evalDataset).getValue();
config, mathCompare, valueType
Constructor and Description |
---|
VarGain(java.lang.String thisValueType)
Create a new instance of VarGain.
|
Modifier and Type | Method and Description |
---|---|
ReplySet |
evaluate(MetricDataset dataset)
Evaluate a cohesive value, similar to an entropy value, for the combined variable
list and count.
|
double |
getCohesion()
Get the cohesion value.
|
double |
getMean()
Get the mean value.
|
double |
getVariance()
Get the variance value.
|
protected void |
initialise()
Initialise the function values, setting the config parameters or other.
|
java.util.ArrayList<java.lang.String> |
varsWithCount(int freq)
Return a list of all variable names with the specified count.
|
checkValueType, createFunction, createFunction, createFunction, getConfigParams, innerObject, isLegalNumber, setConfigParams, setEvaluator, setValueType
public VarGain(java.lang.String thisValueType) throws java.lang.Exception
thisValueType
- the type of object being evaluated. Can be null if set later or not used.java.lang.Exception
- any error.protected void initialise()
initialise
in class Function
public ReplySet evaluate(MetricDataset dataset) throws java.lang.Exception
evaluate
in interface FunctionDef
evaluate
in class Function
dataset
- tabular list of keyword values. This should store a list of MetricValue
entities
that each store a set of values for any column or variables that are present.java.lang.Exception
- any error.public java.util.ArrayList<java.lang.String> varsWithCount(int freq)
freq
- the frequency count to check for.public double getMean()
public double getVariance()
public double getCohesion()