InputType
- Type of data upon which the KNearestNeighborExhaustive operates,
something like Vector, Double, or StringOutputType
- Output of the evaluator, like Matrix, Double, String@PublicationReference(author="Wikipedia", title="k-nearest neighbor algorithm", type=WebPage, year=2008, url="http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm") public class KNearestNeighborExhaustive<InputType,OutputType> extends AbstractKNearestNeighbor<InputType,OutputType>
Modifier and Type | Class and Description |
---|---|
static class |
KNearestNeighborExhaustive.Learner<InputType,OutputType>
This is a BatchLearner interface for creating a new KNearestNeighborExhaustive
from a given dataset, simply a pass-through to the constructor of
KNearestNeighborExhaustive
|
protected class |
KNearestNeighborExhaustive.Neighbor
Holds neighbor information used during the evaluate method and is put
into a priority queue.
|
divergenceFunction
DEFAULT_K
Constructor and Description |
---|
KNearestNeighborExhaustive()
Creates a new instance of
KNearestNeighborExhaustive . |
KNearestNeighborExhaustive(int k,
java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data,
DivergenceFunction<? super InputType,? super InputType> divergenceFunction,
Summarizer<? super OutputType,? extends OutputType> averager)
Creates a new instance of KNearestNeighborExhaustive
|
Modifier and Type | Method and Description |
---|---|
KNearestNeighborExhaustive<InputType,OutputType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
protected java.util.Collection<OutputType> |
computeNeighborhood(InputType key)
Computes the neighbors to the input key.
|
java.util.Collection<InputOutputPair<? extends InputType,OutputType>> |
getData()
Gets the data from which this computes the nearest neighbors.
|
void |
setData(java.util.Collection<InputOutputPair<? extends InputType,OutputType>> data)
Setter for data
|
evaluate, getAverager, getK, setAverager, setK
add
getDivergenceFunction, setDivergenceFunction
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
add, getDivergenceFunction
public KNearestNeighborExhaustive()
KNearestNeighborExhaustive
.public KNearestNeighborExhaustive(int k, java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data, DivergenceFunction<? super InputType,? super InputType> divergenceFunction, Summarizer<? super OutputType,? extends OutputType> averager)
k
- Number of neighbors to consider, must be greater than zerodata
- Underlying data for the classifierdivergenceFunction
- Divergence function that determines how "far" two objects are apartaverager
- Creates a single object from a collection of datapublic KNearestNeighborExhaustive<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 AbstractKNearestNeighbor<InputType,OutputType>
protected java.util.Collection<OutputType> computeNeighborhood(InputType key)
AbstractKNearestNeighbor
computeNeighborhood
in class AbstractKNearestNeighbor<InputType,OutputType>
key
- Input to find the nearest neighbors of.public java.util.Collection<InputOutputPair<? extends InputType,OutputType>> getData()
NearestNeighbor
public void setData(java.util.Collection<InputOutputPair<? extends InputType,OutputType>> data)
data
- Underlying data for the classifier