linear method

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

Linear kernel.

K(x, y) = <f(x), f(y)>

Implementation

List<double> linear(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 += supportVectors[i][j] * X[j];
    }
    kernels[i] = kernel;
  }
  return kernels;
}