kNearest Neighbors (CrossValidation Version)
kNearest Neighbors (kNN) is often used for machine learning. You can choose the value for topK
based on your experience, or using crossvalidation to optimize the hyperparameters. In our library, Leaveoneout crossvalidation for selecting optimal k is provided. Given a k value, we run the algorithm repeatedly using every vertex with a known label as the source vertex and predict its label. We assess the accuracy of the predictions for each value of k, and then repeat for different values of k in the given range. The goal is to find the value of k with highest predicting accuracy in the given range, for that dataset.
Specifications
tg_knn_cosine_cv(SET<STRING> v_type, SET<STRING> e_type, SET<STRING> re_type,
STRING weight, STRING label, INT min_k, INT max_k) RETURNS (INT)
Time complexity
This algorithm has a complexity of \(O(max\_k*\frac{E^2}{V})\), where \(E\) is the number of edges and \(V\) is the number of vertices.
Characteristic  Value 

Result 
A list of prediction accuracy for every k value in the given range, and the value of k with the highest predicting accuracy in the given range. The result is available in JSON format 
Input Parameters 

Result Size 
max_kmin_k+1 
Graph Types 
Undirected or directed edges, weighted edges 