You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

compute_graph_kernel_old.py 805 B

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. """compute_graph_kernel_v0.1.ipynb
  3. Automatically generated by Colaboratory.
  4. Original file is located at
  5. https://colab.research.google.com/drive/10jUz7-ahPiE_T1qvFrh2NvCVs1e47noj
  6. **This script demonstrates how to compute a graph kernel.**
  7. ---
  8. **0. Install `graphkit-learn`.**
  9. """
  10. """**1. Get dataset.**"""
  11. from gklearn.utils.graphfiles import loadDataset
  12. graphs, targets = loadDataset('../../../datasets/MUTAG/MUTAG_A.txt')
  13. """**2. Compute graph kernel.**"""
  14. from gklearn.kernels import untilhpathkernel
  15. gram_matrix, run_time = untilhpathkernel(
  16. graphs, # The list of input graphs.
  17. depth=5, # The longest length of paths.
  18. k_func='MinMax', # Or 'tanimoto'.
  19. compute_method='trie', # Or 'naive'.
  20. n_jobs=1, # The number of jobs to run in parallel.
  21. verbose=True)

A Python package for graph kernels, graph edit distances and graph pre-image problem.