rbf method

List<double> rbf(
  1. List<double> X
)

RBF kernel.

K(x, y) = exp(-gamma ||x-y||^2)

Implementation

List<double> rbf(List<double> X) {
  List<double> kernels =
      List.generate(supportVectors.length, (index) => index.toDouble());
  for (int i = 0; i < supportVectors.length; i++) {
    double kernel = 0.0;
    for (int j = 0; j < supportVectors[i].length; j++) {
      kernel += pow(supportVectors[i][j] - X[j], 2);
    }
    kernels[i] = exp(this.gamma * -1.0 * kernel);
  }
  return kernels;
}