Cpp ML Library  1.0.0
A library of Machine Learning Algorithmns seen from the Udemy course Machine Learning A to Z.
Public Member Functions | List of all members
KNNRegressor Class Reference

K-Nearest Neighbors Regressor for regression tasks. More...

#include <KNNRegressor.hpp>

Public Member Functions

 KNNRegressor (int k=3)
 Constructs a KNNRegressor. More...
 
 ~KNNRegressor ()
 Destructor for KNNRegressor.
 
void fit (const std::vector< std::vector< double >> &X, const std::vector< double > &y)
 Fits the regressor to the training data. More...
 
std::vector< double > predict (const std::vector< std::vector< double >> &X) const
 Predicts target values for the given input data. More...
 

Detailed Description

K-Nearest Neighbors Regressor for regression tasks.

Constructor & Destructor Documentation

◆ KNNRegressor()

KNNRegressor::KNNRegressor ( int  k = 3)
explicit

Constructs a KNNRegressor.

Parameters
kThe number of neighbors to consider.

Member Function Documentation

◆ fit()

void KNNRegressor::fit ( const std::vector< std::vector< double >> &  X,
const std::vector< double > &  y 
)

Fits the regressor to the training data.

Parameters
XA vector of feature vectors (training data).
yA 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
XA vector of feature vectors (test data).
Returns
A vector of predicted target values.

The documentation for this class was generated from the following file: