mlpack.fastmks

fastmks(...)FastMKS (Fast Max-Kernel Search)

>>> from mlpack import fastmks

This program will find the k maximum kernels of a set of points, using a query set and a reference set (which can optionally be the same set). More specifically, for each point in the query set, the k points in the reference set with maximum kernel evaluations are found. The kernel function used is specified with the 'kernel' parameter.

For example, the following command will calculate, for each point in the query set 'query', the five points in the reference set 'reference' with maximum kernel evaluation using the linear kernel. The kernel evaluations may be saved with the 'kernels' output parameter and the indices may be saved with the 'indices' output parameter.

>>> fastmks(k=5, reference=reference, query=query, kernel='linear')

>>> indices = output['indices']

>>> kernels = output['kernels']

The output matrices are organized such that row i and column j in the indices matrix corresponds to the index of the point in the reference set that has j'th largest kernel evaluation with the point in the query set with index i. Row i and column j in the kernels matrix corresponds to the kernel evaluation between those two points.

This program performs FastMKS using a cover tree. The base used to build the cover tree can be specified with the 'base' parameter.

## input options

- bandwidth (float): Bandwidth (for Gaussian, Epanechnikov, and triangular kernels). Default value 1.
- base (float): Base to use during cover tree construction. Default value 2.
- copy_all_inputs (bool): If specified, all input parameters will be deep copied before the method is run. This is useful for debugging problems where the input parameters are being modified by the algorithm, but can slow down the code.
- degree (float): Degree of polynomial kernel. Default value 2.
- input_model (mlpack.FastMKSModelType): Input FastMKS model to use.
- k (int): Number of maximum kernels to find. Default value 0.
- kernel (string): Kernel type to use: 'linear', 'polynomial', 'cosine', 'gaussian', 'epanechnikov', 'triangular', 'hyptan'. Default value linear.
- naive (bool): If true, O(n^2) naive mode is used for computation.
- offset (float): Offset of kernel (for polynomial and hyptan kernels). Default value 0.
- query (numpy matrix or arraylike, float dtype): The query dataset.
- reference (numpy matrix or arraylike, float dtype): The reference dataset.
- scale (float): Scale of kernel (for hyptan kernel). Default value 1.
- single (bool): If true, single-tree search is used (as opposed to dual-tree search.
- verbose (bool): Display informational messages and the full list of parameters and timers at the end of execution.

## output options

The return value from the binding is a dict containing the following elements:

- indices (numpy matrix, int dtype): Output matrix of indices.
- kernels (numpy matrix, float dtype): Output matrix of kernels.
- output_model (mlpack.FastMKSModelType): Output for FastMKS model.