public class RPUtils extends Object
Constructor and Description |
---|
RPUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
buildTree(RPTree tree,
RPNode from,
RPHyperPlanes planes,
INDArray X,
int maxSize,
int depth,
String similarityFunction)
Initialize the tree given the input parameters
|
static double |
computeDistance(String function,
INDArray x,
INDArray y)
Compute the distance between 2 vectors
given a function name.
|
static double |
computeDistance(String function,
INDArray x,
INDArray y,
INDArray result)
/**
Compute the distance between 2 vectors
given a function name.
|
static INDArray |
computeDistanceMulti(String function,
INDArray x,
INDArray y,
INDArray result)
Compute the distance between 2 vectors
given a function name.
|
static INDArray |
getAllCandidates(INDArray x,
List<RPTree> trees,
String similarityFunction)
Get the search candidates as indices given the input
and similarity function
|
static List<Integer> |
getCandidates(INDArray x,
List<RPTree> roots,
String similarityFunction)
Get the search candidates as indices given the input
and similarity function
|
static <T extends DifferentialFunction> |
getOp(String name,
INDArray x,
INDArray y,
INDArray result) |
static RPNode |
query(RPNode from,
RPHyperPlanes planes,
INDArray x,
String similarityFunction)
Query the tree starting from the given node
using the given hyper plane and similarity function
|
static INDArray |
queryAll(INDArray toQuery,
INDArray X,
List<RPTree> trees,
int n,
String similarityFunction)
Query all trees using the given input and data
|
static List<Pair<Double,Integer>> |
queryAllWithDistances(INDArray toQuery,
INDArray X,
List<RPTree> trees,
int n,
String similarityFunction)
Query all trees using the given input and data
|
static void |
scanForLeaves(List<RPNode> nodes,
RPNode current)
Scan for leaves accumulating
the nodes in the passed in list
|
static void |
scanForLeaves(List<RPNode> nodes,
RPTree scan)
Scan for leaves accumulating
the nodes in the passed in list
|
static void |
slimNode(RPNode node)
Prune indices from the given node
when it's a leaf
|
static List<Pair<Double,Integer>> |
sortCandidates(INDArray x,
INDArray X,
List<Integer> candidates,
String similarityFunction)
Get the sorted distances given the
query vector, input data, given the list of possible search candidates
|
public static <T extends DifferentialFunction> DifferentialFunction getOp(String name, INDArray x, INDArray y, INDArray result)
public static List<Pair<Double,Integer>> queryAllWithDistances(INDArray toQuery, INDArray X, List<RPTree> trees, int n, String similarityFunction)
toQuery
- the query vectorX
- the input data to querytrees
- the trees to queryn
- the number of results to search forsimilarityFunction
- the similarity function to usepublic static INDArray queryAll(INDArray toQuery, INDArray X, List<RPTree> trees, int n, String similarityFunction)
toQuery
- the query vectorX
- the input data to querytrees
- the trees to queryn
- the number of results to search forsimilarityFunction
- the similarity function to usepublic static List<Pair<Double,Integer>> sortCandidates(INDArray x, INDArray X, List<Integer> candidates, String similarityFunction)
x
- the query vectorX
- the input data to usecandidates
- the possible search candidatessimilarityFunction
- the similarity function to usepublic static INDArray getAllCandidates(INDArray x, List<RPTree> trees, String similarityFunction)
x
- the input data to search withtrees
- the trees to searchsimilarityFunction
- the function to use for similaritypublic static List<Integer> getCandidates(INDArray x, List<RPTree> roots, String similarityFunction)
x
- the input data to search withroots
- the trees to searchsimilarityFunction
- the function to use for similaritypublic static RPNode query(RPNode from, RPHyperPlanes planes, INDArray x, String similarityFunction)
from
- the node to start fromplanes
- the hyper plane to queryx
- the input datasimilarityFunction
- the similarity function to usepublic static INDArray computeDistanceMulti(String function, INDArray x, INDArray y, INDArray result)
function
- the function to use (default euclidean distance)x
- the first vectory
- the second vectorpublic static double computeDistance(String function, INDArray x, INDArray y, INDArray result)
function
- the function to use (default euclidean distance)x
- the first vectory
- the second vectorpublic static double computeDistance(String function, INDArray x, INDArray y)
function
- the function to use (default euclidean distance)x
- the first vectory
- the second vectorpublic static void buildTree(RPTree tree, RPNode from, RPHyperPlanes planes, INDArray X, int maxSize, int depth, String similarityFunction)
tree
- the tree to initializefrom
- the starting nodeplanes
- the hyper planes to use (vector space for similarity)X
- the input datamaxSize
- the max number of indices on a given leaf nodedepth
- the current depth of the treesimilarityFunction
- the similarity function to usepublic static void scanForLeaves(List<RPNode> nodes, RPTree scan)
nodes
- the nodes so farscan
- the tree to scanpublic static void scanForLeaves(List<RPNode> nodes, RPNode current)
nodes
- the nodes so farpublic static void slimNode(RPNode node)
node
- the node to pruneCopyright © 2020. All rights reserved.