grakel.KMTransformer

class grakel.KMTransformer(K=None)[source][source]

A Kernel Matrix Transformer.

Usefull for using precalculated Kernel Matrices inside scikit-learn pipeline.

Parameters
Karray-like, shape=[n, n]

If given an array the input can be as follows:

  • array-like lists of lists

  • np.array

  • sparse matrix (scipy.sparse)

It can also be embedded in an sklearn Bunch object as a mat (argument)

Attributes
K_numpy.array, shape=[n, n]

Methods

fit(self, X[, y])

Fit a list of indeces.

fit_transform(self, X[, y])

Fit and transform, on the same dataset.

get_params(self[, deep])

Get parameters for this estimator.

initialize(self)

Initialize all transformer arguments, needing initialisation.

set_params(self, \*\*params)

Set the parameters of this estimator.

transform(self, X)

Calculate the kernel matrix, between given and fitted dataset.

Initialise the Kernel Matrix Transformer

Methods

fit(self, X[, y])

Fit a list of indeces.

fit_transform(self, X[, y])

Fit and transform, on the same dataset.

get_params(self[, deep])

Get parameters for this estimator.

initialize(self)

Initialize all transformer arguments, needing initialisation.

set_params(self, \*\*params)

Set the parameters of this estimator.

transform(self, X)

Calculate the kernel matrix, between given and fitted dataset.

__init__(self, K=None)[source][source]

Initialise the Kernel Matrix Transformer

fit(self, X, y=None)[source][source]

Fit a list of indeces.

Parameters
XIterable of int:

Indexes for the X of the kernel matrix.

Returns
selfobject

Returns self.

fit_transform(self, X, y=None)[source][source]

Fit and transform, on the same dataset.

Parameters
XIterable of int

Indexes for the first dimension of the kernel matrix.

yNone

There is no need of a target in a transformer, yet the pipeline API requires this parameter.

Returns
Knumpy array, shape = [len(X), len(X)]

Corresping to the values of the X indexes with themselfs.

get_params(self, deep=True)[source]

Get parameters for this estimator.

Parameters
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsmapping of string to any

Parameter names mapped to their values.

initialize(self)[source][source]

Initialize all transformer arguments, needing initialisation.

set_params(self, **params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters
**paramsdict

Estimator parameters.

Returns
selfobject

Estimator instance.

transform(self, X)[source][source]

Calculate the kernel matrix, between given and fitted dataset.

Parameters
XIterable of int

Indexes for the second dimension of the kernel matrix.

Returns
Knumpy array, shape = [len(Y), len(X)]

Corresping to the values of the Y indexes with X.