InputType
- The input type for nearest neighbor.OutputType
- The output type for nearest neighbor.@PublicationReference(author="Wikipedia", title="k-nearest neighbor algorithm", type=WebPage, year=2008, url="http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm") public class NearestNeighborExhaustive<InputType,OutputType> extends AbstractNearestNeighbor<InputType,OutputType>
NearestNeighborExhaustive
class implements a simple evaluator
that looks up a given input object in a collection of input-output pair
examples and returns the output associated with the most similar input.
Similarity is judged using the given divergence function. This is an
implementation of the standard nearest-neighbor algorithm, which is a corner
case of the k-nearest neighbor algorithm, implemented in the
KNearestNeighbor
class.KNearestNeighbor
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
NearestNeighborExhaustive.Learner<InputType,OutputType>
The
NearestNeighborExhaustive.Learner class implements a batch learner for
the NearestNeighborExhaustive class. |
Modifier and Type | Field and Description |
---|---|
protected java.util.LinkedList<InputOutputPair<? extends InputType,OutputType>> |
data
The data that nearest-neighbor is performed over.
|
divergenceFunction
Constructor and Description |
---|
NearestNeighborExhaustive()
Creates a new instance of
NearestNeighborExhaustive . |
NearestNeighborExhaustive(DivergenceFunction<? super InputType,? super InputType> divergenceFunction)
Creates a new instance of
NearestNeighborExhaustive . |
NearestNeighborExhaustive(DivergenceFunction<? super InputType,? super InputType> divergenceFunction,
java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data)
Creates a new instance of
NearestNeighborExhaustive . |
Modifier and Type | Method and Description |
---|---|
NearestNeighborExhaustive<InputType,OutputType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
OutputType |
evaluate(InputType input)
Evaluates the object to do nearest-neighbor lookup for the given input.
|
java.util.LinkedList<InputOutputPair<? extends InputType,OutputType>> |
getData()
Gets the data from which this computes the nearest neighbors.
|
void |
setData(java.util.LinkedList<InputOutputPair<? extends InputType,OutputType>> data)
Sets the data that the object performs nearest-neighbor lookup on.
|
add
getDivergenceFunction, setDivergenceFunction
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDivergenceFunction
protected java.util.LinkedList<InputOutputPair<? extends InputType,OutputType>> data
public NearestNeighborExhaustive()
NearestNeighborExhaustive
.public NearestNeighborExhaustive(DivergenceFunction<? super InputType,? super InputType> divergenceFunction)
NearestNeighborExhaustive
.divergenceFunction
- The divergence function to use.public NearestNeighborExhaustive(DivergenceFunction<? super InputType,? super InputType> divergenceFunction, java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data)
NearestNeighborExhaustive
.divergenceFunction
- The divergence function to use.data
- The data to perform nearest neighbor over.public NearestNeighborExhaustive<InputType,OutputType> clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class DefaultDivergenceFunctionContainer<InputType,InputType>
public OutputType evaluate(InputType input)
input
- The input to evaluate.public java.util.LinkedList<InputOutputPair<? extends InputType,OutputType>> getData()
NearestNeighbor
public void setData(java.util.LinkedList<InputOutputPair<? extends InputType,OutputType>> data)
data
- The data to perform nearest-neighbor lookup on.