grakel
.RandomWalkLabeled¶
-
class
grakel.
RandomWalkLabeled
(n_jobs=None, normalize=False, verbose=False, lamda=0.1, method_type='fast', kernel_type='geometric', p=None)[source][source]¶ The labeled random walk kernel class.
See [KTI03], [GartnerFW03] and [VBS07].
- Parameters
- lambdafloat
A lambda factor concerning summation.
- method_typestr, valid_values={“baseline”, “fast”}
- The method to use for calculating random walk kernel [geometric]:
“baseline” Complexity: \(O(|V|^6)\) (see [KTI03], [GartnerFW03])
“fast” Complexity: \(O(|E|^{2}rd|V|^{3})\) (see [VBS07])
- kernel_typestr, valid_values={“geometric”, “exponential”}
Defines how inner summation will be applied.
- pint, optional
If initialised defines the number of steps.
- Attributes
- _lamdafloat, default=0.1
A lambda factor concerning summation.
- _kernel_typestr, valid_values={“geometric”, “exponential”},
- default=”geometric”
Defines how inner summation will be applied.
- _method_typestr valid_values={“baseline”, “fast”},
- default=”fast”
- The method to use for calculating random walk kernel:
“baseline” Complexity: \(O(|V|^6)\) (see [KTI03], [GartnerFW03])
“fast” Complexity: \(O((|E|+|V|)|V||M|)\) (see [VBS07])
- _pint, default=1
If not -1, the number of steps of the random walk kernel.
Methods
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 labeled random walk kernel.
parse_input
(self, X)Parse and create features for graphlet_sampling kernel.
set_params
(self, \*\*params)Call the parent method.
transform
(self, X)Calculate the kernel matrix, between given and fitted dataset.
Initialise a labeled random_walk kernel.
- Attributes
- X
Methods
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 labeled random walk kernel.
parse_input
(self, X)Parse and create features for graphlet_sampling 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, normalize=False, verbose=False, lamda=0.1, method_type='fast', kernel_type='geometric', p=None)[source][source]¶ Initialise a labeled random_walk kernel.
-
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.
-
pairwise_operation
(self, X, Y)[source][source]¶ Calculate the labeled random walk kernel.
Fast [geometric]: Conjugate Gradient method as presented in [VBS07] p.12, s.4.2, with complexity of \(O(|E|^{2}rd|V|^{3})\) for labeled graphs.
Baseline: Algorithm presented in [KTI03], [GartnerFW03] with complexity of \(O(|V|^6)\)
- Parameters
- X, Ytuples
Tuples of adjacency matrices and labels.
- Returns
- kernelnumber
The kernel value.
-
parse_input
(self, X)[source][source]¶ Parse and create features for graphlet_sampling 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
- outlist
The extracted adjacency matrices for any given input.
-
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¶
- GartnerFW03(1,2,3,4)
Thomas Gärtner, Peter Flach, and Stefan Wrobel. On Graph Kernels: Hardness Results and Efficient Alternatives. In Learning Theory and Kernel Machines, 129–143. 2003.
- KTI03(1,2,3,4)
Hisashi Kashima, Koji Tsuda, and Akihiro Inokuchi. Marginalized Kernels Between Labeled Graphs. In Proceedings of the 20th Conference in Machine Learning, 321–328. 2003.
- VBS07(1,2,3,4)
S.V.N. Vishwanathan, Karsten M. Borgwardt, and Nicol N. Schraudolph. Fast Computation of Graph Kernels. In Advances in Neural Information Processing Systems, 1449–1456. 2007.