Package PyML :: Package containers :: Module ker
[frames] | no frames]

Module ker

source code

Classes
  Kernel
base class for kernel objects
  Linear
A Linear kernel (dot product)
  Cosine
A Cosine kernel (dot product) Construction: k = Cosine()
  Polynomial
A Polynomial kernel K(x,y) = (x dot y + additiveConst) ** degree
  Gaussian
A Gaussian (RBF) kernel K(x,y) = exp( - gamma * ||x - y||**2
Functions
 
attachKernel(data, kernel='linear', **args) source code
 
kernel2file(data, fileName, **args)
compute a kernel matrix and save it to a file in tab delimited format
source code
 
averageEntry(fileName, ignoreDiagonal=True, delim=None) source code
 
PositionalKmerDispatcher(**args)
A string kernel inspired by Raetsch et al's weighted degree kernel
source code
 
combineKernels(ker1file, ker2file, kerOutFile, operation='add', **args)
combine two kernels by either adding or multiplying them.
source code
 
sortKernel(kernelInFile, kernelOutFile, format='gist', **args)
sort a kernel matrix according to its pattern ID
source code
 
commonKernel(kernelFile1, kernelFile2, kernelOutFileName1, kernelOutFileName2) source code
 
expandKernel(inKernelFile, referenceKernelFile, outKernelFile, **args)
Given a kernel matrix that might have missing entries, fill those as 0 on the basis of the patterns in a reference kernel (it is checked that the reference kernel is sorted).
source code
 
showKernel(dataOrMatrix, fileName=None, useLabels=True, **args) source code
 
sortKernel2(kernelInFile, kernelOutFile, ids, format='gist', **args)
sort a kernel matrix according to the given list of ids
source code
Variables
  normalizationMethods = ['none', 'cosine', 'tanimoto', 'dices']
Function Details

kernel2file(data, fileName, **args)

source code 
compute a kernel matrix and save it to a file in tab delimited format
Parameters:
  • data - a dataset
  • fileName - file name to save the kernel
  • format - the format in which to save the kernel: pyml or gist formats [default: 'gist'] gist format has an additional header line that contains the ids.

combineKernels(ker1file, ker2file, kerOutFile, operation='add', **args)

source code 

combine two kernels by either adding or multiplying them. In the case of addition the resulting kernel is of the form: K_out(i,j) = weight * K1(i,j) + (1-weight) * K2(i,j) where the default weight is 0.5 In the case of multiplication the resulting kernel is: K_out(i,j) = (const1 + K1(i,j)) * (const2 + K2(i, j)) where const1 and const2 are 0 by default.

Notes: It is assumed that the kernels have the same size and the ids are in the same order (an exception is raised if this is not satisfied).

Parameters:
  • operation - which operation to perform between the kernels; it is a string with supported values 'add' or 'multiply' (add by default)
  • weight - weighting of kernels for kernel addition
  • const1, const2 - additive factor in case of kernel multiplication

sortKernel(kernelInFile, kernelOutFile, format='gist', **args)

source code 
sort a kernel matrix according to its pattern ID
Parameters:
  • kernelInFile - the kernel input file name
  • kernelOutFile - the output file name
  • format - whether to output the kernel in gist format
  • delim - the field delimiter (default = tab)

expandKernel(inKernelFile, referenceKernelFile, outKernelFile, **args)

source code 
Given a kernel matrix that might have missing entries, fill those as 0 on the basis of the patterns in a reference kernel (it is checked that the reference kernel is sorted).
Parameters:
  • inKernelFile - input kernel file name
  • referenceKernelFile - file name for the reference kernel
  • outKernelFile - file name to output expanded kernel

sortKernel2(kernelInFile, kernelOutFile, ids, format='gist', **args)

source code 
sort a kernel matrix according to the given list of ids
Parameters:
  • kernelInFile - the kernel input file name
  • kernelOutFile - the output file name
  • format - whether to output the kernel in gist format
  • delim - the field delimiter (default = tab)