k-nearest neighbors
More...
#include <kNN.h>
|
| | kNN (int maxPoints, int dim, int k) |
| | Constructor. More...
|
| |
| int | dim () const |
| | Method for getting the number of dimensions. More...
|
| |
| int | numPoints () const |
| | Method for getting the current number of points. More...
|
| |
| mat | X () const |
| | Method for getting the current points. More...
|
| |
| vec | X (int i) const |
| | Method for getting current point number i (0 is the first) More...
|
| |
| vec | fX () const |
| | Method for getting the values of the current points. More...
|
| |
| double | fX (int i) const |
| | Method for getting the value of current point number i (0 is the first) More...
|
| |
| void | addPoint (const vec &point, double funVal) |
| | Method for adding a point with a known value. More...
|
| |
| void | addPoints (const mat &points, const vec &funVals) |
| | Method for adding multiple points with known values. More...
|
| |
| double | eval (const vec &point) const |
| | Method for evaluating the surrogate model at a point. More...
|
| |
| double | eval (const vec &point, const vec &dists) const |
| | Method for evaluating the surrogate at multiple points. More...
|
| |
| vec | evals (const mat &points) const |
| | Method for evaluating the surrogate at multiple points. More...
|
| |
| vec | evals (const mat &points, const mat &dists) const |
| | Method for evaluating the surrogate at multiple points. More...
|
| |
| vec | deriv (const vec &point) const |
| | Method for evaluating the kNN derivative at one point (not implemented) More...
|
| |
|
void | reset () |
| | Method for resetting the surrogate model.
|
| |
|
void | fit () |
| | Fits kNN (does nothing)
|
| |
k-nearest neighbors
The kNN method is a robust regression method that approximates the value at a given point as the average of the k closest points.
- Author
- David Eriksson, dme65.nosp@m.@cor.nosp@m.nell..nosp@m.edu
| sot::kNN::kNN |
( |
int |
maxPoints, |
|
|
int |
dim, |
|
|
int |
k |
|
) |
| |
|
inline |
Constructor.
- Parameters
-
| maxPoints | Capacity |
| dim | Number of dimensions |
| k | (number of neighbors used in averaging) |
| void sot::kNN::addPoint |
( |
const vec & |
point, |
|
|
double |
funVal |
|
) |
| |
|
inlinevirtual |
Method for adding a point with a known value.
- Parameters
-
| point | Point to be added |
| funVal | Function value at point |
- Exceptions
-
| std::logic_error | if one point is supplied or if capacity is exceeded |
Implements sot::Surrogate.
| void sot::kNN::addPoints |
( |
const mat & |
points, |
|
|
const vec & |
funVals |
|
) |
| |
|
inlinevirtual |
Method for adding multiple points with known values.
- Parameters
-
| points | Points to be added |
| funVals | Function values at the points |
- Exceptions
-
| std::logic_error | if one point is supplied or if capacity is exceeded |
Implements sot::Surrogate.
| vec sot::kNN::deriv |
( |
const vec & |
point | ) |
const |
|
inlinevirtual |
Method for evaluating the kNN derivative at one point (not implemented)
- Exceptions
-
| std::logic_error | Not available for kNN |
Implements sot::Surrogate.
| int sot::kNN::dim |
( |
| ) |
const |
|
inlinevirtual |
Method for getting the number of dimensions.
- Returns
- Number of dimensions
Implements sot::Surrogate.
| double sot::kNN::eval |
( |
const vec & |
point | ) |
const |
|
inlinevirtual |
Method for evaluating the surrogate model at a point.
- Parameters
-
| point | Point for which to evaluate the surrogate |
- Returns
- Value of the surrogate model at the point
Implements sot::Surrogate.
| double sot::kNN::eval |
( |
const vec & |
point, |
|
|
const vec & |
dists |
|
) |
| const |
|
inlinevirtual |
Method for evaluating the surrogate at multiple points.
- Parameters
-
| point | Points for which to evaluate the surrogate model |
| dists | Distances between the interpolation nodes and point |
- Returns
- Values of the surrogate model at the points
Implements sot::Surrogate.
| vec sot::kNN::evals |
( |
const mat & |
points | ) |
const |
|
inlinevirtual |
Method for evaluating the surrogate at multiple points.
- Parameters
-
| points | Points for which to evaluate the surrogate model |
- Returns
- Values of the surrogate model at the points
Implements sot::Surrogate.
| vec sot::kNN::evals |
( |
const mat & |
points, |
|
|
const mat & |
dists |
|
) |
| const |
|
inlinevirtual |
Method for evaluating the surrogate at multiple points.
- Parameters
-
| points | Points for which to evaluate the surrogate model |
| dists | Distances between the interpolation nodes and the points |
- Returns
- Values of the surrogate model at the points
Implements sot::Surrogate.
| vec sot::kNN::fX |
( |
| ) |
const |
|
inlinevirtual |
Method for getting the values of the current points.
- Returns
- Values of current points
Implements sot::Surrogate.
| double sot::kNN::fX |
( |
int |
i | ) |
const |
|
inlinevirtual |
Method for getting the value of current point number i (0 is the first)
- Returns
- Value of point number i
Implements sot::Surrogate.
| int sot::kNN::numPoints |
( |
| ) |
const |
|
inlinevirtual |
Method for getting the current number of points.
- Returns
- Current number of points
Implements sot::Surrogate.
| mat sot::kNN::X |
( |
| ) |
const |
|
inlinevirtual |
Method for getting the current points.
- Returns
- Current points
Implements sot::Surrogate.
| vec sot::kNN::X |
( |
int |
i | ) |
const |
|
inlinevirtual |
Method for getting current point number i (0 is the first)
- Returns
- Point number i
Implements sot::Surrogate.
k (number of neighbors used in averaging)
The documentation for this class was generated from the following file: