Browse Source

New translations run_untilhpathkernel.ipynb (Chinese Simplified)

l10n_v0.2.x
linlin 4 years ago
parent
commit
f706a63240
1 changed files with 412 additions and 0 deletions
  1. +412
    -0
      lang/zh/notebooks/run_untilhpathkernel.ipynb

+ 412
- 0
lang/zh/notebooks/run_untilhpathkernel.ipynb View File

@@ -0,0 +1,412 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Acyclic\n",
"\n",
"--- This is a regression problem ---\n",
"\n",
"\n",
"1. Loading dataset from file...\n",
"\n",
"2. Calculating gram matrices. This could take a while...\n",
"getting paths: 183it [00:00, 22697.39it/s]\n",
"calculating kernels: 16836it [00:00, 371524.56it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 1 of size 183 built in 0.27962422370910645 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 1.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 35988.26it/s]\n",
"calculating kernels: 16836it [00:00, 444708.75it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 1 of size 183 built in 0.284440279006958 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 1.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 26474.81it/s]\n",
"calculating kernels: 16836it [00:00, 215084.65it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 2 of size 183 built in 0.2832369804382324 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 2.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 18360.43it/s]\n",
"calculating kernels: 16836it [00:00, 254309.18it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 2 of size 183 built in 0.28844165802001953 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 2.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 8687.30it/s]\n",
"calculating kernels: 16836it [00:00, 168741.96it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 3 of size 183 built in 0.38907885551452637 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 3.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 11379.65it/s]\n",
"calculating kernels: 16836it [00:00, 195770.23it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 3 of size 183 built in 0.39213061332702637 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 3.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 8062.50it/s]\n",
"calculating kernels: 16836it [00:00, 72349.59it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 4 of size 183 built in 0.512467622756958 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 4.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 10578.68it/s]\n",
"calculating kernels: 16836it [00:00, 133704.13it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 4 of size 183 built in 0.3866546154022217 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 4.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 9220.91it/s]\n",
"calculating kernels: 16836it [00:00, 98386.86it/s] \n",
"\n",
" --- kernel matrix of path kernel up to 5 of size 183 built in 0.38112974166870117 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 5.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 8493.03it/s]\n",
"calculating kernels: 16836it [00:00, 119698.11it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 5 of size 183 built in 0.38007307052612305 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 5.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 7385.55it/s]\n",
"calculating kernels: 16836it [00:00, 88347.09it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 6 of size 183 built in 0.3929023742675781 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 6.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 5394.24it/s]\n",
"calculating kernels: 16836it [00:00, 100946.78it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 6 of size 183 built in 0.3824801445007324 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 6.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 12457.52it/s]\n",
"calculating kernels: 16836it [00:00, 68995.02it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 7 of size 183 built in 0.49313783645629883 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 7.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 2829.00it/s]\n",
"calculating kernels: 16836it [00:00, 105515.66it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 7 of size 183 built in 0.35750555992126465 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 7.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 7427.43it/s]\n",
"calculating kernels: 16836it [00:00, 81607.79it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 8 of size 183 built in 0.4937615394592285 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 8.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 5660.08it/s]\n",
"calculating kernels: 16836it [00:00, 90014.85it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 8 of size 183 built in 0.36504673957824707 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 8.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 7548.83it/s]\n",
"calculating kernels: 16836it [00:00, 79498.55it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 9 of size 183 built in 0.47993040084838867 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 9.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 7319.90it/s]\n",
"calculating kernels: 16836it [00:00, 92310.24it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 9 of size 183 built in 0.3970515727996826 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 9.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 8318.60it/s]\n",
"calculating kernels: 16836it [00:00, 89934.38it/s] \n",
"\n",
" --- kernel matrix of path kernel up to 10 of size 183 built in 0.4861469268798828 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 10.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 183it [00:00, 2635.72it/s]\n",
"calculating kernels: 16836it [00:00, 90123.30it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 10 of size 183 built in 0.367603063583374 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 10.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"\n",
"20 gram matrices are calculated, 0 of which are ignored.\n",
"\n",
"3. Fitting and predicting using nested cross validation. This could really take a while...\n",
"cross validation: 30it [01:06, 1.11s/it]\n",
"\n",
"4. Getting final performance...\n",
"best_params_out: [{'compute_method': 'trie', 'depth': 2.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True}]\n",
"best_params_in: [{'alpha': 0.01}]\n",
"\n",
"best_val_perf: 6.842702754673377\n",
"best_val_std: 0.3600238142615252\n",
"final_performance: [7.557191252340816]\n",
"final_confidence: [2.5849069582911595]\n",
"train_performance: [2.276370048287339]\n",
"train_std: [0.13830866732067562]\n",
"\n",
"time to calculate gram matrix with different hyper-params: 0.39±0.07s\n",
"time to calculate best gram matrix: 0.28±0.00s\n",
"total training time with all hyper-param choices: 79.82s\n",
"\n",
"\n",
"\n",
"Alkane\n",
"\n",
"--- This is a regression problem ---\n",
"\n",
"\n",
"1. Loading dataset from file...\n",
"\n",
"2. Calculating gram matrices. This could take a while...\n",
"getting paths: 150it [00:00, 31366.32it/s]\n",
"calculating kernels: 11325it [00:00, 509820.58it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 1 of size 150 built in 0.29791831970214844 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 1.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 150it [00:00, 30330.50it/s]\n",
"calculating kernels: 11325it [00:00, 655613.27it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 1 of size 150 built in 0.29232001304626465 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 1.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 150it [00:00, 27568.71it/s]\n",
"calculating kernels: 11325it [00:00, 780628.98it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 2 of size 150 built in 0.2590019702911377 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 2.0, 'k_func': 'MinMax', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n",
"getting paths: 150it [00:00, 17554.29it/s]\n",
"calculating kernels: 11325it [00:00, 320784.55it/s]\n",
"\n",
" --- kernel matrix of path kernel up to 2 of size 150 built in 0.3091611862182617 seconds ---\n",
"\n",
"the gram matrix with parameters {'compute_method': 'trie', 'depth': 2.0, 'k_func': 'tanimoto', 'n_jobs': 8, 'verbose': True} is: \n",
"\n",
"\n"
]
}
],
"source": [
"# %load_ext line_profiler\n",
"# %matplotlib inline\n",
"from libs import *\n",
"import multiprocessing\n",
"\n",
"from gklearn.kernels.untilHPathKernel import untilhpathkernel\n",
"from gklearn.utils.kernels import deltakernel, kernelproduct\n",
"\n",
"dslist = [\n",
" {'name': 'Acyclic', 'dataset': '../datasets/acyclic/dataset_bps.ds',\n",
" 'task': 'regression'}, # node symb\n",
" {'name': 'Alkane', 'dataset': '../datasets/Alkane/dataset.ds', 'task': 'regression',\n",
" 'dataset_y': '../datasets/Alkane/dataset_boiling_point_names.txt'}, \n",
" # contains single node graph, node symb\n",
" {'name': 'MAO', 'dataset': '../datasets/MAO/dataset.ds'}, # node/edge symb\n",
" {'name': 'PAH', 'dataset': '../datasets/PAH/dataset.ds'}, # unlabeled\n",
" {'name': 'MUTAG', 'dataset': '../datasets/MUTAG/MUTAG_A.txt'}, # node/edge symb\n",
" {'name': 'Letter-med', 'dataset': '../datasets/Letter-med/Letter-med_A.txt'},\n",
" # node nsymb\n",
" {'name': 'ENZYMES', 'dataset': '../datasets/ENZYMES_txt/ENZYMES_A_sparse.txt'},\n",
" # node symb/nsymb\n",
"# {'name': 'Mutagenicity', 'dataset': '../datasets/Mutagenicity/Mutagenicity_A.txt'},\n",
"# # node/edge symb\n",
"# {'name': 'D&D', 'dataset': '../datasets/DD/DD_A.txt'}, # node symb\n",
"\n",
" # {'name': 'COIL-DEL', 'dataset': '../datasets/COIL-DEL/COIL-DEL_A.txt'}, # edge symb, node nsymb\n",
" # # # {'name': 'BZR', 'dataset': '../datasets/BZR_txt/BZR_A_sparse.txt'}, # node symb/nsymb\n",
" # # # {'name': 'COX2', 'dataset': '../datasets/COX2_txt/COX2_A_sparse.txt'}, # node symb/nsymb\n",
" # {'name': 'Fingerprint', 'dataset': '../datasets/Fingerprint/Fingerprint_A.txt'},\n",
" #\n",
" # # {'name': 'DHFR', 'dataset': '../datasets/DHFR_txt/DHFR_A_sparse.txt'}, # node symb/nsymb\n",
" # # {'name': 'SYNTHETIC', 'dataset': '../datasets/SYNTHETIC_txt/SYNTHETIC_A_sparse.txt'}, # node symb/nsymb\n",
" # # {'name': 'MSRC9', 'dataset': '../datasets/MSRC_9_txt/MSRC_9_A.txt'}, # node symb\n",
" # # {'name': 'MSRC21', 'dataset': '../datasets/MSRC_21_txt/MSRC_21_A.txt'}, # node symb\n",
" # # {'name': 'FIRSTMM_DB', 'dataset': '../datasets/FIRSTMM_DB/FIRSTMM_DB_A.txt'}, # node symb/nsymb ,edge nsymb\n",
"\n",
" # # {'name': 'PROTEINS', 'dataset': '../datasets/PROTEINS_txt/PROTEINS_A_sparse.txt'}, # node symb/nsymb\n",
" # # {'name': 'PROTEINS_full', 'dataset': '../datasets/PROTEINS_full_txt/PROTEINS_full_A_sparse.txt'}, # node symb/nsymb\n",
" # # {'name': 'AIDS', 'dataset': '../datasets/AIDS/AIDS_A.txt'}, # node symb/nsymb, edge symb\n",
" # {'name': 'NCI1', 'dataset': '../datasets/NCI1/NCI1.mat',\n",
" # 'extra_params': {'am_sp_al_nl_el': [1, 1, 2, 0, -1]}}, # node symb\n",
" # {'name': 'NCI109', 'dataset': '../datasets/NCI109/NCI109.mat',\n",
" # 'extra_params': {'am_sp_al_nl_el': [1, 1, 2, 0, -1]}}, # node symb\n",
" # {'name': 'NCI-HIV', 'dataset': '../datasets/NCI-HIV/AIDO99SD.sdf',\n",
" # 'dataset_y': '../datasets/NCI-HIV/aids_conc_may04.txt',}, # node/edge symb\n",
"\n",
" # # not working below\n",
" # {'name': 'PTC_FM', 'dataset': '../datasets/PTC/Train/FM.ds',},\n",
" # {'name': 'PTC_FR', 'dataset': '../datasets/PTC/Train/FR.ds',},\n",
" # {'name': 'PTC_MM', 'dataset': '../datasets/PTC/Train/MM.ds',},\n",
" # {'name': 'PTC_MR', 'dataset': '../datasets/PTC/Train/MR.ds',},\n",
"]\n",
"estimator = untilhpathkernel\n",
"param_grid_precomputed = {'depth': np.linspace(1, 10, 10), # [2], \n",
" 'k_func': ['MinMax', 'tanimoto'],\n",
" 'compute_method': ['trie']} # ['MinMax']}\n",
"param_grid = [{'C': np.logspace(-10, 10, num=41, base=10)},\n",
" {'alpha': np.logspace(-10, 10, num=41, base=10)}]\n",
"\n",
"for ds in dslist:\n",
" print()\n",
" print(ds['name'])\n",
" model_selection_for_precomputed_kernel(\n",
" ds['dataset'],\n",
" estimator,\n",
" param_grid_precomputed,\n",
" (param_grid[1] if ('task' in ds and ds['task']\n",
" == 'regression') else param_grid[0]),\n",
" (ds['task'] if 'task' in ds else 'classification'),\n",
" NUM_TRIALS=30,\n",
" datafile_y=(ds['dataset_y'] if 'dataset_y' in ds else None),\n",
" extra_params=(ds['extra_params'] if 'extra_params' in ds else None),\n",
" ds_name=ds['name'],\n",
" n_jobs=multiprocessing.cpu_count(),\n",
" read_gm_from_file=False,\n",
" verbose=True)\n",
" print()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'line_profiler'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\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",
"\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",
"\u001b[0;32m<decorator-gen-65>\u001b[0m in \u001b[0;36mload_ext\u001b[0;34m(self, module_str)\u001b[0m\n",
"\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",
"\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",
"\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",
"\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",
"\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",
"\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",
"\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",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'line_profiler'"
]
}
],
"source": [
"%load_ext line_profiler\n",
"\n",
"import sys\n",
"sys.path.insert(0, \"../\")\n",
"from gklearn.utils.utils import kernel_train_test\n",
"from gklearn.kernels.untildPathKernel import untildpathkernel\n",
"\n",
"import numpy as np\n",
"\n",
"datafile = '../../datasets/acyclic/Acyclic/dataset_bps.ds'\n",
"kernel_file_path = 'kernelmatrices_path_acyclic/'\n",
"\n",
"kernel_para = dict(node_label = 'atom', edge_label = 'bond_type', labeled = True, k_func = 'tanimoto')\n",
"\n",
"# kernel_train_test(datafile, kernel_file_path, treeletkernel, kernel_para, normalize = False)\n",
"\n",
"kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, \\\n",
" hyper_name = 'depth', hyper_range = np.linspace(0, 20, 21), normalize = True)\n",
"kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, \\\n",
" hyper_name = 'depth', hyper_range = np.linspace(0, 20, 21), normalize = False)\n",
"\n",
"kernel_para['k_func'] = 'minmax'\n",
"kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, \\\n",
" hyper_name = 'depth', hyper_range = np.linspace(0, 10, 11), normalize = True)\n",
"kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, \\\n",
" hyper_name = 'depth', hyper_range = np.linspace(0, 10, 11), normalize = False)\n",
"\n",
"# # kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, normalize = False)\n",
"\n",
"# kernel_para['depth'] = 10\n",
"# %lprun -f untildpathkernel \\\n",
"# kernel_train_test(datafile, kernel_file_path, untildpathkernel, kernel_para, normalize = False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Loading…
Cancel
Save