gov.sandia.cognition.learning.algorithm.nearest
Interface KNearestNeighbor<InputType,OutputType>

Type Parameters:
InputType - Type of data upon which the KNearestNeighbor operates, something like Vector, Double, or String
OutputType - Output of the evaluator, like Matrix, Double, String
All Superinterfaces:
Cloneable, CloneableSerializable, Evaluator<InputType,OutputType>, NearestNeighbor<InputType,OutputType>, Serializable
All Known Implementing Classes:
AbstractKNearestNeighbor, KNearestNeighborExhaustive, KNearestNeighborExhaustive.Learner, KNearestNeighborKDTree, KNearestNeighborKDTree.Learner

@PublicationReference(author="Wikipedia",
                      title="k-nearest neighbor algorithm",
                      type=WebPage,
                      year=2008,
                      url="http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm")
public interface KNearestNeighbor<InputType,OutputType>
extends NearestNeighbor<InputType,OutputType>

A generic k-nearest-neighbor classifier. This classifier simply looks at the nearest "k" neighbors to a point and returns the average of them. Thus, the learner is trivial, but the lookups (evaluations) are expensive. For example, with k=1, then k-nearest-neighbor simply returns the nearest data point to a given input. And so forth.

Since:
3.0
Author:
Kevin R. Dixon

Field Summary
static int DEFAULT_K
          The default value for k is 1.
 
Method Summary
 Summarizer<? super OutputType,? extends OutputType> getAverager()
          Getter for averager.
 int getK()
          Getter for k
 void setAverager(Summarizer<? super OutputType,? extends OutputType> averager)
          Setter for averager.
 void setK(int k)
          Setter for k
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.nearest.NearestNeighbor
add, getData, getDivergenceFunction
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

DEFAULT_K

static final int DEFAULT_K
The default value for k is 1.

See Also:
Constant Field Values
Method Detail

getAverager

Summarizer<? super OutputType,? extends OutputType> getAverager()
Getter for averager.

Returns:
Creates a single object from a collection of data

setAverager

void setAverager(Summarizer<? super OutputType,? extends OutputType> averager)
Setter for averager.

Parameters:
averager - Creates a single object from a collection of data

getK

int getK()
Getter for k

Returns:
Number of neighbors to consider, must be greater than zero

setK

void setK(int k)
Setter for k

Parameters:
k - Number of neighbors to consider, must be greater than zero