public class DistanceIndex extends Object implements Comparable<DistanceIndex>
Modifier and Type | Class and Description |
---|---|
static class |
DistanceIndex.AndFilter
Returns true if and only if both underlying filters return true.
|
static class |
DistanceIndex.IdentityFilter
This filter returns true if the input index is equal to the reference
index.
|
static interface |
DistanceIndex.IndexFilter
This is an interface for functions that filter indices.
|
static class |
DistanceIndex.Labelfilter
Returns true if and only if the label of the input data point is the same
as the reference label.
|
static class |
DistanceIndex.NotFilter
Returns true if and only if the underlying filter returns false.
|
Modifier and Type | Field and Description |
---|---|
double |
distance |
int |
index |
static DistanceIndex.IndexFilter |
TRUE
This trivial IndexFilter returns always true.
|
Constructor and Description |
---|
DistanceIndex(int index,
double distance) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DistanceIndex o) |
boolean |
equals(Object obj) |
static TreeSet<DistanceIndex> |
getImposters(int j,
double[] distances,
int[] labels,
double margin)
Returns the indices of all data points from other classes, that are
closer to the reference data point than the target neighbor
with index j (including a margin of safety).
|
static TreeSet<DistanceIndex> |
getKNearest(int K,
double[] distances,
DistanceIndex.IndexFilter filter)
Returns the indices of the K data points with the lowest distance that
meet some filter criterion.
|
static TreeSet<DistanceIndex> |
getKNearest(int K,
int i,
double[] distances)
Returns the indices of the K nearest neighbors of the reference data
point sorted in ascending order with respect to their distance.
|
static TreeSet<DistanceIndex> |
getPointsInRadius(double radius,
double[] distances,
DistanceIndex.IndexFilter filter)
Returns the indices of all data points, which have a lower distance than
the given radius and meet some additional filter criterion.
|
static TreeSet<DistanceIndex> |
getTargetNeighborsTest(int K,
int label,
double[] distances,
int[] labels)
Returns the indices of the K nearest neighbors of the reference data
point that are from the same class as the reference data point.
|
static TreeSet<DistanceIndex> |
getTargetNeighborsTraining(int K,
int i,
double[] distances,
int[] labels)
Returns the indices of the K nearest neighbors of the reference data
point that are from the same class as the reference data point.
|
static TreeSet<DistanceIndex> |
getTargetNeighborsTraining(int K,
int i,
int label,
double[] distances,
int[] labels)
Returns the indices of the K nearest neighbors of the reference data
point that are from the same class as the reference data point.
|
int |
hashCode() |
public final int index
public final double distance
public static final DistanceIndex.IndexFilter TRUE
public int compareTo(DistanceIndex o)
compareTo
in interface Comparable<DistanceIndex>
public static TreeSet<DistanceIndex> getKNearest(int K, int i, double[] distances)
K
- some (positive) integer K.i
- the index of the reference data point.distances
- the distances of the reference data point to all other
data points, also including the self-distance. This
function will take care not to report the reference data
point itself as nearest neighbor.public static TreeSet<DistanceIndex> getTargetNeighborsTraining(int K, int i, double[] distances, int[] labels)
K
- some (positive) integer K.i
- the index of the reference data point.distances
- the distances of the reference data point to all other
data points, also including the self-distance. This
function will take care not to report the reference data
point itself as nearest neighbor.labels
- the indices of the classes of all data points.public static TreeSet<DistanceIndex> getTargetNeighborsTraining(int K, int i, int label, double[] distances, int[] labels)
K
- some (positive) integer K.i
- the index of the reference data point.label
- the supposed label of the reference data point.distances
- the distances of the reference data point to all other
data points, also including the self-distance. This
function will take care not to report the reference data
point itself as nearest neighbor.labels
- the indices of the classes of all data points.public static TreeSet<DistanceIndex> getTargetNeighborsTest(int K, int label, double[] distances, int[] labels)
K
- some (positive) integer K.label
- the label of the reference data point.distances
- the distances of the reference data point to all other
data points, not including the self-distance. This
function will take care not to report the reference data
point itself as nearest neighbor.labels
- the indices of the classes of all data points.public static TreeSet<DistanceIndex> getImposters(int j, double[] distances, int[] labels, double margin)
j
- the index of the target neighbor.distances
- the distances of the reference data point to all other
data points, also including the self-distance.labels
- the indices of the classes of all data points.margin
- a margin of safety.public static TreeSet<DistanceIndex> getKNearest(int K, double[] distances, DistanceIndex.IndexFilter filter)
K
- some (positive) integer K.distances
- the distances to all data points.filter
- some filter criterion.public static TreeSet<DistanceIndex> getPointsInRadius(double radius, double[] distances, DistanceIndex.IndexFilter filter)
radius
- some (non-negative) radius.distances
- the distances to all data points.filter
- some filter criterion.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/