K-Nearest Neighbors Regressor for regression tasks.
More...
#include <KNNRegressor.hpp>
K-Nearest Neighbors Regressor for regression tasks.
◆ KNNRegressor()
KNNRegressor::KNNRegressor |
( |
int |
k = 3 | ) |
|
|
explicit |
Constructs a KNNRegressor.
- Parameters
-
k | The number of neighbors to consider. |
◆ fit()
void KNNRegressor::fit |
( |
const std::vector< std::vector< double >> & |
X, |
|
|
const std::vector< double > & |
y |
|
) |
| |
Fits the regressor to the training data.
- Parameters
-
X | A vector of feature vectors (training data). |
y | A vector of target values (training labels). |
◆ predict()
std::vector< double > KNNRegressor::predict |
( |
const std::vector< std::vector< double >> & |
X | ) |
const |
Predicts target values for the given input data.
- Parameters
-
X | A vector of feature vectors (test data). |
- Returns
- A vector of predicted target values.
The documentation for this class was generated from the following file: