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.

run_randomwalkkernel.ipynb 19 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {
  7. "scrolled": true
  8. },
  9. "outputs": [
  10. {
  11. "name": "stdout",
  12. "output_type": "stream",
  13. "text": [
  14. "\n",
  15. "Acyclic\n",
  16. "\n",
  17. "--- This is a regression problem ---\n",
  18. "\n",
  19. "1. Loading dataset from file...\n",
  20. "\n",
  21. "2. Calculating gram matrices. This could take a while...\n",
  22. "\n",
  23. "gram matrix with parameters {'compute_method': 'sylvester'} is: \n",
  24. "\r",
  25. "calculating kernels: 0%| | 0/16836.0 [00:00<?, ?it/s]"
  26. ]
  27. },
  28. {
  29. "name": "stderr",
  30. "output_type": "stream",
  31. "text": [
  32. "../pygraph/kernels/randomWalkKernel.py:81: UserWarning: The Sylvester equation (rather than generalized Sylvester equation) is used; only walks of length 1 is considered.\n",
  33. " 'The Sylvester equation (rather than generalized Sylvester equation) is used; only walks of length 1 is considered.'\n"
  34. ]
  35. },
  36. {
  37. "ename": "NameError",
  38. "evalue": "name 'all_walks' is not defined",
  39. "output_type": "error",
  40. "traceback": [
  41. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  42. "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
  43. "\u001b[0;32m<ipython-input-1-b058c92f071d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mds\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'task'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m'task'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mds\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0;34m'classification'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNUM_TRIALS\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m30\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[0mdatafile_y\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mds\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'dataset_y'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m'dataset_y'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mds\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 60\u001b[0;31m extra_params=(ds['extra_params'] if 'extra_params' in ds else None))\n\u001b[0m\u001b[1;32m 61\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  44. "\u001b[0;32m/media/ljia/DATA/research-repo/codes/Linlin/py-graph/pygraph/utils/model_selection_precomputed.py\u001b[0m in \u001b[0;36mmodel_selection_for_precomputed_kernel\u001b[0;34m(datafile, estimator, param_grid_precomputed, param_grid, model_type, NUM_TRIALS, datafile_y, extra_params)\u001b[0m\n\u001b[1;32m 99\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'gram matrix with parameters'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams_out\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'is: '\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 100\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 101\u001b[0;31m \u001b[0mKmatrix\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcurrent_run_time\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mestimator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mparams_out\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 102\u001b[0m \u001b[0mKmatrix_diag\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mKmatrix\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdiagonal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 103\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
  45. "\u001b[0;32m/media/ljia/DATA/research-repo/codes/Linlin/py-graph/pygraph/kernels/randomWalkKernel.py\u001b[0m in \u001b[0;36mrandomwalkkernel\u001b[0;34m(node_label, edge_label, h, compute_method, *args)\u001b[0m\n\u001b[1;32m 85\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mGn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 86\u001b[0m Kmatrix[i][j] = _randomwalkkernel_sylvester(\n\u001b[0;32m---> 87\u001b[0;31m \u001b[0mall_walks\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 88\u001b[0m \u001b[0mall_walks\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[0mnode_label\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnode_label\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  46. "\u001b[0;31mNameError\u001b[0m: name 'all_walks' is not defined"
  47. ]
  48. }
  49. ],
  50. "source": [
  51. "%load_ext line_profiler\n",
  52. "%matplotlib inline\n",
  53. "import numpy as np\n",
  54. "import sys\n",
  55. "sys.path.insert(0, \"../\")\n",
  56. "from pygraph.utils.model_selection_precomputed import model_selection_for_precomputed_kernel\n",
  57. "from pygraph.kernels.randomWalkKernel import randomwalkkernel\n",
  58. "\n",
  59. "dslist = [ \n",
  60. " {'name': 'Acyclic', 'dataset': '../datasets/acyclic/dataset_bps.ds', 'task': 'regression'}, # node_labeled\n",
  61. " {'name': 'COIL-DEL', 'dataset': '../datasets/COIL-DEL/COIL-DEL_A.txt'}, # edge_labeled\n",
  62. " {'name': 'PAH', 'dataset': '../datasets/PAH/dataset.ds',}, # unlabeled\n",
  63. " {'name': 'Mutagenicity', 'dataset': '../datasets/Mutagenicity/Mutagenicity_A.txt'}, # fully_labeled\n",
  64. "# {'name': 'MAO', 'dataset': '../datasets/MAO/dataset.ds',},\n",
  65. "\n",
  66. "# {'name': 'MUTAG', 'dataset': '../datasets/MUTAG/MUTAG.mat',\n",
  67. "# 'extra_params': {'am_sp_al_nl_el': [0, 0, 3, 1, 2]}},\n",
  68. "# {'name': 'Alkane', 'dataset': '../datasets/Alkane/dataset.ds', 'task': 'regression', \n",
  69. "# 'dataset_y': '../datasets/Alkane/dataset_boiling_point_names.txt',},\n",
  70. "# {'name': 'BZR', 'dataset': '../datasets/BZR_txt/BZR_A_sparse.txt'},\n",
  71. "# {'name': 'COX2', 'dataset': '../datasets/COX2_txt/COX2_A_sparse.txt'}, \n",
  72. " {'name': 'ENZYMES', 'dataset': '../datasets/ENZYMES_txt/ENZYMES_A_sparse.txt'},\n",
  73. "# {'name': 'DHFR', 'dataset': '../datasets/DHFR_txt/DHFR_A_sparse.txt'},\n",
  74. "# {'name': 'SYNTHETIC', 'dataset': '../datasets/SYNTHETIC_txt/SYNTHETIC_A_sparse.txt'},\n",
  75. "# {'name': 'MSRC9', 'dataset': '../datasets/MSRC_9_txt/MSRC_9_A.txt'},\n",
  76. "# {'name': 'MSRC21', 'dataset': '../datasets/MSRC_21_txt/MSRC_21_A.txt'},\n",
  77. "# {'name': 'FIRSTMM_DB', 'dataset': '../datasets/FIRSTMM_DB/FIRSTMM_DB_A.txt'},\n",
  78. "\n",
  79. "# {'name': 'PROTEINS', 'dataset': '../datasets/PROTEINS_txt/PROTEINS_A_sparse.txt'},\n",
  80. "# {'name': 'PROTEINS_full', 'dataset': '../datasets/PROTEINS_full_txt/PROTEINS_full_A_sparse.txt'},\n",
  81. "# {'name': 'D&D', 'dataset': '../datasets/D&D/DD.mat',\n",
  82. "# 'extra_params': {'am_sp_al_nl_el': [0, 1, 2, 1, -1]}},\n",
  83. "# {'name': 'AIDS', 'dataset': '../datasets/AIDS/AIDS_A.txt'},\n",
  84. "# {'name': 'NCI1', 'dataset': '../datasets/NCI1/NCI1.mat',\n",
  85. "# 'extra_params': {'am_sp_al_nl_el': [1, 1, 2, 0, -1]}},\n",
  86. "# {'name': 'NCI109', 'dataset': '../datasets/NCI109/NCI109.mat',\n",
  87. "# 'extra_params': {'am_sp_al_nl_el': [1, 1, 2, 0, -1]}},\n",
  88. "# {'name': 'NCI-HIV', 'dataset': '../datasets/NCI-HIV/AIDO99SD.sdf',\n",
  89. "# 'dataset_y': '../datasets/NCI-HIV/aids_conc_may04.txt',},\n",
  90. " \n",
  91. "# # not working below\n",
  92. "# {'name': 'PTC_FM', 'dataset': '../datasets/PTC/Train/FM.ds',},\n",
  93. "# {'name': 'PTC_FR', 'dataset': '../datasets/PTC/Train/FR.ds',},\n",
  94. "# {'name': 'PTC_MM', 'dataset': '../datasets/PTC/Train/MM.ds',},\n",
  95. "# {'name': 'PTC_MR', 'dataset': '../datasets/PTC/Train/MR.ds',},\n",
  96. "]\n",
  97. "estimator = randomwalkkernel\n",
  98. "param_grid_precomputed = {'compute_method': ['sylvester']}\n",
  99. "param_grid = [{'C': np.logspace(-10, 10, num = 41, base = 10)}, \n",
  100. " {'alpha': np.logspace(-10, 10, num = 41, base = 10)}]\n",
  101. "\n",
  102. "for ds in dslist:\n",
  103. " print()\n",
  104. " print(ds['name'])\n",
  105. " model_selection_for_precomputed_kernel(\n",
  106. " ds['dataset'], estimator, param_grid_precomputed, \n",
  107. " (param_grid[1] if ('task' in ds and ds['task'] == 'regression') else param_grid[0]), \n",
  108. " (ds['task'] if 'task' in ds else 'classification'), NUM_TRIALS=30,\n",
  109. " datafile_y=(ds['dataset_y'] if 'dataset_y' in ds else None),\n",
  110. " extra_params=(ds['extra_params'] if 'extra_params' in ds else None))\n",
  111. " print()"
  112. ]
  113. },
  114. {
  115. "cell_type": "code",
  116. "execution_count": 1,
  117. "metadata": {
  118. "scrolled": true
  119. },
  120. "outputs": [
  121. {
  122. "name": "stdout",
  123. "output_type": "stream",
  124. "text": [
  125. "\n",
  126. "--- This is a regression problem ---\n",
  127. "\n",
  128. "1. Loading dataset from file...\n",
  129. "\n",
  130. "2. Calculating gram matrices. This could take a while...\n",
  131. "\n",
  132. "gram matrix with parameters {'n': 0.0} is: \n"
  133. ]
  134. },
  135. {
  136. "ename": "IndexError",
  137. "evalue": "index 1 is out of bounds for axis 0 with size 1",
  138. "output_type": "error",
  139. "traceback": [
  140. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  141. "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
  142. "\u001b[0;32m<ipython-input-1-2b1121e86472>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m model_selection_for_precomputed_kernel(datafile, estimator, param_grid_precomputed, param_grid, \n\u001b[0;32m---> 15\u001b[0;31m 'regression', NUM_TRIALS=30)\n\u001b[0m",
  143. "\u001b[0;32m/media/ljia/DATA/research-repo/codes/Linlin/py-graph/pygraph/utils/model_selection_precomputed.py\u001b[0m in \u001b[0;36mmodel_selection_for_precomputed_kernel\u001b[0;34m(datafile, estimator, param_grid_precomputed, param_grid, model_type, NUM_TRIALS, datafile_y)\u001b[0m\n\u001b[1;32m 94\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'gram matrix with parameters'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams_out\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'is: '\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 95\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 96\u001b[0;31m \u001b[0mKmatrix\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcurrent_run_time\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mestimator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mparams_out\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 97\u001b[0m \u001b[0mKmatrix_diag\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mKmatrix\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdiagonal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
  144. "\u001b[0;32m/media/ljia/DATA/research-repo/codes/Linlin/py-graph/pygraph/kernels/untilnWalkKernel.py\u001b[0m in \u001b[0;36muntilnwalkkernel\u001b[0;34m(node_label, edge_label, labeled, n, weight, compute_method, *args)\u001b[0m\n\u001b[1;32m 65\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mGn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 66\u001b[0m Kmatrix[i][j] = _untilnwalkkernel_direct(\n\u001b[0;32m---> 67\u001b[0;31m Gn[i], Gn[j], node_label, edge_label, labeled, weight)\n\u001b[0m\u001b[1;32m 68\u001b[0m \u001b[0mKmatrix\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mKmatrix\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 69\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
  145. "\u001b[0;32m/media/ljia/DATA/research-repo/codes/Linlin/py-graph/pygraph/kernels/untilnWalkKernel.py\u001b[0m in \u001b[0;36m_untilnwalkkernel_direct\u001b[0;34m(G1, G2, node_label, edge_label, labeled, weight)\u001b[0m\n\u001b[1;32m 129\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mproduct\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgp\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 130\u001b[0m \u001b[0mmat_tmp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mT\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mweight\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mD\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mT\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mI\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 131\u001b[0;31m \u001b[0mkernel\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mkernel\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmat_tmp\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 132\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 133\u001b[0m \u001b[0;31m# from matplotlib import pyplot as plt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  146. "\u001b[0;32m/usr/local/lib/python3.5/dist-packages/numpy/matrixlib/defmatrix.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, index)\u001b[0m\n\u001b[1;32m 282\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 283\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 284\u001b[0;31m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mN\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__getitem__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 285\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 286\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getitem\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  147. "\u001b[0;31mIndexError\u001b[0m: index 1 is out of bounds for axis 0 with size 1"
  148. ]
  149. }
  150. ],
  151. "source": [
  152. "%load_ext line_profiler\n",
  153. "%matplotlib inline\n",
  154. "import numpy as np\n",
  155. "import sys\n",
  156. "sys.path.insert(0, \"../\")\n",
  157. "from pygraph.utils.model_selection_precomputed import model_selection_for_precomputed_kernel\n",
  158. "from pygraph.kernels.untilnWalkKernel import untilnwalkkernel\n",
  159. "\n",
  160. "datafile = '../../../../datasets/acyclic/Acyclic/dataset_bps.ds'\n",
  161. "estimator = untilnwalkkernel\n",
  162. "param_grid_precomputed = {'n': np.linspace(0, 10, 11)}\n",
  163. "param_grid = {'alpha': np.logspace(-10, 10, num = 41, base = 10)}\n",
  164. "\n",
  165. "model_selection_for_precomputed_kernel(datafile, estimator, param_grid_precomputed, param_grid, \n",
  166. " 'regression', NUM_TRIALS=30)"
  167. ]
  168. },
  169. {
  170. "cell_type": "code",
  171. "execution_count": null,
  172. "metadata": {},
  173. "outputs": [],
  174. "source": [
  175. "# results\n",
  176. "\n",
  177. "# untiln kernel when h = 2\n",
  178. " lmda rmse_test std_test rmse_train std_train k_time\n",
  179. "----------- ----------- ---------- ------------ ----------- --------\n",
  180. " 1e-10 7.46524 1.71862 5.99486 0.356634 38.1447\n",
  181. " 1e-09 7.37326 1.77195 5.96155 0.374395 37.4921\n",
  182. " 1e-08 7.35105 1.78349 5.96481 0.378047 37.9971\n",
  183. " 1e-07 7.35213 1.77903 5.96728 0.382251 38.3182\n",
  184. " 1e-06 7.3524 1.77992 5.9696 0.3863 39.6428\n",
  185. " 1e-05 7.34958 1.78141 5.97114 0.39017 37.3711\n",
  186. " 0.0001 7.3513 1.78136 5.94251 0.331843 37.3967\n",
  187. " 0.001 7.35822 1.78119 5.9326 0.32534 36.7357\n",
  188. " 0.01 7.37552 1.79037 5.94089 0.34763 36.8864\n",
  189. " 0.1 7.32951 1.91346 6.42634 1.29405 36.8382\n",
  190. " 1 7.27134 2.20774 6.62425 1.2242 37.2425\n",
  191. " 10 7.49787 2.36815 6.81697 1.50182 37.8286\n",
  192. " 100 7.42887 2.64789 6.68766 1.34809 36.3701\n",
  193. " 1000 7.24914 2.65554 6.81906 1.41008 36.1695\n",
  194. " 10000 7.08183 2.6248 6.93431 1.38441 37.5723\n",
  195. "100000 8.021 3.43694 8.69813 0.909839 37.8158\n",
  196. " 1e+06 8.49625 3.6332 9.59333 0.96626 38.4688\n",
  197. " 1e+07 10.9067 3.17593 11.5642 2.07792 36.9926\n",
  198. " 1e+08 61.1524 10.4355 65.3527 13.9538 37.1321\n",
  199. " 1e+09 99.943 13.6994 98.8848 5.27014 36.7443\n",
  200. " 1e+10 100.083 13.8503 97.9168 3.22768 37.096\n"
  201. ]
  202. }
  203. ],
  204. "metadata": {
  205. "kernelspec": {
  206. "display_name": "Python 3",
  207. "language": "python",
  208. "name": "python3"
  209. },
  210. "language_info": {
  211. "codemirror_mode": {
  212. "name": "ipython",
  213. "version": 3
  214. },
  215. "file_extension": ".py",
  216. "mimetype": "text/x-python",
  217. "name": "python",
  218. "nbconvert_exporter": "python",
  219. "pygments_lexer": "ipython3",
  220. "version": "3.5.2"
  221. }
  222. },
  223. "nbformat": 4,
  224. "nbformat_minor": 2
  225. }

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