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.

model_selection_old.py 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. """model_selection_old.ipynb
  3. Automatically generated by Colaboratory.
  4. Original file is located at
  5. https://colab.research.google.com/drive/1uVkl7scNgEPrimX8ks6iEC5ijuhB8L_D
  6. **This script demonstrates how to compute a graph kernel.**
  7. ---
  8. **0. Install `graphkit-learn`.**
  9. """
  10. """**1. Perform model seletion and classification.**"""
  11. from gklearn.utils import model_selection_for_precomputed_kernel
  12. from gklearn.kernels import untilhpathkernel
  13. import numpy as np
  14. # Set parameters.
  15. datafile = '../../../datasets/MUTAG/MUTAG_A.txt'
  16. param_grid_precomputed = {'depth': np.linspace(1, 10, 10),
  17. 'k_func': ['MinMax', 'tanimoto'],
  18. 'compute_method': ['trie']}
  19. param_grid = {'C': np.logspace(-10, 10, num=41, base=10)}
  20. # Perform model selection and classification.
  21. model_selection_for_precomputed_kernel(
  22. datafile, # The path of dataset file.
  23. untilhpathkernel, # The graph kernel used for estimation.
  24. param_grid_precomputed, # The parameters used to compute gram matrices.
  25. param_grid, # The penelty Parameters used for penelty items.
  26. 'classification', # Or 'regression'.
  27. NUM_TRIALS=30, # The number of the random trials of the outer CV loop.
  28. ds_name='MUTAG', # The name of the dataset.
  29. n_jobs=1,
  30. verbose=True)

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