public class KNNClassificationModel<K,V> extends Object implements Model<Vector,Double>, Exportable<KNNModelFormat>
| Modifier and Type | Field and Description |
|---|---|
protected DistanceMeasure |
distanceMeasure
Distance measure.
|
protected int |
k
Amount of nearest neighbors.
|
protected KNNStrategy |
stgy
kNN strategy.
|
| Constructor and Description |
|---|
KNNClassificationModel(Dataset<EmptyContext,LabeledDataset<Double,LabeledVector>> dataset)
Builds the model via prepared dataset.
|
| Modifier and Type | Method and Description |
|---|---|
Double |
apply(Vector v) |
boolean |
equals(Object obj) |
protected List<LabeledVector> |
findKNearestNeighbors(Vector v)
The main idea is calculation all distance pairs between given vector and all vectors in training set, sorting
them and finding k vectors with min distance with the given vector.
|
int |
hashCode() |
<P> void |
saveModel(Exporter<KNNModelFormat,P> exporter,
P path)
Save model by the given path.
|
KNNClassificationModel<K,V> |
withDistanceMeasure(DistanceMeasure distanceMeasure)
Set up parameter of the kNN model.
|
KNNClassificationModel<K,V> |
withK(int k)
Set up parameter of the kNN model.
|
KNNClassificationModel<K,V> |
withStrategy(KNNStrategy stgy)
Set up parameter of the kNN model.
|
protected int k
protected DistanceMeasure distanceMeasure
protected KNNStrategy stgy
public KNNClassificationModel(Dataset<EmptyContext,LabeledDataset<Double,LabeledVector>> dataset)
dataset - Specially prepared object to run algorithm over it.public <P> void saveModel(Exporter<KNNModelFormat,P> exporter, P path)
ExportablesaveModel in interface Exportable<KNNModelFormat>exporter - Exporter.path - Path to saved model.public KNNClassificationModel<K,V> withK(int k)
k - Amount of nearest neighbors.public KNNClassificationModel<K,V> withStrategy(KNNStrategy stgy)
stgy - Strategy of calculations.public KNNClassificationModel<K,V> withDistanceMeasure(DistanceMeasure distanceMeasure)
distanceMeasure - Distance measure.protected List<LabeledVector> findKNearestNeighbors(Vector v)
v - The given vector.
Follow @ApacheIgnite
Ignite Fabric : ver. 2.6.0 Release Date : July 10 2018