@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()
KnnResultsgetK in interface KnnResultspublic int getMinNeighborCount()
KnnResultsgetMinNeighborCount in interface KnnResultspublic int getMaxNeighborCount()
KnnResultsgetMaxNeighborCount in interface KnnResultspublic int getAllNeighborCount()
KnnResultsgetAllNeighborCount in interface KnnResultspublic int getQueryCount()
NnResultsgetQueryCount in interface NnResultspublic int[] getNeighbors(int queryIndex)
KnnResultsNnResults.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 KnnResultsqueryIndex - Indexpublic double[] getDissimilarities(int queryIndex)
KnnResultsNnResults.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 KnnResultsqueryIndex - Index of querypublic int copyNeighborsTo(int queryIndex,
int[] neighbors,
double[] dissimilarities)
KnnResultscopyNeighborsTo in interface KnnResultsqueryIndex - Query indexneighbors - Array to copy neighbor indicesdissimilarities - Array to copy dissimilaritiespublic int getMinNeighborIndex()
NnResultsgetMinNeighborIndex in interface NnResultspublic int getMaxNeighborIndex()
NnResultsgetMaxNeighborIndex in interface NnResultspublic double getMinDissimilarity()
NnResultsgetMinDissimilarity in interface NnResultspublic double getMaxDissimilarity()
NnResultsgetMaxDissimilarity in interface NnResultspublic int getMostSimilarNeighbor(int queryIndex)
NnResultsgetMostSimilarNeighbor in interface NnResultsqueryIndex - Index of querypublic double getMostSimilarDissimilarity(int queryIndex)
NnResultsgetMostSimilarDissimilarity in interface NnResultsqueryIndex - Index of querypublic int[] getNthNeighborIdsOfAll(int neighborIndex)
KnnResultsn-th neighbor indices for all queries.getNthNeighborIdsOfAll in interface KnnResultsneighborIndex - 0-based neigbbor indexpublic double getNeighborDissimilaritiesMissingValue()
KnnResultsKnnResults.getNthNeighborDissimilaritiesOfAll(int).getNeighborDissimilaritiesMissingValue in interface KnnResultspublic double[] getNthNeighborDissimilaritiesOfAll(int neighborIndex)
KnnResultsn-th neighbor dissimilarities for all queries.getNthNeighborDissimilaritiesOfAll in interface KnnResultsneighborIndex - 0-based neigbbor indexKnnResults.getNeighborDissimilaritiesMissingValue() when
given neighbor is not presentpublic int[] getNeighborCountsOfAll()
KnnResultsgetNeighborCountsOfAll in interface KnnResultspublic int getNeighbor(int queryIndex,
int neighborIndex)
KnnResultsgetNeighbor in interface KnnResultsqueryIndex - QueryneighborIndex - Neighbor indexpublic double getDissimilarity(int queryIndex,
int neighborIndex)
KnnResultsgetDissimilarity in interface KnnResultsqueryIndex - QueryneighborIndex - Neighbor indexKnnResults.getNeighborDissimilaritiesMissingValue()