public abstract class NNClassificationModel extends Object implements IgniteModel<Vector,Double>, Exportable<KNNModelFormat>, DeployableObject
Modifier and Type | Field and Description |
---|---|
protected DistanceMeasure |
distanceMeasure
Distance measure.
|
protected int |
k
Amount of nearest neighbors.
|
protected boolean |
weighted
kNN strategy.
|
Constructor and Description |
---|
NNClassificationModel() |
Modifier and Type | Method and Description |
---|---|
protected LabeledVectorSet<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(boolean weighted,
double distance) |
protected double |
getClassWithMaxVotes(Map<Double,Double> clsVotes) |
List<Object> |
getDependencies()
Returns dependencies of this object that can be object with class defined by client side and unknown for server.
|
DistanceMeasure |
getDistanceMeasure() |
protected @NotNull TreeMap<Double,Set<Integer>> |
getDistances(Vector v,
LabeledVectorSet<LabeledVector<Double>> trainingData)
Computes distances between given vector and each vector in training dataset.
|
protected @NotNull LabeledVector[] |
getKClosestVectors(LabeledVectorSet<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 |
withWeighted(boolean weighted)
Sets up
weighted parameter. |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
protected int k
protected DistanceMeasure distanceMeasure
protected boolean weighted
public NNClassificationModel withK(int k)
k
- Amount of nearest neighbors.public NNClassificationModel withWeighted(boolean weighted)
weighted
parameter.weighted
- Weighted or not.public NNClassificationModel withDistanceMeasure(DistanceMeasure distanceMeasure)
distanceMeasure
- Distance measure.protected LabeledVectorSet<LabeledVector> buildLabeledDatasetOnListOfVectors(List<LabeledVector> neighborsFromPartitions)
@NotNull protected @NotNull LabeledVector[] getKClosestVectors(LabeledVectorSet<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<LabeledVector<Double>> trainingData)
v
- The given vector.trainingData
- The training dataset.protected void putDistanceIdxPair(Map<Double,Set<Integer>> distanceIdxPairs, int i, double distance)
protected double getClassVoteForVector(boolean weighted, double distance)
public DistanceMeasure getDistanceMeasure()
public String toString(boolean pretty)
toString
in interface IgniteModel<Vector,Double>
pretty
- Use pretty mode.protected void copyParametersFrom(NNClassificationModel mdl)
mdl
- Model.public abstract <P> void saveModel(Exporter<KNNModelFormat,P> exporter, P path)
saveModel
in interface Exportable<KNNModelFormat>
exporter
- Exporter.path
- Path to saved model.public List<Object> getDependencies()
getDependencies
in interface DeployableObject
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024