Typical workflow for k-NN Regression - 5.2 English - 68552

AOCL API Guide (68552)

Document ID
68552
Release Date
2025-12-29
Version
5.2 English

The standard way of computing the k-nearest neighbors for regression using AOCL-DA is as follows.

  1. Initialize a aoclda.nearest_neighbors.knn_regressor() object with options set in the class constructor.

  2. Fit the k-NN for your training data set using aoclda.nearest_neighbors.knn_regressor.fit().

  3. Compute the indices of the nearest neighbors and optionally the corresponding distances using aoclda.nearest_neighbors.knn_regressor.kneighbors().

  4. If only the target values of the test data are required, use aoclda.nearest_neighbors.knn_regressor.predict(). Note that a previous call to aoclda.nearest_neighbors.knn_regressor.kneighbors() is not required.

  1. Initialize a da_handle with da_handle_type da_handle_nn.

  2. Pass data to the handle using da_nn_regressor_set_training_data_?.

  3. Set the number of neighbors required and the metric or weights used in k-NN using da_options_set_? (see below).

  4. Compute the indices of the nearest neighbors and optionally the corresponding distances using da_nn_kneighbors_?.

  5. If only the target values of the test data are required, use da_nn_regressor_predict_?.