public class NearestNeighbour extends AlgorithmCompareTree
KD_Tree
tree.Modifier and Type | Field and Description |
---|---|
protected int |
ksize
The number of nearest neighbours to return
|
protected EvaluateMathDef |
mathCompare
Single value math comparisons - simple type
|
bs, kdTree
bestEval, evalMetric
Constructor and Description |
---|
NearestNeighbour(FunctionMetric thisEvalMetric,
EvaluateMathDef mathEval)
Create a new empty instance of NearestNeighbour.
|
NearestNeighbour(java.lang.String thisValueType,
java.util.HashMap<java.lang.String,?> thisConfig)
Create a new instance of NearestNeighbour.
|
Modifier and Type | Method and Description |
---|---|
ReplySet |
evaluate(MetricDataset cDataset)
Calculate the closest ksize data points from each pont to the other and use this to cluster.
|
protected void |
initialise()
Initialise the function values, setting the config parameters or other.
|
protected java.util.ArrayList<java.util.ArrayList<java.lang.String>> |
toClusters(java.util.HashMap<java.lang.String,java.util.ArrayList<KD_TreeNode>> nnGroups)
Convert the groups of nn nodes to clusters of node names.
|
getDatasetTree, resetValues, setDatasetTree, updateTree
getBestEvaluation
checkValueType, createFunction, createFunction, createFunction, getConfigParams, innerObject, isLegalNumber, setConfigParams, setEvaluator, setValueType
protected int ksize
protected EvaluateMathDef mathCompare
public NearestNeighbour(FunctionMetric thisEvalMetric, EvaluateMathDef mathEval) throws java.lang.Exception
thisEvalMetric
- the distance function.mathEval
- for simple math comparisons.java.lang.Exception
- any error.public NearestNeighbour(java.lang.String thisValueType, java.util.HashMap<java.lang.String,?> thisConfig) throws java.lang.Exception
thisValueType
- the type of object being evaluated. Can be null if set later or not used.thisConfig
- list of initialisation function-specific parameters.
Use AiHeuristicConst
.KNN
to store the number of nearest neighbours value,
.DIM
to store the number of dimensions value, .EVALUATOR
to store the
instance of the base mathCompare
evaluator.
java.lang.Exception
- any error.protected void initialise()
initialise
in class AlgorithmCompareTree
public ReplySet evaluate(MetricDataset cDataset) throws java.lang.Exception
evaluate
in interface FunctionDef
evaluate
in class Function
cDataset
- the dataset to cluster, as specified above. Add all points to the tree and
then return clusters for the new dataset points.datasets
list, as ArrayList
lists.
You can use ((Integer)ReplySet.getValue()).intValue()
to retrieve the cluster values.java.lang.Exception
- any error.protected java.util.ArrayList<java.util.ArrayList<java.lang.String>> toClusters(java.util.HashMap<java.lang.String,java.util.ArrayList<KD_TreeNode>> nnGroups)
nnGroups
- the groups of nn nodes to cluster.