k-Nearest Neighbors (Batch Version)
This algorithm is a batch version of the k-Nearest Neighbors, Cosine Neighbor Similarity, single vertex. It makes a prediction for every vertex whose label is not known (i.e., the attribute for the known label is empty), based on its k nearest neighbors' labels.
Specifications
tg_knn_cosine_all( SET<STRING> v_type_set,  SET<STRING> e_type_set, SET<STRING> reverse_e_type_set,
  STRING weight_attribute, STRING label, INT top_k, BOOL print_results = TRUE,
  STRING file_path = "", STRING attr = "")
Parameters
| Parameter | Description | Default Value | 
|---|---|---|
  | 
The vertex types to calculate the distance for.  | 
(empty set of strings)  | 
  | 
The edge types to use  | 
(empty set of strings)  | 
  | 
The reverse edge types to use  | 
(empty set of strings)  | 
  | 
If not empty, use this edge attribute as the edge weight.  | 
(empty string)  | 
  | 
If not empty, read an existing label from this attribute.  | 
(empty string)  | 
  | 
The number of nearest neighbors to consider  | 
N/A  | 
  | 
If true, print output in JSON format to the standard output.  | 
True  | 
  | 
If not empty, write output to this file.  | 
(empty string)  | 
  | 
If not empty, store the predicted label to this vertex attribute.  | 
(empty string)  | 
Example
For the movie graph shown in the single vertex version, run knn_cosine_all, using topK=3. Then you get the following result:
  {
    "Source": [
      {
        "v_id": "Jing",
        "v_type": "Person",
        "attributes": {
          "name": "Jing",
          "known_label": "",
          "predicted_label": "",
          "@predicted_label": "a"
        }
      },
      {
        "v_id": "Neil",
        "v_type": "Person",
        "attributes": {
          "name": "Neil",
          "known_label": "",
          "predicted_label": "",
          "@predicted_label": "b"
        }
      },
      {
        "v_id": "Elena",
        "v_type": "Person",
        "attributes": {
          "name": "Elena",
          "known_label": "",
          "predicted_label": "",
          "@predicted_label": ""
        }
      }
    ]
  }
]