public abstract class NNClassificationModel 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 NNStrategy |
stgy
kNN strategy.
|
Constructor and Description |
---|
NNClassificationModel() |
Modifier and Type | Method and Description |
---|---|
protected LabeledVectorSet<Double,LabeledVector> |
buildLabeledDatasetOnListOfVectors(List<LabeledVector> neighborsFromPartitions) |
protected void |
copyParametersFrom(NNClassificationModel mdl)
Sets parameters from other model to this model.
|
boolean |
equals(Object obj) |
protected double |
getClassVoteForVector(NNStrategy stgy,
double distance) |
protected double |
getClassWithMaxVotes(Map<Double,Double> clsVotes) |
DistanceMeasure |
getDistanceMeasure() |
protected @NotNull TreeMap<Double,Set<Integer>> |
getDistances(Vector v,
LabeledVectorSet<Double,LabeledVector> trainingData)
Computes distances between given vector and each vector in training dataset.
|
protected @NotNull LabeledVector[] |
getKClosestVectors(LabeledVectorSet<Double,LabeledVector> trainingData,
TreeMap<Double,Set<Integer>> distanceIdxPairs)
Iterates along entries in distance map and fill the resulting k-element array.
|
int |
hashCode() |
protected void |
putDistanceIdxPair(Map<Double,Set<Integer>> distanceIdxPairs,
int i,
double distance) |
abstract <P> void |
saveModel(Exporter<KNNModelFormat,P> exporter,
P path)
Save model by the given path.
|
String |
toString() |
String |
toString(boolean pretty) |
NNClassificationModel |
withDistanceMeasure(DistanceMeasure distanceMeasure)
Set up parameter of the NN model.
|
NNClassificationModel |
withK(int k)
Set up parameter of the NN model.
|
NNClassificationModel |
withStrategy(NNStrategy stgy)
Set up parameter of the NN model.
|
protected int k
protected DistanceMeasure distanceMeasure
protected NNStrategy stgy
public NNClassificationModel withK(int k)
k
- Amount of nearest neighbors.public NNClassificationModel withStrategy(NNStrategy stgy)
stgy
- Strategy of calculations.public NNClassificationModel withDistanceMeasure(DistanceMeasure distanceMeasure)
distanceMeasure
- Distance measure.protected LabeledVectorSet<Double,LabeledVector> buildLabeledDatasetOnListOfVectors(List<LabeledVector> neighborsFromPartitions)
@NotNull protected @NotNull LabeledVector[] getKClosestVectors(LabeledVectorSet<Double,LabeledVector> trainingData, TreeMap<Double,Set<Integer>> distanceIdxPairs)
trainingData
- The training data.distanceIdxPairs
- The distance map.@NotNull protected @NotNull TreeMap<Double,Set<Integer>> getDistances(Vector v, LabeledVectorSet<Double,LabeledVector> trainingData)
v
- The given vector.trainingData
- The training dataset.protected void putDistanceIdxPair(Map<Double,Set<Integer>> distanceIdxPairs, int i, double distance)
protected double getClassVoteForVector(NNStrategy stgy, double distance)
public DistanceMeasure getDistanceMeasure()
public String toString(boolean pretty)
protected void copyParametersFrom(NNClassificationModel mdl)
mdl
- Model.public abstract <P> void saveModel(Exporter<KNNModelFormat,P> exporter, P path)
Exportable
saveModel
in interface Exportable<KNNModelFormat>
exporter
- Exporter.path
- Path to saved model.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.2 Release Date : February 6 2019