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_untilhpathkernel.ipynb 28 kB

5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": null,
  6. "metadata": {
  7. "scrolled": false
  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. "\n",
  20. "1. Loading dataset from file...\n",
  21. "\n",
  22. "2. Calculating gram matrices. This could take a while...\n",
  23. "getting paths: 183it [00:00, 22697.39it/s]\n",
  24. "calculating kernels: 16836it [00:00, 371524.56it/s]\n",
  25. "\n",
  26. " --- kernel matrix of path kernel up to 1 of size 183 built in 0.27962422370910645 seconds ---\n",
  27. "\n",
  28. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 1.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  29. "\n",
  30. "\n",
  31. "getting paths: 183it [00:00, 35988.26it/s]\n",
  32. "calculating kernels: 16836it [00:00, 444708.75it/s]\n",
  33. "\n",
  34. " --- kernel matrix of path kernel up to 1 of size 183 built in 0.284440279006958 seconds ---\n",
  35. "\n",
  36. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 1.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  37. "\n",
  38. "\n",
  39. "getting paths: 183it [00:00, 26474.81it/s]\n",
  40. "calculating kernels: 16836it [00:00, 215084.65it/s]\n",
  41. "\n",
  42. " --- kernel matrix of path kernel up to 2 of size 183 built in 0.2832369804382324 seconds ---\n",
  43. "\n",
  44. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 2.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  45. "\n",
  46. "\n",
  47. "getting paths: 183it [00:00, 18360.43it/s]\n",
  48. "calculating kernels: 16836it [00:00, 254309.18it/s]\n",
  49. "\n",
  50. " --- kernel matrix of path kernel up to 2 of size 183 built in 0.28844165802001953 seconds ---\n",
  51. "\n",
  52. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 2.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  53. "\n",
  54. "\n",
  55. "getting paths: 183it [00:00, 8687.30it/s]\n",
  56. "calculating kernels: 16836it [00:00, 168741.96it/s]\n",
  57. "\n",
  58. " --- kernel matrix of path kernel up to 3 of size 183 built in 0.38907885551452637 seconds ---\n",
  59. "\n",
  60. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 3.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  61. "\n",
  62. "\n",
  63. "getting paths: 183it [00:00, 11379.65it/s]\n",
  64. "calculating kernels: 16836it [00:00, 195770.23it/s]\n",
  65. "\n",
  66. " --- kernel matrix of path kernel up to 3 of size 183 built in 0.39213061332702637 seconds ---\n",
  67. "\n",
  68. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 3.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  69. "\n",
  70. "\n",
  71. "getting paths: 183it [00:00, 8062.50it/s]\n",
  72. "calculating kernels: 16836it [00:00, 72349.59it/s]\n",
  73. "\n",
  74. " --- kernel matrix of path kernel up to 4 of size 183 built in 0.512467622756958 seconds ---\n",
  75. "\n",
  76. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 4.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  77. "\n",
  78. "\n",
  79. "getting paths: 183it [00:00, 10578.68it/s]\n",
  80. "calculating kernels: 16836it [00:00, 133704.13it/s]\n",
  81. "\n",
  82. " --- kernel matrix of path kernel up to 4 of size 183 built in 0.3866546154022217 seconds ---\n",
  83. "\n",
  84. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 4.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  85. "\n",
  86. "\n",
  87. "getting paths: 183it [00:00, 9220.91it/s]\n",
  88. "calculating kernels: 16836it [00:00, 98386.86it/s] \n",
  89. "\n",
  90. " --- kernel matrix of path kernel up to 5 of size 183 built in 0.38112974166870117 seconds ---\n",
  91. "\n",
  92. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 5.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  93. "\n",
  94. "\n",
  95. "getting paths: 183it [00:00, 8493.03it/s]\n",
  96. "calculating kernels: 16836it [00:00, 119698.11it/s]\n",
  97. "\n",
  98. " --- kernel matrix of path kernel up to 5 of size 183 built in 0.38007307052612305 seconds ---\n",
  99. "\n",
  100. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 5.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  101. "\n",
  102. "\n",
  103. "getting paths: 183it [00:00, 7385.55it/s]\n",
  104. "calculating kernels: 16836it [00:00, 88347.09it/s]\n",
  105. "\n",
  106. " --- kernel matrix of path kernel up to 6 of size 183 built in 0.3929023742675781 seconds ---\n",
  107. "\n",
  108. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 6.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  109. "\n",
  110. "\n",
  111. "getting paths: 183it [00:00, 5394.24it/s]\n",
  112. "calculating kernels: 16836it [00:00, 100946.78it/s]\n",
  113. "\n",
  114. " --- kernel matrix of path kernel up to 6 of size 183 built in 0.3824801445007324 seconds ---\n",
  115. "\n",
  116. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 6.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  117. "\n",
  118. "\n",
  119. "getting paths: 183it [00:00, 12457.52it/s]\n",
  120. "calculating kernels: 16836it [00:00, 68995.02it/s]\n",
  121. "\n",
  122. " --- kernel matrix of path kernel up to 7 of size 183 built in 0.49313783645629883 seconds ---\n",
  123. "\n",
  124. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 7.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  125. "\n",
  126. "\n",
  127. "getting paths: 183it [00:00, 2829.00it/s]\n",
  128. "calculating kernels: 16836it [00:00, 105515.66it/s]\n",
  129. "\n",
  130. " --- kernel matrix of path kernel up to 7 of size 183 built in 0.35750555992126465 seconds ---\n",
  131. "\n",
  132. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 7.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  133. "\n",
  134. "\n",
  135. "getting paths: 183it [00:00, 7427.43it/s]\n",
  136. "calculating kernels: 16836it [00:00, 81607.79it/s]\n",
  137. "\n",
  138. " --- kernel matrix of path kernel up to 8 of size 183 built in 0.4937615394592285 seconds ---\n",
  139. "\n",
  140. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 8.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  141. "\n",
  142. "\n",
  143. "getting paths: 183it [00:00, 5660.08it/s]\n",
  144. "calculating kernels: 16836it [00:00, 90014.85it/s]\n",
  145. "\n",
  146. " --- kernel matrix of path kernel up to 8 of size 183 built in 0.36504673957824707 seconds ---\n",
  147. "\n",
  148. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 8.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  149. "\n",
  150. "\n",
  151. "getting paths: 183it [00:00, 7548.83it/s]\n",
  152. "calculating kernels: 16836it [00:00, 79498.55it/s]\n",
  153. "\n",
  154. " --- kernel matrix of path kernel up to 9 of size 183 built in 0.47993040084838867 seconds ---\n",
  155. "\n",
  156. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 9.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  157. "\n",
  158. "\n",
  159. "getting paths: 183it [00:00, 7319.90it/s]\n",
  160. "calculating kernels: 16836it [00:00, 92310.24it/s]\n",
  161. "\n",
  162. " --- kernel matrix of path kernel up to 9 of size 183 built in 0.3970515727996826 seconds ---\n",
  163. "\n",
  164. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 9.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  165. "\n",
  166. "\n",
  167. "getting paths: 183it [00:00, 8318.60it/s]\n",
  168. "calculating kernels: 16836it [00:00, 89934.38it/s] \n",
  169. "\n",
  170. " --- kernel matrix of path kernel up to 10 of size 183 built in 0.4861469268798828 seconds ---\n",
  171. "\n",
  172. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 10.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  173. "\n",
  174. "\n",
  175. "getting paths: 183it [00:00, 2635.72it/s]\n",
  176. "calculating kernels: 16836it [00:00, 90123.30it/s]\n",
  177. "\n",
  178. " --- kernel matrix of path kernel up to 10 of size 183 built in 0.367603063583374 seconds ---\n",
  179. "\n",
  180. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 10.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  181. "\n",
  182. "\n",
  183. "\n",
  184. "20 gram matrices are calculated, 0 of which are ignored.\n",
  185. "\n",
  186. "3. Fitting and predicting using nested cross validation. This could really take a while...\n",
  187. "cross validation: 30it [01:06, 1.11s/it]\n",
  188. "\n",
  189. "4. Getting final performance...\n",
  190. "best_params_out: [{'compute_method': 'trie', 'depth': 2.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True}]\n",
  191. "best_params_in: [{'alpha': 0.01}]\n",
  192. "\n",
  193. "best_val_perf: 6.842702754673377\n",
  194. "best_val_std: 0.3600238142615252\n",
  195. "final_performance: [7.557191252340816]\n",
  196. "final_confidence: [2.5849069582911595]\n",
  197. "train_performance: [2.276370048287339]\n",
  198. "train_std: [0.13830866732067562]\n",
  199. "\n",
  200. "time to calculate gram matrix with different hyper-params: 0.39±0.07s\n",
  201. "time to calculate best gram matrix: 0.28±0.00s\n",
  202. "total training time with all hyper-param choices: 79.82s\n",
  203. "\n",
  204. "\n",
  205. "\n",
  206. "Alkane\n",
  207. "\n",
  208. "--- This is a regression problem ---\n",
  209. "\n",
  210. "\n",
  211. "1. Loading dataset from file...\n",
  212. "\n",
  213. "2. Calculating gram matrices. This could take a while...\n",
  214. "getting paths: 150it [00:00, 31366.32it/s]\n",
  215. "calculating kernels: 11325it [00:00, 509820.58it/s]\n",
  216. "\n",
  217. " --- kernel matrix of path kernel up to 1 of size 150 built in 0.29791831970214844 seconds ---\n",
  218. "\n",
  219. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 1.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  220. "\n",
  221. "\n",
  222. "getting paths: 150it [00:00, 30330.50it/s]\n",
  223. "calculating kernels: 11325it [00:00, 655613.27it/s]\n",
  224. "\n",
  225. " --- kernel matrix of path kernel up to 1 of size 150 built in 0.29232001304626465 seconds ---\n",
  226. "\n",
  227. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 1.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  228. "\n",
  229. "\n",
  230. "getting paths: 150it [00:00, 27568.71it/s]\n",
  231. "calculating kernels: 11325it [00:00, 780628.98it/s]\n",
  232. "\n",
  233. " --- kernel matrix of path kernel up to 2 of size 150 built in 0.2590019702911377 seconds ---\n",
  234. "\n",
  235. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 2.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
  236. "\n",
  237. "\n",
  238. "getting paths: 150it [00:00, 17554.29it/s]\n",
  239. "calculating kernels: 11325it [00:00, 320784.55it/s]\n",
  240. "\n",
  241. " --- kernel matrix of path kernel up to 2 of size 150 built in 0.3091611862182617 seconds ---\n",
  242. "\n",
  243. "the gram matrix with parameters {'compute_method': 'trie', 'depth': 2.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
  244. "\n",
  245. "\n"
  246. ]
  247. }
  248. ],
  249. "source": [
  250. "# %load_ext line_profiler\n",
  251. "# %matplotlib inline\n",
  252. "from libs import *\n",
  253. "import multiprocessing\n",
  254. "\n",
  255. "from gklearn.kernels.untilHPathKernel import untilhpathkernel\n",
  256. "from gklearn.utils.kernels import deltakernel, kernelproduct\n",
  257. "\n",
  258. "dslist = [\n",
  259. " {'name': 'Acyclic', 'dataset': '../datasets/acyclic/dataset_bps.ds',\n",
  260. " 'task': 'regression'}, # node symb\n",
  261. " {'name': 'Alkane', 'dataset': '../datasets/Alkane/dataset.ds', 'task': 'regression',\n",
  262. " 'dataset_y': '../datasets/Alkane/dataset_boiling_point_names.txt'}, \n",
  263. " # contains single node graph, node symb\n",
  264. " {'name': 'MAO', 'dataset': '../datasets/MAO/dataset.ds'}, # node/edge symb\n",
  265. " {'name': 'PAH', 'dataset': '../datasets/PAH/dataset.ds'}, # unlabeled\n",
  266. " {'name': 'MUTAG', 'dataset': '../datasets/MUTAG/MUTAG_A.txt'}, # node/edge symb\n",
  267. " {'name': 'Letter-med', 'dataset': '../datasets/Letter-med/Letter-med_A.txt'},\n",
  268. " # node nsymb\n",
  269. " {'name': 'ENZYMES', 'dataset': '../datasets/ENZYMES_txt/ENZYMES_A_sparse.txt'},\n",
  270. " # node symb/nsymb\n",
  271. "# {'name': 'Mutagenicity', 'dataset': '../datasets/Mutagenicity/Mutagenicity_A.txt'},\n",
  272. "# # node/edge symb\n",
  273. "# {'name': 'D&D', 'dataset': '../datasets/DD/DD_A.txt'}, # node symb\n",
  274. "\n",
  275. " # {'name': 'COIL-DEL', 'dataset': '../datasets/COIL-DEL/COIL-DEL_A.txt'}, # edge symb, node nsymb\n",
  276. " # # # {'name': 'BZR', 'dataset': '../datasets/BZR_txt/BZR_A_sparse.txt'}, # node symb/nsymb\n",
  277. " # # # {'name': 'COX2', 'dataset': '../datasets/COX2_txt/COX2_A_sparse.txt'}, # node symb/nsymb\n",
  278. " # {'name': 'Fingerprint', 'dataset': '../datasets/Fingerprint/Fingerprint_A.txt'},\n",
  279. " #\n",
  280. " # # {'name': 'DHFR', 'dataset': '../datasets/DHFR_txt/DHFR_A_sparse.txt'}, # node symb/nsymb\n",
  281. " # # {'name': 'SYNTHETIC', 'dataset': '../datasets/SYNTHETIC_txt/SYNTHETIC_A_sparse.txt'}, # node symb/nsymb\n",
  282. " # # {'name': 'MSRC9', 'dataset': '../datasets/MSRC_9_txt/MSRC_9_A.txt'}, # node symb\n",
  283. " # # {'name': 'MSRC21', 'dataset': '../datasets/MSRC_21_txt/MSRC_21_A.txt'}, # node symb\n",
  284. " # # {'name': 'FIRSTMM_DB', 'dataset': '../datasets/FIRSTMM_DB/FIRSTMM_DB_A.txt'}, # node symb/nsymb ,edge nsymb\n",
  285. "\n",
  286. " # # {'name': 'PROTEINS', 'dataset': '../datasets/PROTEINS_txt/PROTEINS_A_sparse.txt'}, # node symb/nsymb\n",
  287. " # # {'name': 'PROTEINS_full', 'dataset': '../datasets/PROTEINS_full_txt/PROTEINS_full_A_sparse.txt'}, # node symb/nsymb\n",
  288. " # # {'name': 'AIDS', 'dataset': '../datasets/AIDS/AIDS_A.txt'}, # node symb/nsymb, edge symb\n",
  289. " # {'name': 'NCI1', 'dataset': '../datasets/NCI1/NCI1.mat',\n",
  290. " # 'extra_params': {'am_sp_al_nl_el': [1, 1, 2, 0, -1]}}, # node symb\n",
  291. " # {'name': 'NCI109', 'dataset': '../datasets/NCI109/NCI109.mat',\n",
  292. " # 'extra_params': {'am_sp_al_nl_el': [1, 1, 2, 0, -1]}}, # node symb\n",
  293. " # {'name': 'NCI-HIV', 'dataset': '../datasets/NCI-HIV/AIDO99SD.sdf',\n",
  294. " # 'dataset_y': '../datasets/NCI-HIV/aids_conc_may04.txt',}, # node/edge symb\n",
  295. "\n",
  296. " # # not working below\n",
  297. " # {'name': 'PTC_FM', 'dataset': '../datasets/PTC/Train/FM.ds',},\n",
  298. " # {'name': 'PTC_FR', 'dataset': '../datasets/PTC/Train/FR.ds',},\n",
  299. " # {'name': 'PTC_MM', 'dataset': '../datasets/PTC/Train/MM.ds',},\n",
  300. " # {'name': 'PTC_MR', 'dataset': '../datasets/PTC/Train/MR.ds',},\n",
  301. "]\n",
  302. "estimator = untilhpathkernel\n",
  303. "param_grid_precomputed = {'depth': np.linspace(1, 10, 10), # [2], \n",
  304. " 'k_func': ['MinMax', 'tanimoto'],\n",
  305. " 'compute_method': ['trie']} # ['MinMax']}\n",
  306. "param_grid = [{'C': np.logspace(-10, 10, num=41, base=10)},\n",
  307. " {'alpha': np.logspace(-10, 10, num=41, base=10)}]\n",
  308. "\n",
  309. "for ds in dslist:\n",
  310. " print()\n",
  311. " print(ds['name'])\n",
  312. " model_selection_for_precomputed_kernel(\n",
  313. " ds['dataset'],\n",
  314. " estimator,\n",
  315. " param_grid_precomputed,\n",
  316. " (param_grid[1] if ('task' in ds and ds['task']\n",
  317. " == 'regression') else param_grid[0]),\n",
  318. " (ds['task'] if 'task' in ds else 'classification'),\n",
  319. " NUM_TRIALS=30,\n",
  320. " datafile_y=(ds['dataset_y'] if 'dataset_y' in ds else None),\n",
  321. " extra_params=(ds['extra_params'] if 'extra_params' in ds else None),\n",
  322. " ds_name=ds['name'],\n",
  323. " n_jobs=multiprocessing.cpu_count(),\n",
  324. " read_gm_from_file=False,\n",
  325. " verbose=True)\n",
  326. " print()"
  327. ]
  328. },
  329. {
  330. "cell_type": "code",
  331. "execution_count": 2,
  332. "metadata": {},
  333. "outputs": [
  334. {
  335. "ename": "ModuleNotFoundError",
  336. "evalue": "No module named 'line_profiler'",
  337. "output_type": "error",
  338. "traceback": [
  339. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  340. "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
  341. "\u001b[0;32m<ipython-input-2-cf4da93eeb50>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_line_magic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'load_ext'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'line_profiler'\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 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minsert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\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 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mgklearn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mkernel_train_test\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  342. "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mrun_line_magic\u001b[0;34m(self, magic_name, line, _stack_depth)\u001b[0m\n\u001b[1;32m 2283\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'local_ns'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getframe\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstack_depth\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mf_locals\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2284\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuiltin_trap\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2285\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mkwargs\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 2286\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2287\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
  343. "\u001b[0;32m<decorator-gen-65>\u001b[0m in \u001b[0;36mload_ext\u001b[0;34m(self, module_str)\u001b[0m\n",
  344. "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py\u001b[0m in \u001b[0;36m<lambda>\u001b[0;34m(f, *a, **k)\u001b[0m\n\u001b[1;32m 185\u001b[0m \u001b[0;31m# but it's overkill for just that one bit of state.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmagic_deco\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\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[0;32m--> 187\u001b[0;31m \u001b[0mcall\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\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 188\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 189\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcallable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\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",
  345. "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/magics/extension.py\u001b[0m in \u001b[0;36mload_ext\u001b[0;34m(self, module_str)\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mmodule_str\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 32\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mUsageError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Missing module name.'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 33\u001b[0;31m \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshell\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mextension_manager\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_extension\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmodule_str\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 34\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 35\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mres\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'already loaded'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  346. "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/extensions.py\u001b[0m in \u001b[0;36mload_extension\u001b[0;34m(self, module_str)\u001b[0m\n\u001b[1;32m 78\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmodule_str\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodules\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mprepended_to_syspath\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mipython_extension_dir\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[0;32m---> 80\u001b[0;31m \u001b[0mmod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mimport_module\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmodule_str\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 81\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__file__\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstartswith\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mipython_extension_dir\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 82\u001b[0m print((\"Loading extensions from {dir} is deprecated. \"\n",
  347. "\u001b[0;32m/usr/lib/python3.6/importlib/__init__.py\u001b[0m in \u001b[0;36mimport_module\u001b[0;34m(name, package)\u001b[0m\n\u001b[1;32m 124\u001b[0m \u001b[0;32mbreak\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 125\u001b[0m \u001b[0mlevel\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 126\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_bootstrap\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_gcd_import\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mlevel\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpackage\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\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 127\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 128\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
  348. "\u001b[0;32m/usr/lib/python3.6/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_gcd_import\u001b[0;34m(name, package, level)\u001b[0m\n",
  349. "\u001b[0;32m/usr/lib/python3.6/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_find_and_load\u001b[0;34m(name, import_)\u001b[0m\n",
  350. "\u001b[0;32m/usr/lib/python3.6/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_find_and_load_unlocked\u001b[0;34m(name, import_)\u001b[0m\n",
  351. "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'line_profiler'"
  352. ]
  353. }
  354. ],
  355. "source": [
  356. "%load_ext line_profiler\n",
  357. "\n",
  358. "import sys\n",
  359. "sys.path.insert(0, \"../\")\n",
  360. "from gklearn.utils.utils import kernel_train_test\n",
  361. "from gklearn.kernels.untildPathKernel import untildpathkernel\n",
  362. "\n",
  363. "import numpy as np\n",
  364. "\n",
  365. "datafile = '../../datasets/acyclic/Acyclic/dataset_bps.ds'\n",
  366. "kernel_file_path = 'kernelmatrices_path_acyclic/'\n",
  367. "\n",
  368. "kernel_para = dict(node_label = 'atom', edge_label = 'bond_type', labeled = True, k_func = 'tanimoto')\n",
  369. "\n",
  370. "# kernel_train_test(datafile, kernel_file_path, treeletkernel, kernel_para, normalize = False)\n",
  371. "\n",
  372. "kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, \\\n",
  373. " hyper_name = 'depth', hyper_range = np.linspace(0, 20, 21), normalize = True)\n",
  374. "kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, \\\n",
  375. " hyper_name = 'depth', hyper_range = np.linspace(0, 20, 21), normalize = False)\n",
  376. "\n",
  377. "kernel_para['k_func'] = 'minmax'\n",
  378. "kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, \\\n",
  379. " hyper_name = 'depth', hyper_range = np.linspace(0, 10, 11), normalize = True)\n",
  380. "kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, \\\n",
  381. " hyper_name = 'depth', hyper_range = np.linspace(0, 10, 11), normalize = False)\n",
  382. "\n",
  383. "# # kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, normalize = False)\n",
  384. "\n",
  385. "# kernel_para['depth'] = 10\n",
  386. "# %lprun -f untildpathkernel \\\n",
  387. "# kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, normalize = False)"
  388. ]
  389. }
  390. ],
  391. "metadata": {
  392. "kernelspec": {
  393. "display_name": "Python 3",
  394. "language": "python",
  395. "name": "python3"
  396. },
  397. "language_info": {
  398. "codemirror_mode": {
  399. "name": "ipython",
  400. "version": 3
  401. },
  402. "file_extension": ".py",
  403. "mimetype": "text/x-python",
  404. "name": "python",
  405. "nbconvert_exporter": "python",
  406. "pygments_lexer": "ipython3",
  407. "version": "3.6.7"
  408. }
  409. },
  410. "nbformat": 4,
  411. "nbformat_minor": 2
  412. }

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