grakel.PropagationAttr

class grakel.PropagationAttr(n_jobs=None, verbose=False, normalize=False, random_state=None, metric=<function _dot>, M='L1', t_max=5, w=4)[source][source]

The Propagation kernel for fully attributed graphs.

See [NGBK15]: Algorithms 1, 3, p. 216, 221.

Parameters
t_maxint, default=5

Maximum number of iterations.

wint, default=0.01

Bin width.

Mstr, default=”TV”
The preserved distance metric (on local sensitive hashing):
  • “L1”: l1-norm

  • “L2”: l2-norm

metricfunction (np.array, np.array -> number),

default=:math:f(x,y)=sum_{i} x_{i}*y_{i} A metric between two 1-dimensional numpy arrays of numbers that outputs a number.

Attributes
Mstr

The preserved distance metric (on local sensitive hashing).

tmaxint

Holds the maximum number of iterations.

wint

Holds the bin width.

metricfunction (np.array, np.array -> number)

A metric between two 1-dimensional numpy arrays of numbers that outputs a number.

Methods

calculate_LSH(self, X, u, b)

Calculate Local Sensitive Hashing needed for propagation kernels.

diagonal(self)

Calculate the kernel matrix diagonal of the fit/transformed data.

fit(self, X[, y])

Fit a dataset, for a transformer.

fit_transform(self, X)

Fit and transform, on the same dataset.

get_params(self[, deep])

Get parameters for this estimator.

initialize(self)

Initialize all transformer arguments, needing initialization.

pairwise_operation(self, x, y)

Calculate the kernel value between two elements.

parse_input(self, X)

Parse and create features for the attributed propation kernel.

set_params(self, \*\*params)

Call the parent method.

transform(self, X)

Calculate the kernel matrix, between given and fitted dataset.

Initialise a propagation kernel.

Attributes
X

Methods

calculate_LSH(self, X, u, b)

Calculate Local Sensitive Hashing needed for propagation kernels.

diagonal(self)

Calculate the kernel matrix diagonal of the fit/transformed data.

fit(self, X[, y])

Fit a dataset, for a transformer.

fit_transform(self, X)

Fit and transform, on the same dataset.

get_params(self[, deep])

Get parameters for this estimator.

initialize(self)

Initialize all transformer arguments, needing initialization.

pairwise_operation(self, x, y)

Calculate the kernel value between two elements.

parse_input(self, X)

Parse and create features for the attributed propation kernel.

set_params(self, \*\*params)

Call the parent method.

transform(self, X)

Calculate the kernel matrix, between given and fitted dataset.

__init__(self, n_jobs=None, verbose=False, normalize=False, random_state=None, metric=<function _dot at 0x7f17e196c620>, M='L1', t_max=5, w=4)[source][source]

Initialise a propagation kernel.

calculate_LSH(self, X, u, b)[source][source]

Calculate Local Sensitive Hashing needed for propagation kernels.

See [NGBK15], p.12.

Parameters
Xnp.array

A float array of shape (N, D) with N vertices and D features.

unp.array, shape=(D, 1)

A projection vector.

bfloat

An offset (times w).

Returns
lshnp.array.

The local sensitive hash coresponding to each vertex.

diagonal(self)[source]

Calculate the kernel matrix diagonal of the fit/transformed data.

Parameters
None.
Returns
X_diagnp.array

The diagonal of the kernel matrix between the fitted data. This consists of each element calculated with itself.

Y_diagnp.array

The diagonal of the kernel matrix, of the transform. This consists of each element calculated with itself.

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

Fit a dataset, for a transformer.

Parameters
Xiterable

Each element must be an iterable with at most three features and at least one. The first that is obligatory is a valid graph structure (adjacency matrix or edge_dictionary) while the second is node_labels and the third edge_labels (that fitting the given graph format). The train samples.

yNone

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

Returns
selfobject
Returns self.
fit_transform(self, X)[source]

Fit and transform, on the same dataset.

Parameters
Xiterable

Each element must be an iterable with at most three features and at least one. The first that is obligatory is a valid graph structure (adjacency matrix or edge_dictionary) while the second is node_labels and the third edge_labels (that fitting the given graph format). If None the kernel matrix is calculated upon fit data. The test samples.

yNone

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

Returns
Knumpy array, shape = [n_targets, n_input_graphs]

corresponding to the kernel matrix, a calculation between all pairs of graphs between target an features

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 initialization.

pairwise_operation(self, x, y)[source]

Calculate the kernel value between two elements.

Parameters
x, y: list

Inverse label dictionaries.

Returns
kernelnumber

The kernel value.

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

Parse and create features for the attributed propation kernel.

Parameters
Xiterable

For the input to pass the test, we must have: Each element must be an iterable with at most three features and at least one. The first that is obligatory is a valid graph structure (adjacency matrix or edge_dictionary) while the second is node_labels and the third edge_labels (that correspond to the given graph format). A valid input also consists of graph type objects.

Returns
local_valuesdict

A dictionary of pairs between each input graph and a bins where the sampled graphlets have fallen.

set_params(self, **params)[source]

Call the parent method.

transform(self, X)[source]

Calculate the kernel matrix, between given and fitted dataset.

Parameters
Xiterable

Each element must be an iterable with at most three features and at least one. The first that is obligatory is a valid graph structure (adjacency matrix or edge_dictionary) while the second is node_labels and the third edge_labels (that fitting the given graph format). If None the kernel matrix is calculated upon fit data. The test samples.

Returns
Knumpy array, shape = [n_targets, n_input_graphs]

corresponding to the kernel matrix, a calculation between all pairs of graphs between target an features

Bibliography

NGBK15(1,2)

Marion Neumann, Roman Garnett, Christian Bauckhage, and Kristian Kersting. Propagation kernels: efficient graph kernels from propagated information. Machine Learning, 102:209–245, 2015.