KernelKnnCV_nmslib | R Documentation |
Approximate Kernel k nearest neighbors (cross-validated) using the nmslib library
KernelKnnCV_nmslib( data, y, k = 5, folds = 5, h = 1, weights_function = NULL, Levels = NULL, Index_Params = NULL, Time_Params = NULL, space = "l1", space_params = NULL, method = "hnsw", data_type = "DENSE_VECTOR", dtype = "FLOAT", index_filepath = NULL, print_progress = FALSE, num_threads = 1, seed_num = 1 )
data |
a numeric matrix |
y |
a numeric vector specifying the response variable (in classification the labels must be numeric from 1:Inf). The length of y must equal the rows of the data parameter |
k |
an integer. The number of neighbours to return |
folds |
the number of cross validation folds (must be greater than 1) |
h |
the bandwidth (applicable if the weights_function is not NULL, defaults to 1.0) |
weights_function |
there are various ways of specifying the kernel function. See the details section. |
Levels |
a numeric vector. In case of classification the unique levels of the response variable are necessary |
Index_Params |
a list of (optional) parameters to use in indexing (when creating the index) |
Time_Params |
a list of parameters to use in querying. Setting Time_Params to NULL will reset |
space |
a character string (optional). The metric space to create for this index. Page 31 of the manual (see references) explains all available inputs |
space_params |
a list of (optional) parameters for configuring the space. See the references manual for more details. |
method |
a character string specifying the index method to use |
data_type |
a character string. One of 'DENSE_UINT8_VECTOR', 'DENSE_VECTOR', 'OBJECT_AS_STRING' or 'SPARSE_VECTOR' |
dtype |
a character string. Either 'FLOAT' or 'INT' |
index_filepath |
a character string specifying the path to a file, where an existing index is saved |
print_progress |
a boolean (either TRUE or FALSE). Whether or not to display progress bar |
num_threads |
an integer. The number of threads to use |
seed_num |
a numeric value specifying the seed of the random number generator |
There are three possible ways to specify the weights function, 1st option : if the weights_function is NULL then a simple k-nearest-neighbor is performed. 2nd option : the weights_function is one of 'uniform', 'triangular', 'epanechnikov', 'biweight', 'triweight', 'tricube', 'gaussian', 'cosine', 'logistic', 'gaussianSimple', 'silverman', 'inverse', 'exponential'. The 2nd option can be extended by combining kernels from the existing ones (adding or multiplying). For instance, I can multiply the tricube with the gaussian kernel by giving 'tricube_gaussian_MULT' or I can add the previously mentioned kernels by giving 'tricube_gaussian_ADD'. 3rd option : a user defined kernel function
## Not run: x = matrix(runif(1000), nrow = 100, ncol = 10) y = runif(100) out = KernelKnnCV_nmslib(x, y, k = 5, folds = 5) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.