public class KNNClassifierFactory<K,V>
extends java.lang.Object
KNNClassifier
objects, given
sets of RVFDatums, or Counters (dimensions are identified by the keys).Constructor and Description |
---|
KNNClassifierFactory(int k,
boolean weightedVotes,
boolean l2NormalizeVectors)
Creates a new factory that generates K-NN classifiers with the given k-value, and
if the votes are weighted by their similarity score, or unit value.
|
Modifier and Type | Method and Description |
---|---|
KNNClassifier<K,V> |
train(java.util.Collection<Counter<V>> vectors,
java.util.Map<V,K> labelMap)
Given a set of vectors, and a mapping from each vector to its class label,
generates the sets of instances used to perform classifications and returns
the corresponding K-NN classifier.
|
KNNClassifier<K,V> |
train(java.util.Collection<RVFDatum<K,V>> instances)
Given a set of labeled RVFDatums, treats each as an instance vector of that
label and adds it to the examples used for classification.
|
KNNClassifier<K,V> |
train(CollectionValuedMap<K,Counter<V>> vecBag)
Given a CollectionValued Map of vectors, treats outer key as label for each
set of inner vectors.
|
public KNNClassifierFactory(int k, boolean weightedVotes, boolean l2NormalizeVectors)
public KNNClassifier<K,V> train(java.util.Collection<RVFDatum<K,V>> instances)
public KNNClassifier<K,V> train(java.util.Collection<Counter<V>> vectors, java.util.Map<V,K> labelMap)
public KNNClassifier<K,V> train(CollectionValuedMap<K,Counter<V>> vecBag)