public class LMNNClassifier extends AbstractDissimilarityClassifier
Constructor and Description |
---|
LMNNClassifier(int[] trainingLabels) |
Modifier and Type | Method and Description |
---|---|
double |
calculateLMNNCostFunction(TreeSet<DistanceIndex> targetNeighbors,
double[] distances)
Calculates the LMNN cost function given the target neighbors of some data
point and its distances to the training data points.
|
double |
calculateLMNNCostFunctionTest(int label,
double[] distances)
Calculates the value of the LMNN cost function for the given data point,
assuming that it belongs to the class with the given label and that it
has the given distances to all training data points.
|
double |
calculateLMNNCostFunctionTraining(int i,
int label,
double[] distances)
Calculates the value of the LMNN cost function for the given data point,
assuming that it belongs to the class with the given label and that it
has the given distances to all training data points.
|
int |
classifyTest(double[] distances)
Returns the supposed class label for some data point, that is not
part of the training set, based on its distances to the training data
set.
|
int |
classifyTraining(int i,
double[] distances)
Returns the supposed class label for some data point in the
training set based on its distances to all training data points.
|
int |
getK()
Returns the number of considered nearest neighbors in the LMNN cost
function.
|
double |
getMargin()
Returns the margin of safety that is required by the LMNN cost function.
|
void |
setK(int K)
Sets the number of considered nearest neighbors in the LMNN cost
function.
|
void |
setMargin(double margin)
Sets the margin of safety that is required by the LMNN cost function.
|
calculateTestAccuracy, calculateTrainingAccuracy, getLabels, getTrainingLabels
public int getK()
public void setK(int K)
K
- the number of considered nearest neighbors in the LMNN cost
function.public double getMargin()
public void setMargin(double margin)
margin
- the margin of safety that is required by the LMNN cost
function.public int classifyTest(double[] distances)
DissimilarityClassifier
classifyTest
in interface DissimilarityClassifier
classifyTest
in class AbstractDissimilarityClassifier
distances
- the distances of the data point to all
training data points.public int classifyTraining(int i, double[] distances)
DissimilarityClassifier
classifyTraining
in interface DissimilarityClassifier
classifyTraining
in class AbstractDissimilarityClassifier
i
- the index of the data point that shall be classified in
the training set.distances
- the distances of the data point to all
training data points.public double calculateLMNNCostFunctionTraining(int i, int label, double[] distances)
i
- the index of the data point in the training set.label
- the supposed label of the data point.distances
- the distances of the data point to all training data
points, including the self-distance.public double calculateLMNNCostFunctionTest(int label, double[] distances)
label
- the supposed label of the data point.distances
- the distances of the data point to all training data
points, not including the self-distance.public double calculateLMNNCostFunction(TreeSet<DistanceIndex> targetNeighbors, double[] distances)
targetNeighbors
- the set of target neighbors.distances
- the distances d of the data point for which the
cost function shall be calculated to all training
data points.Copyright (C) 2016 Benjamin Paaßen, AG Theoretical Computer Science, Centre of Excellence Cognitive Interaction Technology (CITEC), University of Bielefeld, licensed under the AGPL v. 3: http://openresearch.cit-ec.de/projects/tcs . This documentation is licensed under the conditions of CC-BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/