kernelMatrix             package:kernlab             R Documentation

_K_e_r_n_e_l _M_a_t_r_i_x _f_u_n_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     'kernelMatrix' calculates the kernel matrix K_{ij} = k(x_i,x_j) or
     K_{ij} = k(x_i,y_j).
      'kernelPol' computes the quadratic kernel expression  H = z_i z_j
     k(x_i,x_j), H = z_i k_j k(x_i,y_j).
      'kernelMult' calculates the kernel expansion f(x_i) = sum_{i=1}^m
     z k(x_i,x_j)

_U_s_a_g_e:

     ## S4 method for signature 'kernel':
     kernelMatrix(kernel, x, y = NULL)

     ## S4 method for signature 'kernel':
     kernelPol(kernel, x, y = NULL, z, k = NULL)

     ## S4 method for signature 'kernel':
     kernelMult(kernel, x, y = NULL, z, blocksize = 256)

_A_r_g_u_m_e_n_t_s:

  kernel: the kernel function to be used to calculate the kernel
          matrix. This has to be a function of class 'kernel'

       x: a data matrix to be used to calculate the kernel matrix

       y: second data matrix to calculate the kernel matrix

       z: a suitable vector or matrix

       k: a suitable vector or matrix

blocksize: the kernel expansion computations are done block wise to
          avoid storing the kernel matrix into memory. 'blocksize'
          defines the size of the computational blocks.

_D_e_t_a_i_l_s:

     Common functions used during kernel based computations.
      This 'kernel' parameter can be set to any function, of class
     kernel, which computes a dot product between two vector arguments.
     kernlab provides the most popular kernel functions which can be
     initialized by using the following functions:

        *  'rbfdot' Radial Basis kernel function

        *  'polydot' Polynomial kernel function

        *  'vanilladot' Linear kernel function

        *  'tanhdot' Hyperbolic tangent kernel function

        *  'laplacedot' Laplacian kernel function

        *  'besseldot' Bessel kernel function

        *  'anovadot' ANOVA RBF kernel function

_V_a_l_u_e:

     'kernelMatrix' returns a symmetric diagonal semi-definite matrix.
     'kernelPol' returns a matrix. 'kernelMult'{usually returns a
     one-column matrix}

_A_u_t_h_o_r(_s):

     Alexandros Karatzoglou 
      alexandros.karatzoglou@ci.tuwien.ac.at

_S_e_e _A_l_s_o:

     'rbfdot', 'polydot', 'tanhdot', 'vanilladot'

_E_x_a_m_p_l_e_s:

     ## use the spam data
     data(spam)
     dt <- as.matrix(spam[c(10:20,3000:3010),-58])

     ## initialize kernel function 
     rbf <- rbfdot(sigma = 0.05)
     rbf

     ## calculate kernel matrix
     kernelMatrix(rbf, dt)

     yt <- as.matrix(as.integer(spam[c(10:20,3000:3010),58]))
     yt[yt==2] <- -1

     ## calculate the quadratic kernel expression
     kernelPol(rbf, dt, ,yt)

     ## calculate the kernel expansion
     kernelMult(rbf, dt, ,yt)

