grakel
.NeighborhoodSubgraphPairwiseDistance¶
-
class
grakel.
NeighborhoodSubgraphPairwiseDistance
(n_jobs=None, normalize=False, verbose=False, r=3, d=4)[source][source]¶ The Neighborhood subgraph pairwise distance kernel.
See [CDG10].
- Parameters
- rint, default=3
The maximum considered radius between vertices.
- dint, default=4
Neighborhood depth.
- Attributes
- _ngxint
The number of graphs upon fit.
- _ngyint
The number of graphs upon transform.
- _fit_keysdict
A dictionary with keys from 0 to _d+1, constructed upon fit holding an enumeration of all the found (in the fit dataset) tuples of two hashes and a radius in this certain level.
- _X_level_norm_factordict
A dictionary with keys from 0 to _d+1, that holds the self calculated kernel [krg(X_i, X_i) for i=1:ngraphs_X] for all levels.
Methods
diagonal
(self)Calculate the kernel matrix diagonal of the fitted 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 a pairwise kernel between two elements.
parse_input
(self, X)Parse and create features for the NSPD kernel.
set_params
(self, \*\*params)Call the parent method.
transform
(self, X[, y])Calculate the kernel matrix, between given and fitted dataset.
Initialize an NSPD kernel.
- Attributes
- X
Methods
diagonal
(self)Calculate the kernel matrix diagonal of the fitted 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 a pairwise kernel between two elements.
parse_input
(self, X)Parse and create features for the NSPD kernel.
set_params
(self, \*\*params)Call the parent method.
transform
(self, X[, y])Calculate the kernel matrix, between given and fitted dataset.
-
__init__
(self, n_jobs=None, normalize=False, verbose=False, r=3, d=4)[source][source]¶ Initialize an NSPD kernel.
-
diagonal
(self)[source][source]¶ Calculate the kernel matrix diagonal of the fitted data.
Static. Added for completeness.
- Parameters
- None.
- Returns
- X_diagint
Always equal with r*d.
- Y_diagint
Always equal with r*d.
-
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][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.
- Returns
- Knumpy array, shape = [n_input_graphs, 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]¶ Calculate a pairwise kernel between two elements.
- Parameters
- x, yObject
Objects as occur from parse_input.
- Returns
- kernelnumber
The kernel value.
-
parse_input
(self, X)[source][source]¶ Parse and create features for the NSPD 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
- Mdict
A dictionary with keys all the distances from 0 to self.d and values the the np.arrays with rows corresponding to the non-null input graphs and columns to the enumerations of tuples consisting of pairs of hash values and radius, from all the given graphs of the input (plus the fitted one’s on transform).
-
transform
(self, X, y=None)[source][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).
- yObject, default=None
Ignored argument, added for the pipeline.
- 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