grakel
.GraphKernel¶
- class grakel.GraphKernel(kernel='shortest_path', normalize=False, verbose=False, n_jobs=None, random_state=None, Nystroem=False)[source][source]¶
A generic wrapper for graph kernels.
- Parameters
- kernellist*(dict or str)
A single element or a list of
dict
with:“name” : [str] - with the kernel name
“name_of_parameter_1” : value
“name_of_parameter_2” : value
\(\;\cdots\;\)
“name_of_parameter_k” : value
or of
str
, designating a kernel name.- available “name” or “name-alias” / “parametres” are:
base_graph_kernels (the structure must always reach a base kernel)
- “vertex_histogram” or “subtree_wl” or “VH” or “ST-WL”
(o) “sparse” : bool or ‘auto’
- “edge_histogram” or “EH”
(o) “sparse” : bool or ‘auto’
- “random_walk” or “RW”
(o) “with_labels” : bool
(o) “lamda” : float
(o) “method_type” : [str], “baseline”, “fast”
(o) “kernel_type” : [str], “geometric”, “exponential”
(o) “p” : [int] > 0
- “shortest_path” or “SP”
(o) “algorithm_type” : [str] “dijkstra”, “floyd_warshall”
(o) “as_attributes” : [bool]
(o) “metric” : [function] : (attribute_x, attribute_y) -> number
(o) “with_labels” : [bool]
- “graphlet_sampling” or “GR”
(o) “k” : [int]
(o) “sampling” : [dict] or None
- “multiscale_laplacian” or “ML”
(o) “L” : [int] > 0
(o) “gamma” : [float] > .0
(o) “heta” : [float] > .0
(o) “n_samples” : [int] > 0, if “which”: “fast”
(o) “P” : [int] > 0, if “which”: “fast”
- “subgraph_matching” or “SM”
(o) “kv” : [function] : (node_x, node_y, Lx, Ly) -> number
(o) “ke” : [function] : (edge_x, edge_y, Lx, Ly) -> number
(o) “lw” : a lambda weight function for cliques: set -> number
- “lovasz_theta” or “LOVT”
(o) “n_samples” : [int] > 1
(o) “subsets_size_range” : [tuple] of two [int]
(o) “metric” : [function] (number, number) -> number
- “svm_theta” or “SVMT”
(o) “n_samples” : [int] > 1
(o) “subsets_size_range” : [tuple] with 2 [int] elements
(o) “metric” : [function] (number, number) -> number
- “neighborhood_hash” or “NH”
(o) “nh_type” : [str] “simple” or “count-sensitive”
(o) “R” : [int] > 0
(o) “bits” : [int] > 0
- “neighborhood_subgraph_pairwise_distance” or “NSPD”
(o) “r” : (int) positive integer
(o) “d” : (int) positive integer
- “odd_sth” or “ODD”
(o) “h” : [int] > 0
- “propagation” or “PR”
(o) t_max: [int] > 0
(o) T: [dict] [int]: [np.arrays]
(o) with_attributes: [bool], default=False
(o) M: [str] {“H”, “TV”} if with_attributes=True else {“L1”, “L2”}
(o) w: [int] > 0
(o) metric: [function] x:[Counter] , y:[Counter] -> [number]
- “pyramid_match” or “PM”
(o) with_labels: [bool]
(o) d: [int] > 0
(o) L: [int] >= 0
- “graph_hopper” or “GH”
(o) kernel_type: [str: {‘linear’, ‘gaussian’}] or [tuple: {(‘gaussian’, mu)}] or [function] x:[(np.array, np.array)] , y:[(np.array, np.array)] -> [number]
- “weisfeiler_lehman_optimal_assignment” or “WL-OA”
(o) “n_iter” : [int] >= 0
- frameworks (if a next kernel in the list it asssigned as a base-kernel, else see default)
- “weisfeiler_lehman” or “WL” / default=”VH”
(o) “n_iter” : [int] >= 0
- “hadamard_code” or “HC” / default=”VH”
(o) “n_iter” : [int] > 0
- “core_framework” or “CORE” / default=”SP”
(o) “min_core” : [int] >= -1
where (o): stands for optional parameters
- Nystroemint or bool, optional
Defines the number of nystroem components. To initialize the default (100 components), set -1 or 0.
- n_jobsint or None, optional
Defines the number of jobs of a joblib.Parallel objects needed for parallelization or None for direct execution. The use or not of this function depends on each kernel.
- normalizebool, optional
Normalize the output of the graph kernel. Ignored when Nystroem GraphKernel object is instanciated.
- verbosebool, optional
Define if messages will be printed on stdout.
- random_stateRandomState or int, default=None
A random number generator instance or an int to initialize a RandomState as a seed.
- Attributes
- _initializeddict
Monitors which parameter derived object should be _initialized.
- kernel_function
The full kernel applied between graph objects.
- nystroem_int
Holds the nystroem, number of components. If not _initialized, it stands as a False boolean variable.
- components_array, shape=(n_components, n_features)
Subset of training graphs used to construct the feature map.
- nystroem_normalization_array, shape=(n_components, n_components)
Normalization matrix needed for embedding. Square root of the kernel matrix on
components_
.- component_indices_array, shape=(n_components)
Indices of
components_
in the training set.- random_state_RandomState
A RandomState object handling all randomness of the class.
Methods
fit
(X[, y])Fit a dataset, for a transformer.
fit_transform
(X[, y])Fit and transform, on the same dataset.
get_params
([deep])Get parameters for this estimator.
initialize
()Initialize all transformer arguments, needing initialisation.
make_kernel_
(kernel_list, hidden_args)Produce the desired kernel function.
set_params
(**params)Call the parent method.
transform
(X)Calculate the kernel matrix, between given and fitted dataset.
__init__ for GraphKernel object.
Methods
fit
(X[, y])Fit a dataset, for a transformer.
fit_transform
(X[, y])Fit and transform, on the same dataset.
get_params
([deep])Get parameters for this estimator.
initialize
()Initialize all transformer arguments, needing initialisation.
make_kernel_
(kernel_list, hidden_args)Produce the desired kernel function.
set_params
(**params)Call the parent method.
transform
(X)Calculate the kernel matrix, between given and fitted dataset.