@Beta public final class IndexedKnnResultsImpl extends Object implements KnnResults, Serializable
KnnResults
for variabl neighbor count.
Note that query and target IDs might refer to the same or different sets. If they refer to the same set the nearest neighbor list does not contain self ID.
Constructor and Description |
---|
IndexedKnnResultsImpl(List<int[]> targets,
List<double[]> dissimilarities)
Construct.
|
Modifier and Type | Method and Description |
---|---|
int |
copyNeighborsTo(int queryIndex,
int[] neighbors,
double[] dissimilarities)
Copy neighbor data to an allocated array.
|
int |
getAllNeighborCount()
All stored neighbor count.
|
double[] |
getDissimilarities(int queryIndex)
Dissimilarity.
|
double |
getDissimilarity(int queryIndex,
int neighborIndex)
Dissimilarity of a single neighbor.
|
int |
getK()
Value of k.
|
double |
getMaxDissimilarity()
Upper bound of dissimilarity values.
|
int |
getMaxNeighborCount()
Maximal neighbor count represented.
|
int |
getMaxNeighborIndex()
Upper bound of neighbor index values.
|
double |
getMinDissimilarity()
Lower bound of dissimilarity values.
|
int |
getMinNeighborCount()
Minimal neighbor count represented.
|
int |
getMinNeighborIndex()
Lower bound of neighbor index values.
|
double |
getMostSimilarDissimilarity(int queryIndex)
Dissimilarity of the most similar neighbor.
|
int |
getMostSimilarNeighbor(int queryIndex)
Index of most similar neighbor.
|
int |
getNeighbor(int queryIndex,
int neighborIndex)
Index of a single neighbor.
|
int[] |
getNeighborCountsOfAll()
Neighbor count of all queries.
|
double |
getNeighborDissimilaritiesMissingValue()
Missing value for results of
KnnResults.getNthNeighborDissimilaritiesOfAll(int) . |
int[] |
getNeighbors(int queryIndex)
ID of the nearest neighbors of query.
|
double[] |
getNthNeighborDissimilaritiesOfAll(int neighborIndex)
Get
n -th neighbor dissimilarities for all queries. |
int[] |
getNthNeighborIdsOfAll(int neighborIndex)
Get
n -th neighbor indices for all queries. |
int |
getQueryCount()
Number of queries stored.
|
String |
toString() |
public IndexedKnnResultsImpl(List<int[]> targets, List<double[]> dissimilarities)
targets
- nearest neighborsdissimilarities
- DissimilaritiesIllegalArgumentException
- when array sizes mismatch or dissimilarities array contains NaN or INF valuepublic int getK()
KnnResults
getK
in interface KnnResults
public int getMinNeighborCount()
KnnResults
getMinNeighborCount
in interface KnnResults
public int getMaxNeighborCount()
KnnResults
getMaxNeighborCount
in interface KnnResults
public int getAllNeighborCount()
KnnResults
getAllNeighborCount
in interface KnnResults
public int getQueryCount()
NnResults
getQueryCount
in interface NnResults
public int[] getNeighbors(int queryIndex)
KnnResults
NnResults.getMinNeighborIndex()
and NnResults.getMaxNeighborIndex()
are valid for all neighbors.
First element of the returned list is the same as NnResults.getMostSimilarNeighbor(int)
. The length of the list
might vary from query to query, but is non-empty and no longer than the value of KnnResults.getK()
. The length of
the list is the same as the length of KnnResults.getDissimilarities(int)
.
getNeighbors
in interface KnnResults
queryIndex
- Indexpublic double[] getDissimilarities(int queryIndex)
KnnResults
NnResults.getMinDissimilarity()
and NnResults.getMaxDissimilarity()
are valid for all neighbors.
First element of the returned list is the same as NnResults.getMostSimilarDissimilarity(int)
. The length of the
list might vary from query to query, but is non-empty and no longer than the value of KnnResults.getK()
. The length
of the list is the same as the length of KnnResults.getNeighbors(int)
.
getDissimilarities
in interface KnnResults
queryIndex
- Index of querypublic int copyNeighborsTo(int queryIndex, int[] neighbors, double[] dissimilarities)
KnnResults
copyNeighborsTo
in interface KnnResults
queryIndex
- Query indexneighbors
- Array to copy neighbor indicesdissimilarities
- Array to copy dissimilaritiespublic int getMinNeighborIndex()
NnResults
getMinNeighborIndex
in interface NnResults
public int getMaxNeighborIndex()
NnResults
getMaxNeighborIndex
in interface NnResults
public double getMinDissimilarity()
NnResults
getMinDissimilarity
in interface NnResults
public double getMaxDissimilarity()
NnResults
getMaxDissimilarity
in interface NnResults
public int getMostSimilarNeighbor(int queryIndex)
NnResults
getMostSimilarNeighbor
in interface NnResults
queryIndex
- Index of querypublic double getMostSimilarDissimilarity(int queryIndex)
NnResults
getMostSimilarDissimilarity
in interface NnResults
queryIndex
- Index of querypublic int[] getNthNeighborIdsOfAll(int neighborIndex)
KnnResults
n
-th neighbor indices for all queries.getNthNeighborIdsOfAll
in interface KnnResults
neighborIndex
- 0-based neigbbor indexpublic double getNeighborDissimilaritiesMissingValue()
KnnResults
KnnResults.getNthNeighborDissimilaritiesOfAll(int)
.getNeighborDissimilaritiesMissingValue
in interface KnnResults
public double[] getNthNeighborDissimilaritiesOfAll(int neighborIndex)
KnnResults
n
-th neighbor dissimilarities for all queries.getNthNeighborDissimilaritiesOfAll
in interface KnnResults
neighborIndex
- 0-based neigbbor indexKnnResults.getNeighborDissimilaritiesMissingValue()
when
given neighbor is not presentpublic int[] getNeighborCountsOfAll()
KnnResults
getNeighborCountsOfAll
in interface KnnResults
public int getNeighbor(int queryIndex, int neighborIndex)
KnnResults
getNeighbor
in interface KnnResults
queryIndex
- QueryneighborIndex
- Neighbor indexpublic double getDissimilarity(int queryIndex, int neighborIndex)
KnnResults
getDissimilarity
in interface KnnResults
queryIndex
- QueryneighborIndex
- Neighbor indexKnnResults.getNeighborDissimilaritiesMissingValue()