diff --git a/README.md b/README.md index bd582cc..b43f901 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,14 @@ The criteria used for prediction are SVM for classification and kernel Ridge reg For predition we randomly divide the data in train and test subset, where 90% of entire dataset is for training and rest for testing. 10 splits are performed. For each split, we first train on the train data, then evaluate the performance on the test set. We choose the optimal parameters for the test set and finally provide the corresponding performance. The final results correspond to the average of the performances on the test sets. -| Kernels | RMSE(℃) | STD(℃) | Parameter | k_time | -|---------------|:---------:|:--------:|-------------:|-------:| -| Shortest path | 35.19 | 4.50 | - | 14.58" | -| Marginalized | 18.02 | 6.29 | p_quit = 0.1 | 4'19" | -| Path | 14.00 | 6.93 | - | 36.21" | -| WL subtree | 7.55 | 2.33 | height = 1 | 0.84" | -| Treelet | 8.31 | 3.38 | - | 49.58" | +| Kernels | RMSE(℃) | STD(℃) | Parameter | k_time | +|---------------|:-------:|:------:|-------------:|-------:| +| Shortest path | 35.19 | 4.50 | - | 14.58" | +| Marginalized | 18.02 | 6.29 | p_quit = 0.1 | 4'19" | +| Path | 14.00 | 6.93 | - | 36.21" | +| WL subtree | 7.55 | 2.33 | height = 1 | 0.84" | +| Treelet | 8.31 | 3.38 | - | 0.50" | +| Path up to d | 7.43 | 2.69 | depth = 2 | 0.59" | * RMSE stands for arithmetic mean of the root mean squared errors on all splits. * STD stands for standard deviation of the root mean squared errors on all splits. @@ -44,6 +45,9 @@ For predition we randomly divide the data in train and test subset, where 90% of [5] Gaüzère B, Brun L, Villemin D. Two new graphs kernels in chemoinformatics. Pattern Recognition Letters. 2012 Nov 1;33(15):2038-47. ## Updates +### 2018.01.24 +* ADD *path kernel up to depth d* and its result on dataset Asyclic. +* MOD treelet kernel, retrieve canonkeys of all graphs before calculate kernels, wildly speed it up. ### 2018.01.17 * ADD comments to code of treelet kernel. - linlin ### 2018.01.16 diff --git a/notebooks/.ipynb_checkpoints/run_treeletkernel_acyclic-checkpoint.ipynb b/notebooks/.ipynb_checkpoints/run_treeletkernel_acyclic-checkpoint.ipynb index c25eb36..41ee8d3 100644 --- a/notebooks/.ipynb_checkpoints/run_treeletkernel_acyclic-checkpoint.ipynb +++ b/notebooks/.ipynb_checkpoints/run_treeletkernel_acyclic-checkpoint.ipynb @@ -2,23 +2,24 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + "The line_profiler extension is already loaded. To reload it, use:\n", + " %reload_ext line_profiler\n", "\n", " --- This is a regression problem ---\n", "\n", "\n", - "\n", " Loading dataset from file...\n", "\n", " Calculating kernel matrix, this could take a while...\n", "\n", - " --- treelet kernel matrix of size 185 built in 50.925347328186035 seconds ---\n", + " --- treelet kernel matrix of size 185 built in 0.48417091369628906 seconds ---\n", "[[ 4.00000000e+00 2.60653066e+00 1.00000000e+00 ..., 1.26641655e-14\n", " 1.26641655e-14 1.26641655e-14]\n", " [ 2.60653066e+00 6.00000000e+00 1.00000000e+00 ..., 1.26641655e-14\n", @@ -42,19 +43,18 @@ "With standard deviation: 5.035844\n", "\n", "\n", - " RMSE_test std_test RMSE_train std_train k_time\n", + " rmse_test std_test rmse_train std_train k_time\n", "----------- ---------- ------------ ----------- --------\n", - " 10.0997 5.03584 2.68803 1.54162 50.9253\n", + " 10.0997 5.03584 2.68803 1.54162 0.484171\n", "\n", " --- This is a regression problem ---\n", "\n", "\n", - "\n", " Loading dataset from file...\n", "\n", " Calculating kernel matrix, this could take a while...\n", "\n", - " --- treelet kernel matrix of size 185 built in 49.581383228302 seconds ---\n", + " --- treelet kernel matrix of size 185 built in 0.5003015995025635 seconds ---\n", "[[ 4.00000000e+00 2.60653066e+00 1.00000000e+00 ..., 1.26641655e-14\n", " 1.26641655e-14 1.26641655e-14]\n", " [ 2.60653066e+00 6.00000000e+00 1.00000000e+00 ..., 1.26641655e-14\n", @@ -78,9 +78,9 @@ "With standard deviation: 3.378376\n", "\n", "\n", - " RMSE_test std_test RMSE_train std_train k_time\n", + " rmse_test std_test rmse_train std_train k_time\n", "----------- ---------- ------------ ----------- --------\n", - " 8.3079 3.37838 2.90887 1.2679 49.5814\n" + " 8.3079 3.37838 2.90887 1.2679 0.500302\n" ] } ], @@ -97,7 +97,7 @@ "\n", "kernel_para = dict(node_label = 'atom', edge_label = 'bond_type', labeled = True)\n", "\n", - "# kernel_train_test(datafile, kernel_file_path, treeletkernel, kernel_para, normalize = False)\n", + "kernel_train_test(datafile, kernel_file_path, treeletkernel, kernel_para, normalize = False)\n", "\n", "kernel_train_test(datafile, kernel_file_path, treeletkernel, kernel_para, normalize = True)\n", "\n", @@ -116,12 +116,12 @@ "# with y normalization\n", " RMSE_test std_test RMSE_train std_train k_time\n", "----------- ---------- ------------ ----------- --------\n", - " 8.3079 3.37838 2.90887 1.2679 49.5814\n", + " 8.3079 3.37838 2.90887 1.2679 0.500302\n", "\n", "# without y normalization\n", " RMSE_test std_test RMSE_train std_train k_time\n", "----------- ---------- ------------ ----------- --------\n", - " 10.0997 5.03584 2.68803 1.54162 50.9253" + " 10.0997 5.03584 2.68803 1.54162 0.484171" ] }, { diff --git a/notebooks/.ipynb_checkpoints/run_untildpathkernel_acyclic-checkpoint.ipynb b/notebooks/.ipynb_checkpoints/run_untildpathkernel_acyclic-checkpoint.ipynb new file mode 100644 index 0000000..fd3692e --- /dev/null +++ b/notebooks/.ipynb_checkpoints/run_untildpathkernel_acyclic-checkpoint.ipynb @@ -0,0 +1,2051 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- This is a regression problem ---\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 0.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 0 of size 185 built in 0.09047365188598633 seconds ---\n", + "[[ 1. 1. 0.33333333 ..., 0.33333333 0.33333333\n", + " 0.33333333]\n", + " [ 1. 1. 0.33333333 ..., 0.33333333 0.33333333\n", + " 0.33333333]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " ..., \n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 43.616902\n", + "With standard deviation: 2.132120\n", + "\n", + " Mean performance on test set: 41.620214\n", + "With standard deviation: 6.453003\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 1.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 1 of size 185 built in 0.1754138469696045 seconds ---\n", + "[[ 1. 0.8 0.14285714 ..., 0.125 0.125 0.125 ]\n", + " [ 0.8 1. 0.125 ..., 0.11111111 0.11111111\n", + " 0.11111111]\n", + " [ 0.14285714 0.125 1. ..., 0.8 0.8 0.8 ]\n", + " ..., \n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]\n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]\n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 40.832861\n", + "With standard deviation: 3.441465\n", + "\n", + " Mean performance on test set: 38.844613\n", + "With standard deviation: 6.446482\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 2.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 2 of size 185 built in 0.3448960781097412 seconds ---\n", + "[[ 1. 0.5 0.11111111 ..., 0.07692308 0.07692308\n", + " 0.07692308]\n", + " [ 0.5 1. 0.09090909 ..., 0.06666667 0.06666667\n", + " 0.06666667]\n", + " [ 0.11111111 0.09090909 1. ..., 0.55555556 0.55555556\n", + " 0.55555556]\n", + " ..., \n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]\n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]\n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 35.746142\n", + "With standard deviation: 1.611340\n", + "\n", + " Mean performance on test set: 35.291451\n", + "With standard deviation: 4.781298\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 3.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 3 of size 185 built in 0.5539388656616211 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.05555556 0.05555556\n", + " 0.05555556]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.04761905 0.04761905\n", + " 0.04761905]\n", + " [ 0.11111111 0.08333333 1. ..., 0.35714286 0.35714286\n", + " 0.35714286]\n", + " ..., \n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 28.464581\n", + "With standard deviation: 3.001371\n", + "\n", + " Mean performance on test set: 29.484499\n", + "With standard deviation: 3.903507\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 4.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 4 of size 185 built in 0.7706489562988281 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.04347826 0.04166667\n", + " 0.04347826]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03846154 0.03703704\n", + " 0.03846154]\n", + " [ 0.11111111 0.08333333 1. ..., 0.26315789 0.25 0.26315789]\n", + " ..., \n", + " [ 0.04347826 0.03846154 0.26315789 ..., 1. 0.95 0.9 ]\n", + " [ 0.04166667 0.03703704 0.25 ..., 0.95 1. 0.95 ]\n", + " [ 0.04347826 0.03846154 0.26315789 ..., 0.9 0.95 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 19.251747\n", + "With standard deviation: 3.428930\n", + "\n", + " Mean performance on test set: 22.669312\n", + "With standard deviation: 6.280526\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 5.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 5 of size 185 built in 1.015580415725708 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03703704 0.03333333\n", + " 0.03571429]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03333333 0.03030303\n", + " 0.03225806]\n", + " [ 0.11111111 0.08333333 1. ..., 0.2173913 0.19230769\n", + " 0.20833333]\n", + " ..., \n", + " [ 0.03703704 0.03333333 0.2173913 ..., 1. 0.88461538\n", + " 0.74074074]\n", + " [ 0.03333333 0.03030303 0.19230769 ..., 0.88461538 1. 0.85185185]\n", + " [ 0.03571429 0.03225806 0.20833333 ..., 0.74074074 0.85185185 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 16.886016\n", + "With standard deviation: 2.605194\n", + "\n", + " Mean performance on test set: 21.795626\n", + "With standard deviation: 5.522502\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 6.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 6 of size 185 built in 1.3330223560333252 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03333333 0.02857143\n", + " 0.03030303]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03030303 0.02631579\n", + " 0.02777778]\n", + " [ 0.11111111 0.08333333 1. ..., 0.19230769 0.16129032\n", + " 0.17241379]\n", + " ..., \n", + " [ 0.03333333 0.03030303 0.19230769 ..., 1. 0.83870968\n", + " 0.57142857]\n", + " [ 0.02857143 0.02631579 0.16129032 ..., 0.83870968 1. 0.71428571]\n", + " [ 0.03030303 0.02777778 0.17241379 ..., 0.57142857 0.71428571 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 13.109746\n", + "With standard deviation: 2.584308\n", + "\n", + " Mean performance on test set: 20.604920\n", + "With standard deviation: 5.499831\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 7.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 7 of size 185 built in 1.602663278579712 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03125 0.02564103\n", + " 0.02631579]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02857143 0.02380952\n", + " 0.02439024]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17857143 0.14285714\n", + " 0.14705882]\n", + " ..., \n", + " [ 0.03125 0.02857143 0.17857143 ..., 1. 0.8 0.47619048]\n", + " [ 0.02564103 0.02380952 0.14285714 ..., 0.8 1. 0.56818182]\n", + " [ 0.02631579 0.02439024 0.14705882 ..., 0.47619048 0.56818182 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 12.015210\n", + "With standard deviation: 2.592798\n", + "\n", + " Mean performance on test set: 20.347932\n", + "With standard deviation: 5.176314\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 8.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 8 of size 185 built in 1.8121819496154785 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02325581]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.02173913]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.12820513]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.41666667]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.49019608]\n", + " [ 0.02325581 0.02173913 0.12820513 ..., 0.41666667 0.49019608 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.798096\n", + "With standard deviation: 2.130816\n", + "\n", + " Mean performance on test set: 19.822797\n", + "With standard deviation: 5.137687\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 9.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 9 of size 185 built in 2.2172586917877197 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.0212766 ]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727 0.02 ]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11627907]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.38461538]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.45454545]\n", + " [ 0.0212766 0.02 0.11627907 ..., 0.38461538 0.45454545 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.799656\n", + "With standard deviation: 2.095494\n", + "\n", + " Mean performance on test set: 19.873364\n", + "With standard deviation: 5.103689\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 10.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 10 of size 185 built in 2.4100613594055176 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 11.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 11 of size 185 built in 2.7440149784088135 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 12.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 12 of size 185 built in 2.723442316055298 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 13.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 13 of size 185 built in 2.6163382530212402 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 14.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 14 of size 185 built in 2.629500389099121 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 15.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 15 of size 185 built in 2.664158821105957 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 16.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 16 of size 185 built in 2.7301340103149414 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 17.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 17 of size 185 built in 2.6328580379486084 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 18.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 18 of size 185 built in 2.592944383621216 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 19.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 19 of size 185 built in 2.6368520259857178 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 20.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 20 of size 185 built in 2.52734375 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- ---------\n", + " 0 41.6202 6.453 43.6169 2.13212 0.0904737\n", + " 1 38.8446 6.44648 40.8329 3.44147 0.175414\n", + " 2 35.2915 4.7813 35.7461 1.61134 0.344896\n", + " 3 29.4845 3.90351 28.4646 3.00137 0.553939\n", + " 4 22.6693 6.28053 19.2517 3.42893 0.770649\n", + " 5 21.7956 5.5225 16.886 2.60519 1.01558\n", + " 6 20.6049 5.49983 13.1097 2.58431 1.33302\n", + " 7 20.3479 5.17631 12.0152 2.5928 1.60266\n", + " 8 19.8228 5.13769 10.7981 2.13082 1.81218\n", + " 9 19.8734 5.10369 10.7997 2.09549 2.21726\n", + " 10 19.8708 5.09217 10.7787 2.10002 2.41006\n", + " 11 19.8708 5.09217 10.7787 2.10002 2.74401\n", + " 12 19.8708 5.09217 10.7787 2.10002 2.72344\n", + " 13 19.8708 5.09217 10.7787 2.10002 2.61634\n", + " 14 19.8708 5.09217 10.7787 2.10002 2.6295\n", + " 15 19.8708 5.09217 10.7787 2.10002 2.66416\n", + " 16 19.8708 5.09217 10.7787 2.10002 2.73013\n", + " 17 19.8708 5.09217 10.7787 2.10002 2.63286\n", + " 18 19.8708 5.09217 10.7787 2.10002 2.59294\n", + " 19 19.8708 5.09217 10.7787 2.10002 2.63685\n", + " 20 19.8708 5.09217 10.7787 2.10002 2.52734\n", + "\n", + " --- This is a regression problem ---\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 0.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 0 of size 185 built in 0.1027534008026123 seconds ---\n", + "[[ 1. 1. 0.33333333 ..., 0.33333333 0.33333333\n", + " 0.33333333]\n", + " [ 1. 1. 0.33333333 ..., 0.33333333 0.33333333\n", + " 0.33333333]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " ..., \n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 42.787136\n", + "With standard deviation: 0.675806\n", + "\n", + " Mean performance on test set: 42.645892\n", + "With standard deviation: 6.560629\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 1.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 1 of size 185 built in 0.18301701545715332 seconds ---\n", + "[[ 1. 0.8 0.14285714 ..., 0.125 0.125 0.125 ]\n", + " [ 0.8 1. 0.125 ..., 0.11111111 0.11111111\n", + " 0.11111111]\n", + " [ 0.14285714 0.125 1. ..., 0.8 0.8 0.8 ]\n", + " ..., \n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]\n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]\n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 38.880117\n", + "With standard deviation: 0.623999\n", + "\n", + " Mean performance on test set: 39.174317\n", + "With standard deviation: 6.195371\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 2.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 2 of size 185 built in 0.33235955238342285 seconds ---\n", + "[[ 1. 0.5 0.11111111 ..., 0.07692308 0.07692308\n", + " 0.07692308]\n", + " [ 0.5 1. 0.09090909 ..., 0.06666667 0.06666667\n", + " 0.06666667]\n", + " [ 0.11111111 0.09090909 1. ..., 0.55555556 0.55555556\n", + " 0.55555556]\n", + " ..., \n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]\n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]\n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 35.348332\n", + "With standard deviation: 0.727833\n", + "\n", + " Mean performance on test set: 35.604226\n", + "With standard deviation: 4.539211\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 3.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 3 of size 185 built in 0.5400393009185791 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.05555556 0.05555556\n", + " 0.05555556]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.04761905 0.04761905\n", + " 0.04761905]\n", + " [ 0.11111111 0.08333333 1. ..., 0.35714286 0.35714286\n", + " 0.35714286]\n", + " ..., \n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 28.047646\n", + "With standard deviation: 1.077805\n", + "\n", + " Mean performance on test set: 30.192177\n", + "With standard deviation: 5.110324\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 4.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 4 of size 185 built in 0.8054666519165039 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.04347826 0.04166667\n", + " 0.04347826]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03846154 0.03703704\n", + " 0.03846154]\n", + " [ 0.11111111 0.08333333 1. ..., 0.26315789 0.25 0.26315789]\n", + " ..., \n", + " [ 0.04347826 0.03846154 0.26315789 ..., 1. 0.95 0.9 ]\n", + " [ 0.04166667 0.03703704 0.25 ..., 0.95 1. 0.95 ]\n", + " [ 0.04347826 0.03846154 0.26315789 ..., 0.9 0.95 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Mean performance on train set: 18.878595\n", + "With standard deviation: 1.711897\n", + "\n", + " Mean performance on test set: 23.751530\n", + "With standard deviation: 7.808559\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 5.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 5 of size 185 built in 1.0195980072021484 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03703704 0.03333333\n", + " 0.03571429]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03333333 0.03030303\n", + " 0.03225806]\n", + " [ 0.11111111 0.08333333 1. ..., 0.2173913 0.19230769\n", + " 0.20833333]\n", + " ..., \n", + " [ 0.03703704 0.03333333 0.2173913 ..., 1. 0.88461538\n", + " 0.74074074]\n", + " [ 0.03333333 0.03030303 0.19230769 ..., 0.88461538 1. 0.85185185]\n", + " [ 0.03571429 0.03225806 0.20833333 ..., 0.74074074 0.85185185 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 16.339135\n", + "With standard deviation: 1.397693\n", + "\n", + " Mean performance on test set: 23.482309\n", + "With standard deviation: 7.727117\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 6.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 6 of size 185 built in 1.2962956428527832 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03333333 0.02857143\n", + " 0.03030303]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03030303 0.02631579\n", + " 0.02777778]\n", + " [ 0.11111111 0.08333333 1. ..., 0.19230769 0.16129032\n", + " 0.17241379]\n", + " ..., \n", + " [ 0.03333333 0.03030303 0.19230769 ..., 1. 0.83870968\n", + " 0.57142857]\n", + " [ 0.02857143 0.02631579 0.16129032 ..., 0.83870968 1. 0.71428571]\n", + " [ 0.03030303 0.02777778 0.17241379 ..., 0.57142857 0.71428571 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 12.523830\n", + "With standard deviation: 1.040404\n", + "\n", + " Mean performance on test set: 22.745367\n", + "With standard deviation: 8.028051\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 7.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 7 of size 185 built in 1.5462064743041992 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03125 0.02564103\n", + " 0.02631579]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02857143 0.02380952\n", + " 0.02439024]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17857143 0.14285714\n", + " 0.14705882]\n", + " ..., \n", + " [ 0.03125 0.02857143 0.17857143 ..., 1. 0.8 0.47619048]\n", + " [ 0.02564103 0.02380952 0.14285714 ..., 0.8 1. 0.56818182]\n", + " [ 0.02631579 0.02439024 0.14705882 ..., 0.47619048 0.56818182 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 11.371668\n", + "With standard deviation: 0.925446\n", + "\n", + " Mean performance on test set: 22.831602\n", + "With standard deviation: 7.978369\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 8.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 8 of size 185 built in 1.8658208847045898 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02325581]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.02173913]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.12820513]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.41666667]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.49019608]\n", + " [ 0.02325581 0.02173913 0.12820513 ..., 0.41666667 0.49019608 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.132106\n", + "With standard deviation: 0.525580\n", + "\n", + " Mean performance on test set: 22.586071\n", + "With standard deviation: 8.067887\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 9.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 9 of size 185 built in 2.185042381286621 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.0212766 ]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727 0.02 ]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11627907]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.38461538]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.45454545]\n", + " [ 0.0212766 0.02 0.11627907 ..., 0.38461538 0.45454545 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.078464\n", + "With standard deviation: 0.518149\n", + "\n", + " Mean performance on test set: 22.766801\n", + "With standard deviation: 8.005709\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 10.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 10 of size 185 built in 2.35276198387146 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 11.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 11 of size 185 built in 2.6274359226226807 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 12.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 12 of size 185 built in 2.7209105491638184 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 13.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 13 of size 185 built in 2.699059247970581 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 14.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 14 of size 185 built in 2.6328344345092773 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 15.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 15 of size 185 built in 2.6556999683380127 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 16.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 16 of size 185 built in 2.621814012527466 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 17.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 17 of size 185 built in 2.5938243865966797 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 18.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 18 of size 185 built in 2.65336275100708 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 19.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 19 of size 185 built in 2.628486156463623 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 20.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 20 of size 185 built in 2.682689666748047 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 42.6459 6.56063 42.7871 0.675806 0.102753\n", + " 1 39.1743 6.19537 38.8801 0.623999 0.183017\n", + " 2 35.6042 4.53921 35.3483 0.727833 0.33236\n", + " 3 30.1922 5.11032 28.0476 1.0778 0.540039\n", + " 4 23.7515 7.80856 18.8786 1.7119 0.805467\n", + " 5 23.4823 7.72712 16.3391 1.39769 1.0196\n", + " 6 22.7454 8.02805 12.5238 1.0404 1.2963\n", + " 7 22.8316 7.97837 11.3717 0.925446 1.54621\n", + " 8 22.5861 8.06789 10.1321 0.52558 1.86582\n", + " 9 22.7668 8.00571 10.0785 0.518149 2.18504\n", + " 10 22.8697 7.94456 10.0756 0.67282 2.35276\n", + " 11 22.8697 7.94456 10.0756 0.67282 2.62744\n", + " 12 22.8697 7.94456 10.0756 0.67282 2.72091\n", + " 13 22.8697 7.94456 10.0756 0.67282 2.69906\n", + " 14 22.8697 7.94456 10.0756 0.67282 2.63283\n", + " 15 22.8697 7.94456 10.0756 0.67282 2.6557\n", + " 16 22.8697 7.94456 10.0756 0.67282 2.62181\n", + " 17 22.8697 7.94456 10.0756 0.67282 2.59382\n", + " 18 22.8697 7.94456 10.0756 0.67282 2.65336\n", + " 19 22.8697 7.94456 10.0756 0.67282 2.62849\n", + " 20 22.8697 7.94456 10.0756 0.67282 2.68269\n", + "\n", + " --- This is a regression problem ---\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 0.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 0 of size 185 built in 0.3893899917602539 seconds ---\n", + "[[ 1. 0.75 0.5 ..., 0.16666667 0.16666667\n", + " 0.16666667]\n", + " [ 0.75 1. 0.4 ..., 0.15384615 0.15384615\n", + " 0.15384615]\n", + " [ 0.5 0.4 1. ..., 0.27272727 0.27272727\n", + " 0.27272727]\n", + " ..., \n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]\n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]\n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 12.207923\n", + "With standard deviation: 0.700182\n", + "\n", + " Mean performance on test set: 12.682718\n", + "With standard deviation: 2.748815\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 1.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 1 of size 185 built in 0.4729621410369873 seconds ---\n", + "[[ 1. 0.7 0.16666667 ..., 0.05555556 0.05555556\n", + " 0.05555556]\n", + " [ 0.7 1. 0.13333333 ..., 0.05128205 0.05128205\n", + " 0.05128205]\n", + " [ 0.16666667 0.13333333 1. ..., 0.22580645 0.22580645\n", + " 0.22580645]\n", + " ..., \n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.279220\n", + "With standard deviation: 0.914688\n", + "\n", + " Mean performance on test set: 12.609828\n", + "With standard deviation: 2.372778\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 2.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 2 of size 185 built in 0.576836109161377 seconds ---\n", + "[[ 1. 0.4375 0.125 ..., 0.03333333 0.03333333\n", + " 0.03571429]\n", + " [ 0.4375 1. 0.0952381 ..., 0.03076923 0.03076923\n", + " 0.03278689]\n", + " [ 0.125 0.0952381 1. ..., 0.16981132 0.16981132\n", + " 0.18367347]\n", + " ..., \n", + " [ 0.03333333 0.03076923 0.16981132 ..., 1. 1. 0.9245283 ]\n", + " [ 0.03333333 0.03076923 0.16981132 ..., 1. 1. 0.9245283 ]\n", + " [ 0.03571429 0.03278689 0.18367347 ..., 0.9245283 0.9245283 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 2.588811\n", + "With standard deviation: 0.557162\n", + "\n", + " Mean performance on test set: 8.060609\n", + "With standard deviation: 2.470450\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 3.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 3 of size 185 built in 0.7169125080108643 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.02631579 0.02631579\n", + " 0.02777778]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.02409639 0.02409639\n", + " 0.02531646]\n", + " [ 0.125 0.08695652 1. ..., 0.13043478 0.13043478\n", + " 0.13846154]\n", + " ..., \n", + " [ 0.02631579 0.02409639 0.13043478 ..., 1. 0.94366197\n", + " 0.83561644]\n", + " [ 0.02631579 0.02409639 0.13043478 ..., 0.94366197 1. 0.78666667]\n", + " [ 0.02777778 0.02531646 0.13846154 ..., 0.83561644 0.78666667 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.272670\n", + "With standard deviation: 0.760432\n", + "\n", + " Mean performance on test set: 9.755135\n", + "With standard deviation: 3.049170\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 4.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 4 of size 185 built in 0.8342421054840088 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.02222222 0.02222222\n", + " 0.02325581]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.02061856 0.02061856\n", + " 0.02150538]\n", + " [ 0.125 0.08695652 1. ..., 0.10843373 0.10843373\n", + " 0.11392405]\n", + " ..., \n", + " [ 0.02222222 0.02061856 0.10843373 ..., 1. 0.82417582\n", + " 0.67010309]\n", + " [ 0.02222222 0.02061856 0.10843373 ..., 0.82417582 1. 0.70526316]\n", + " [ 0.02325581 0.02150538 0.11392405 ..., 0.67010309 0.70526316 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.032293\n", + "With standard deviation: 0.728380\n", + "\n", + " Mean performance on test set: 10.319167\n", + "With standard deviation: 3.616673\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 5.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 5 of size 185 built in 0.9938209056854248 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01960784 0.01960784\n", + " 0.02040816]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01834862 0.01834862\n", + " 0.01904762]\n", + " [ 0.125 0.08695652 1. ..., 0.09473684 0.09473684\n", + " 0.0989011 ]\n", + " ..., \n", + " [ 0.01960784 0.01834862 0.09473684 ..., 1. 0.74311927\n", + " 0.56302521]\n", + " [ 0.01960784 0.01834862 0.09473684 ..., 0.74311927 1. 0.6173913 ]\n", + " [ 0.02040816 0.01904762 0.0989011 ..., 0.56302521 0.6173913 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 0.923543\n", + "With standard deviation: 0.660532\n", + "\n", + " Mean performance on test set: 10.659250\n", + "With standard deviation: 4.120523\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 6.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 6 of size 185 built in 1.1753439903259277 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01785714 0.01785714\n", + " 0.01851852]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01680672 0.01680672\n", + " 0.0173913 ]\n", + " [ 0.125 0.08695652 1. ..., 0.08571429 0.08571429\n", + " 0.08910891]\n", + " ..., \n", + " [ 0.01785714 0.01680672 0.08571429 ..., 1. 0.68 0.48201439]\n", + " [ 0.01785714 0.01680672 0.08571429 ..., 0.68 1. 0.54887218]\n", + " [ 0.01851852 0.0173913 0.08910891 ..., 0.48201439 0.54887218 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 0.878589\n", + "With standard deviation: 0.603598\n", + "\n", + " Mean performance on test set: 11.102521\n", + "With standard deviation: 4.330554\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 7.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 7 of size 185 built in 1.4358420372009277 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01666667 0.01666667\n", + " 0.01724138]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01574803 0.01574803\n", + " 0.01626016]\n", + " [ 0.125 0.08695652 1. ..., 0.07964602 0.07964602\n", + " 0.08256881]\n", + " ..., \n", + " [ 0.01666667 0.01574803 0.07964602 ..., 1. 0.64963504\n", + " 0.43225806]\n", + " [ 0.01666667 0.01574803 0.07964602 ..., 0.64963504 1. 0.48993289]\n", + " [ 0.01724138 0.01626016 0.08256881 ..., 0.43225806 0.48993289 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 0.944049\n", + "With standard deviation: 0.694844\n", + "\n", + " Mean performance on test set: 11.352962\n", + "With standard deviation: 4.305459\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 8.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 8 of size 185 built in 1.7005987167358398 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625\n", + " 0.01639344]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01550388]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07826087]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.3964497 ]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.44785276]\n", + " [ 0.01639344 0.01550388 0.07826087 ..., 0.3964497 0.44785276 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.033979\n", + "With standard deviation: 0.775622\n", + "\n", + " Mean performance on test set: 11.298981\n", + "With standard deviation: 4.349648\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 9.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 9 of size 185 built in 2.0194287300109863 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625\n", + " 0.01587302]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01503759]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07563025]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.38728324]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.43712575]\n", + " [ 0.01587302 0.01503759 0.07563025 ..., 0.38728324 0.43712575 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.003187\n", + "With standard deviation: 0.572070\n", + "\n", + " Mean performance on test set: 11.332669\n", + "With standard deviation: 4.324120\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 10.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 10 of size 185 built in 2.243326187133789 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625 0.015625 ]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01481481]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07438017]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.38285714]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.43195266]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.38285714 0.43195266 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.002272\n", + "With standard deviation: 0.570937\n", + "\n", + " Mean performance on test set: 11.343515\n", + "With standard deviation: 4.327265\n", + "\n", + "\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 12.6827 2.74882 12.2079 0.700182 0.38939\n", + " 1 12.6098 2.37278 10.2792 0.914688 0.472962\n", + " 2 8.06061 2.47045 2.58881 0.557162 0.576836\n", + " 3 9.75514 3.04917 1.27267 0.760432 0.716913\n", + " 4 10.3192 3.61667 1.03229 0.72838 0.834242\n", + " 5 10.6593 4.12052 0.923543 0.660532 0.993821\n", + " 6 11.1025 4.33055 0.878589 0.603598 1.17534\n", + " 7 11.353 4.30546 0.944049 0.694844 1.43584\n", + " 8 11.299 4.34965 1.03398 0.775622 1.7006\n", + " 9 11.3327 4.32412 1.00319 0.57207 2.01943\n", + " 10 11.3435 4.32726 1.00227 0.570937 2.24333\n", + "\n", + " --- This is a regression problem ---\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 0.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 0 of size 185 built in 0.3775763511657715 seconds ---\n", + "[[ 1. 0.75 0.5 ..., 0.16666667 0.16666667\n", + " 0.16666667]\n", + " [ 0.75 1. 0.4 ..., 0.15384615 0.15384615\n", + " 0.15384615]\n", + " [ 0.5 0.4 1. ..., 0.27272727 0.27272727\n", + " 0.27272727]\n", + " ..., \n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]\n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]\n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 12.120872\n", + "With standard deviation: 0.500467\n", + "\n", + " Mean performance on test set: 12.579966\n", + "With standard deviation: 2.732346\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 1.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 1 of size 185 built in 0.4563324451446533 seconds ---\n", + "[[ 1. 0.7 0.16666667 ..., 0.05555556 0.05555556\n", + " 0.05555556]\n", + " [ 0.7 1. 0.13333333 ..., 0.05128205 0.05128205\n", + " 0.05128205]\n", + " [ 0.16666667 0.13333333 1. ..., 0.22580645 0.22580645\n", + " 0.22580645]\n", + " ..., \n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.224322\n", + "With standard deviation: 0.734261\n", + "\n", + " Mean performance on test set: 12.621509\n", + "With standard deviation: 2.188664\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 2.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 2 of size 185 built in 0.5852782726287842 seconds ---\n", + "[[ 1. 0.4375 0.125 ..., 0.03333333 0.03333333\n", + " 0.03571429]\n", + " [ 0.4375 1. 0.0952381 ..., 0.03076923 0.03076923\n", + " 0.03278689]\n", + " [ 0.125 0.0952381 1. ..., 0.16981132 0.16981132\n", + " 0.18367347]\n", + " ..., \n", + " [ 0.03333333 0.03076923 0.16981132 ..., 1. 1. 0.9245283 ]\n", + " [ 0.03333333 0.03076923 0.16981132 ..., 1. 1. 0.9245283 ]\n", + " [ 0.03571429 0.03278689 0.18367347 ..., 0.9245283 0.9245283 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 2.718851\n", + "With standard deviation: 0.732922\n", + "\n", + " Mean performance on test set: 7.429032\n", + "With standard deviation: 2.693953\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 3.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 3 of size 185 built in 0.7065560817718506 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.02631579 0.02631579\n", + " 0.02777778]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.02409639 0.02409639\n", + " 0.02531646]\n", + " [ 0.125 0.08695652 1. ..., 0.13043478 0.13043478\n", + " 0.13846154]\n", + " ..., \n", + " [ 0.02631579 0.02409639 0.13043478 ..., 1. 0.94366197\n", + " 0.83561644]\n", + " [ 0.02631579 0.02409639 0.13043478 ..., 0.94366197 1. 0.78666667]\n", + " [ 0.02777778 0.02531646 0.13846154 ..., 0.83561644 0.78666667 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.540000\n", + "With standard deviation: 1.138134\n", + "\n", + " Mean performance on test set: 9.024680\n", + "With standard deviation: 2.508084\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 4.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 4 of size 185 built in 0.8479568958282471 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.02222222 0.02222222\n", + " 0.02325581]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.02061856 0.02061856\n", + " 0.02150538]\n", + " [ 0.125 0.08695652 1. ..., 0.10843373 0.10843373\n", + " 0.11392405]\n", + " ..., \n", + " [ 0.02222222 0.02061856 0.10843373 ..., 1. 0.82417582\n", + " 0.67010309]\n", + " [ 0.02222222 0.02061856 0.10843373 ..., 0.82417582 1. 0.70526316]\n", + " [ 0.02325581 0.02150538 0.11392405 ..., 0.67010309 0.70526316 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.360291\n", + "With standard deviation: 1.423990\n", + "\n", + " Mean performance on test set: 10.081112\n", + "With standard deviation: 3.647700\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 5.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 5 of size 185 built in 1.0008597373962402 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01960784 0.01960784\n", + " 0.02040816]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01834862 0.01834862\n", + " 0.01904762]\n", + " [ 0.125 0.08695652 1. ..., 0.09473684 0.09473684\n", + " 0.0989011 ]\n", + " ..., \n", + " [ 0.01960784 0.01834862 0.09473684 ..., 1. 0.74311927\n", + " 0.56302521]\n", + " [ 0.01960784 0.01834862 0.09473684 ..., 0.74311927 1. 0.6173913 ]\n", + " [ 0.02040816 0.01904762 0.0989011 ..., 0.56302521 0.6173913 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.085175\n", + "With standard deviation: 1.062063\n", + "\n", + " Mean performance on test set: 11.300476\n", + "With standard deviation: 4.441634\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 6.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 6 of size 185 built in 1.1979196071624756 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01785714 0.01785714\n", + " 0.01851852]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01680672 0.01680672\n", + " 0.0173913 ]\n", + " [ 0.125 0.08695652 1. ..., 0.08571429 0.08571429\n", + " 0.08910891]\n", + " ..., \n", + " [ 0.01785714 0.01680672 0.08571429 ..., 1. 0.68 0.48201439]\n", + " [ 0.01785714 0.01680672 0.08571429 ..., 0.68 1. 0.54887218]\n", + " [ 0.01851852 0.0173913 0.08910891 ..., 0.48201439 0.54887218 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.064431\n", + "With standard deviation: 1.001911\n", + "\n", + " Mean performance on test set: 12.186014\n", + "With standard deviation: 4.888158\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 7.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 7 of size 185 built in 1.4372029304504395 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01666667 0.01666667\n", + " 0.01724138]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01574803 0.01574803\n", + " 0.01626016]\n", + " [ 0.125 0.08695652 1. ..., 0.07964602 0.07964602\n", + " 0.08256881]\n", + " ..., \n", + " [ 0.01666667 0.01574803 0.07964602 ..., 1. 0.64963504\n", + " 0.43225806]\n", + " [ 0.01666667 0.01574803 0.07964602 ..., 0.64963504 1. 0.48993289]\n", + " [ 0.01724138 0.01626016 0.08256881 ..., 0.43225806 0.48993289 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.199119\n", + "With standard deviation: 1.340313\n", + "\n", + " Mean performance on test set: 12.753387\n", + "With standard deviation: 5.145288\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 8.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 8 of size 185 built in 1.68448805809021 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625\n", + " 0.01639344]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01550388]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07826087]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.3964497 ]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.44785276]\n", + " [ 0.01639344 0.01550388 0.07826087 ..., 0.3964497 0.44785276 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.358221\n", + "With standard deviation: 1.843147\n", + "\n", + " Mean performance on test set: 13.047098\n", + "With standard deviation: 5.271835\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 9.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 9 of size 185 built in 1.9654510021209717 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625\n", + " 0.01587302]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01503759]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07563025]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.38728324]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.43712575]\n", + " [ 0.01587302 0.01503759 0.07563025 ..., 0.38728324 0.43712575 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.360024\n", + "With standard deviation: 1.848342\n", + "\n", + " Mean performance on test set: 13.178933\n", + "With standard deviation: 5.277067\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 10.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 10 of size 185 built in 2.2494258880615234 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625 0.015625 ]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01481481]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07438017]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.38285714]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.43195266]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.38285714 0.43195266 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.362078\n", + "With standard deviation: 1.854262\n", + "\n", + " Mean performance on test set: 13.253773\n", + "With standard deviation: 5.264247\n", + "\n", + "\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 12.58 2.73235 12.1209 0.500467 0.377576\n", + " 1 12.6215 2.18866 10.2243 0.734261 0.456332\n", + " 2 7.42903 2.69395 2.71885 0.732922 0.585278\n", + " 3 9.02468 2.50808 1.54 1.13813 0.706556\n", + " 4 10.0811 3.6477 1.36029 1.42399 0.847957\n", + " 5 11.3005 4.44163 1.08518 1.06206 1.00086\n", + " 6 12.186 4.88816 1.06443 1.00191 1.19792\n", + " 7 12.7534 5.14529 1.19912 1.34031 1.4372\n", + " 8 13.0471 5.27184 1.35822 1.84315 1.68449\n", + " 9 13.1789 5.27707 1.36002 1.84834 1.96545\n", + " 10 13.2538 5.26425 1.36208 1.85426 2.24943\n" + ] + } + ], + "source": [ + "%load_ext line_profiler\n", + "\n", + "import sys\n", + "sys.path.insert(0, \"../\")\n", + "from pygraph.utils.utils import kernel_train_test\n", + "from pygraph.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)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# results\n", + "\n", + "# kernel Tanimoto with y normalization\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- ---------\n", + " 0 41.6202 6.453 43.6169 2.13212 0.0904737\n", + " 1 38.8446 6.44648 40.8329 3.44147 0.175414\n", + " 2 35.2915 4.7813 35.7461 1.61134 0.344896\n", + " 3 29.4845 3.90351 28.4646 3.00137 0.553939\n", + " 4 22.6693 6.28053 19.2517 3.42893 0.770649\n", + " 5 21.7956 5.5225 16.886 2.60519 1.01558\n", + " 6 20.6049 5.49983 13.1097 2.58431 1.33302\n", + " 7 20.3479 5.17631 12.0152 2.5928 1.60266\n", + " 8 19.8228 5.13769 10.7981 2.13082 1.81218\n", + " 9 19.8734 5.10369 10.7997 2.09549 2.21726\n", + " 10 19.8708 5.09217 10.7787 2.10002 2.41006\n", + " 11 19.8708 5.09217 10.7787 2.10002 2.74401\n", + " 12 19.8708 5.09217 10.7787 2.10002 2.72344\n", + " 13 19.8708 5.09217 10.7787 2.10002 2.61634\n", + " 14 19.8708 5.09217 10.7787 2.10002 2.6295\n", + " 15 19.8708 5.09217 10.7787 2.10002 2.66416\n", + " 16 19.8708 5.09217 10.7787 2.10002 2.73013\n", + " 17 19.8708 5.09217 10.7787 2.10002 2.63286\n", + " 18 19.8708 5.09217 10.7787 2.10002 2.59294\n", + " 19 19.8708 5.09217 10.7787 2.10002 2.63685\n", + " 20 19.8708 5.09217 10.7787 2.10002 2.52734\n", + "\n", + "# kernel Tanimoto without y normalization\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 42.6459 6.56063 42.7871 0.675806 0.102753\n", + " 1 39.1743 6.19537 38.8801 0.623999 0.183017\n", + " 2 35.6042 4.53921 35.3483 0.727833 0.33236\n", + " 3 30.1922 5.11032 28.0476 1.0778 0.540039\n", + " 4 23.7515 7.80856 18.8786 1.7119 0.805467\n", + " 5 23.4823 7.72712 16.3391 1.39769 1.0196\n", + " 6 22.7454 8.02805 12.5238 1.0404 1.2963\n", + " 7 22.8316 7.97837 11.3717 0.925446 1.54621\n", + " 8 22.5861 8.06789 10.1321 0.52558 1.86582\n", + " 9 22.7668 8.00571 10.0785 0.518149 2.18504\n", + " 10 22.8697 7.94456 10.0756 0.67282 2.35276\n", + " 11 22.8697 7.94456 10.0756 0.67282 2.62744\n", + " 12 22.8697 7.94456 10.0756 0.67282 2.72091\n", + " 13 22.8697 7.94456 10.0756 0.67282 2.69906\n", + " 14 22.8697 7.94456 10.0756 0.67282 2.63283\n", + " 15 22.8697 7.94456 10.0756 0.67282 2.6557\n", + " 16 22.8697 7.94456 10.0756 0.67282 2.62181\n", + " 17 22.8697 7.94456 10.0756 0.67282 2.59382\n", + " 18 22.8697 7.94456 10.0756 0.67282 2.65336\n", + " 19 22.8697 7.94456 10.0756 0.67282 2.62849\n", + " 20 22.8697 7.94456 10.0756 0.67282 2.68269\n", + " \n", + "# kernel MinMax with y normalization \n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 12.6827 2.74882 12.2079 0.700182 0.38939\n", + " 1 12.6098 2.37278 10.2792 0.914688 0.472962\n", + " 2 8.06061 2.47045 2.58881 0.557162 0.576836\n", + " 3 9.75514 3.04917 1.27267 0.760432 0.716913\n", + " 4 10.3192 3.61667 1.03229 0.72838 0.834242\n", + " 5 10.6593 4.12052 0.923543 0.660532 0.993821\n", + " 6 11.1025 4.33055 0.878589 0.603598 1.17534\n", + " 7 11.353 4.30546 0.944049 0.694844 1.43584\n", + " 8 11.299 4.34965 1.03398 0.775622 1.7006\n", + " 9 11.3327 4.32412 1.00319 0.57207 2.01943\n", + " 10 11.3435 4.32726 1.00227 0.570937 2.24333\n", + "\n", + "# kernel MinMax without y normalization\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 12.58 2.73235 12.1209 0.500467 0.377576\n", + " 1 12.6215 2.18866 10.2243 0.734261 0.456332\n", + " 2 7.42903 2.69395 2.71885 0.732922 0.585278\n", + " 3 9.02468 2.50808 1.54 1.13813 0.706556\n", + " 4 10.0811 3.6477 1.36029 1.42399 0.847957\n", + " 5 11.3005 4.44163 1.08518 1.06206 1.00086\n", + " 6 12.186 4.88816 1.06443 1.00191 1.19792\n", + " 7 12.7534 5.14529 1.19912 1.34031 1.4372\n", + " 8 13.0471 5.27184 1.35822 1.84315 1.68449\n", + " 9 13.1789 5.27707 1.36002 1.84834 1.96545\n", + " 10 13.2538 5.26425 1.36208 1.85426 2.24943" + ] + } + ], + "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.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/notebooks/run_treeletkernel_acyclic.ipynb b/notebooks/run_treeletkernel_acyclic.ipynb index c25eb36..41ee8d3 100644 --- a/notebooks/run_treeletkernel_acyclic.ipynb +++ b/notebooks/run_treeletkernel_acyclic.ipynb @@ -2,23 +2,24 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + "The line_profiler extension is already loaded. To reload it, use:\n", + " %reload_ext line_profiler\n", "\n", " --- This is a regression problem ---\n", "\n", "\n", - "\n", " Loading dataset from file...\n", "\n", " Calculating kernel matrix, this could take a while...\n", "\n", - " --- treelet kernel matrix of size 185 built in 50.925347328186035 seconds ---\n", + " --- treelet kernel matrix of size 185 built in 0.48417091369628906 seconds ---\n", "[[ 4.00000000e+00 2.60653066e+00 1.00000000e+00 ..., 1.26641655e-14\n", " 1.26641655e-14 1.26641655e-14]\n", " [ 2.60653066e+00 6.00000000e+00 1.00000000e+00 ..., 1.26641655e-14\n", @@ -42,19 +43,18 @@ "With standard deviation: 5.035844\n", "\n", "\n", - " RMSE_test std_test RMSE_train std_train k_time\n", + " rmse_test std_test rmse_train std_train k_time\n", "----------- ---------- ------------ ----------- --------\n", - " 10.0997 5.03584 2.68803 1.54162 50.9253\n", + " 10.0997 5.03584 2.68803 1.54162 0.484171\n", "\n", " --- This is a regression problem ---\n", "\n", "\n", - "\n", " Loading dataset from file...\n", "\n", " Calculating kernel matrix, this could take a while...\n", "\n", - " --- treelet kernel matrix of size 185 built in 49.581383228302 seconds ---\n", + " --- treelet kernel matrix of size 185 built in 0.5003015995025635 seconds ---\n", "[[ 4.00000000e+00 2.60653066e+00 1.00000000e+00 ..., 1.26641655e-14\n", " 1.26641655e-14 1.26641655e-14]\n", " [ 2.60653066e+00 6.00000000e+00 1.00000000e+00 ..., 1.26641655e-14\n", @@ -78,9 +78,9 @@ "With standard deviation: 3.378376\n", "\n", "\n", - " RMSE_test std_test RMSE_train std_train k_time\n", + " rmse_test std_test rmse_train std_train k_time\n", "----------- ---------- ------------ ----------- --------\n", - " 8.3079 3.37838 2.90887 1.2679 49.5814\n" + " 8.3079 3.37838 2.90887 1.2679 0.500302\n" ] } ], @@ -97,7 +97,7 @@ "\n", "kernel_para = dict(node_label = 'atom', edge_label = 'bond_type', labeled = True)\n", "\n", - "# kernel_train_test(datafile, kernel_file_path, treeletkernel, kernel_para, normalize = False)\n", + "kernel_train_test(datafile, kernel_file_path, treeletkernel, kernel_para, normalize = False)\n", "\n", "kernel_train_test(datafile, kernel_file_path, treeletkernel, kernel_para, normalize = True)\n", "\n", @@ -116,12 +116,12 @@ "# with y normalization\n", " RMSE_test std_test RMSE_train std_train k_time\n", "----------- ---------- ------------ ----------- --------\n", - " 8.3079 3.37838 2.90887 1.2679 49.5814\n", + " 8.3079 3.37838 2.90887 1.2679 0.500302\n", "\n", "# without y normalization\n", " RMSE_test std_test RMSE_train std_train k_time\n", "----------- ---------- ------------ ----------- --------\n", - " 10.0997 5.03584 2.68803 1.54162 50.9253" + " 10.0997 5.03584 2.68803 1.54162 0.484171" ] }, { diff --git a/notebooks/run_untildpathkernel_acyclic.ipynb b/notebooks/run_untildpathkernel_acyclic.ipynb new file mode 100644 index 0000000..fd3692e --- /dev/null +++ b/notebooks/run_untildpathkernel_acyclic.ipynb @@ -0,0 +1,2051 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- This is a regression problem ---\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 0.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 0 of size 185 built in 0.09047365188598633 seconds ---\n", + "[[ 1. 1. 0.33333333 ..., 0.33333333 0.33333333\n", + " 0.33333333]\n", + " [ 1. 1. 0.33333333 ..., 0.33333333 0.33333333\n", + " 0.33333333]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " ..., \n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 43.616902\n", + "With standard deviation: 2.132120\n", + "\n", + " Mean performance on test set: 41.620214\n", + "With standard deviation: 6.453003\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 1.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 1 of size 185 built in 0.1754138469696045 seconds ---\n", + "[[ 1. 0.8 0.14285714 ..., 0.125 0.125 0.125 ]\n", + " [ 0.8 1. 0.125 ..., 0.11111111 0.11111111\n", + " 0.11111111]\n", + " [ 0.14285714 0.125 1. ..., 0.8 0.8 0.8 ]\n", + " ..., \n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]\n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]\n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 40.832861\n", + "With standard deviation: 3.441465\n", + "\n", + " Mean performance on test set: 38.844613\n", + "With standard deviation: 6.446482\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 2.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 2 of size 185 built in 0.3448960781097412 seconds ---\n", + "[[ 1. 0.5 0.11111111 ..., 0.07692308 0.07692308\n", + " 0.07692308]\n", + " [ 0.5 1. 0.09090909 ..., 0.06666667 0.06666667\n", + " 0.06666667]\n", + " [ 0.11111111 0.09090909 1. ..., 0.55555556 0.55555556\n", + " 0.55555556]\n", + " ..., \n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]\n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]\n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 35.746142\n", + "With standard deviation: 1.611340\n", + "\n", + " Mean performance on test set: 35.291451\n", + "With standard deviation: 4.781298\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 3.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 3 of size 185 built in 0.5539388656616211 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.05555556 0.05555556\n", + " 0.05555556]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.04761905 0.04761905\n", + " 0.04761905]\n", + " [ 0.11111111 0.08333333 1. ..., 0.35714286 0.35714286\n", + " 0.35714286]\n", + " ..., \n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 28.464581\n", + "With standard deviation: 3.001371\n", + "\n", + " Mean performance on test set: 29.484499\n", + "With standard deviation: 3.903507\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 4.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 4 of size 185 built in 0.7706489562988281 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.04347826 0.04166667\n", + " 0.04347826]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03846154 0.03703704\n", + " 0.03846154]\n", + " [ 0.11111111 0.08333333 1. ..., 0.26315789 0.25 0.26315789]\n", + " ..., \n", + " [ 0.04347826 0.03846154 0.26315789 ..., 1. 0.95 0.9 ]\n", + " [ 0.04166667 0.03703704 0.25 ..., 0.95 1. 0.95 ]\n", + " [ 0.04347826 0.03846154 0.26315789 ..., 0.9 0.95 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 19.251747\n", + "With standard deviation: 3.428930\n", + "\n", + " Mean performance on test set: 22.669312\n", + "With standard deviation: 6.280526\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 5.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 5 of size 185 built in 1.015580415725708 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03703704 0.03333333\n", + " 0.03571429]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03333333 0.03030303\n", + " 0.03225806]\n", + " [ 0.11111111 0.08333333 1. ..., 0.2173913 0.19230769\n", + " 0.20833333]\n", + " ..., \n", + " [ 0.03703704 0.03333333 0.2173913 ..., 1. 0.88461538\n", + " 0.74074074]\n", + " [ 0.03333333 0.03030303 0.19230769 ..., 0.88461538 1. 0.85185185]\n", + " [ 0.03571429 0.03225806 0.20833333 ..., 0.74074074 0.85185185 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 16.886016\n", + "With standard deviation: 2.605194\n", + "\n", + " Mean performance on test set: 21.795626\n", + "With standard deviation: 5.522502\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 6.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 6 of size 185 built in 1.3330223560333252 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03333333 0.02857143\n", + " 0.03030303]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03030303 0.02631579\n", + " 0.02777778]\n", + " [ 0.11111111 0.08333333 1. ..., 0.19230769 0.16129032\n", + " 0.17241379]\n", + " ..., \n", + " [ 0.03333333 0.03030303 0.19230769 ..., 1. 0.83870968\n", + " 0.57142857]\n", + " [ 0.02857143 0.02631579 0.16129032 ..., 0.83870968 1. 0.71428571]\n", + " [ 0.03030303 0.02777778 0.17241379 ..., 0.57142857 0.71428571 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 13.109746\n", + "With standard deviation: 2.584308\n", + "\n", + " Mean performance on test set: 20.604920\n", + "With standard deviation: 5.499831\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 7.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 7 of size 185 built in 1.602663278579712 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03125 0.02564103\n", + " 0.02631579]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02857143 0.02380952\n", + " 0.02439024]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17857143 0.14285714\n", + " 0.14705882]\n", + " ..., \n", + " [ 0.03125 0.02857143 0.17857143 ..., 1. 0.8 0.47619048]\n", + " [ 0.02564103 0.02380952 0.14285714 ..., 0.8 1. 0.56818182]\n", + " [ 0.02631579 0.02439024 0.14705882 ..., 0.47619048 0.56818182 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 12.015210\n", + "With standard deviation: 2.592798\n", + "\n", + " Mean performance on test set: 20.347932\n", + "With standard deviation: 5.176314\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 8.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 8 of size 185 built in 1.8121819496154785 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02325581]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.02173913]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.12820513]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.41666667]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.49019608]\n", + " [ 0.02325581 0.02173913 0.12820513 ..., 0.41666667 0.49019608 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.798096\n", + "With standard deviation: 2.130816\n", + "\n", + " Mean performance on test set: 19.822797\n", + "With standard deviation: 5.137687\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 9.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 9 of size 185 built in 2.2172586917877197 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.0212766 ]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727 0.02 ]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11627907]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.38461538]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.45454545]\n", + " [ 0.0212766 0.02 0.11627907 ..., 0.38461538 0.45454545 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.799656\n", + "With standard deviation: 2.095494\n", + "\n", + " Mean performance on test set: 19.873364\n", + "With standard deviation: 5.103689\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 10.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 10 of size 185 built in 2.4100613594055176 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 11.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 11 of size 185 built in 2.7440149784088135 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 12.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 12 of size 185 built in 2.723442316055298 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 13.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 13 of size 185 built in 2.6163382530212402 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 14.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 14 of size 185 built in 2.629500389099121 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 15.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 15 of size 185 built in 2.664158821105957 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 16.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 16 of size 185 built in 2.7301340103149414 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 17.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 17 of size 185 built in 2.6328580379486084 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 18.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 18 of size 185 built in 2.592944383621216 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 19.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 19 of size 185 built in 2.6368520259857178 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 20.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 20 of size 185 built in 2.52734375 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.778685\n", + "With standard deviation: 2.100015\n", + "\n", + " Mean performance on test set: 19.870809\n", + "With standard deviation: 5.092173\n", + "\n", + "\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- ---------\n", + " 0 41.6202 6.453 43.6169 2.13212 0.0904737\n", + " 1 38.8446 6.44648 40.8329 3.44147 0.175414\n", + " 2 35.2915 4.7813 35.7461 1.61134 0.344896\n", + " 3 29.4845 3.90351 28.4646 3.00137 0.553939\n", + " 4 22.6693 6.28053 19.2517 3.42893 0.770649\n", + " 5 21.7956 5.5225 16.886 2.60519 1.01558\n", + " 6 20.6049 5.49983 13.1097 2.58431 1.33302\n", + " 7 20.3479 5.17631 12.0152 2.5928 1.60266\n", + " 8 19.8228 5.13769 10.7981 2.13082 1.81218\n", + " 9 19.8734 5.10369 10.7997 2.09549 2.21726\n", + " 10 19.8708 5.09217 10.7787 2.10002 2.41006\n", + " 11 19.8708 5.09217 10.7787 2.10002 2.74401\n", + " 12 19.8708 5.09217 10.7787 2.10002 2.72344\n", + " 13 19.8708 5.09217 10.7787 2.10002 2.61634\n", + " 14 19.8708 5.09217 10.7787 2.10002 2.6295\n", + " 15 19.8708 5.09217 10.7787 2.10002 2.66416\n", + " 16 19.8708 5.09217 10.7787 2.10002 2.73013\n", + " 17 19.8708 5.09217 10.7787 2.10002 2.63286\n", + " 18 19.8708 5.09217 10.7787 2.10002 2.59294\n", + " 19 19.8708 5.09217 10.7787 2.10002 2.63685\n", + " 20 19.8708 5.09217 10.7787 2.10002 2.52734\n", + "\n", + " --- This is a regression problem ---\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 0.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 0 of size 185 built in 0.1027534008026123 seconds ---\n", + "[[ 1. 1. 0.33333333 ..., 0.33333333 0.33333333\n", + " 0.33333333]\n", + " [ 1. 1. 0.33333333 ..., 0.33333333 0.33333333\n", + " 0.33333333]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " ..., \n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]\n", + " [ 0.33333333 0.33333333 1. ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 42.787136\n", + "With standard deviation: 0.675806\n", + "\n", + " Mean performance on test set: 42.645892\n", + "With standard deviation: 6.560629\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 1.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 1 of size 185 built in 0.18301701545715332 seconds ---\n", + "[[ 1. 0.8 0.14285714 ..., 0.125 0.125 0.125 ]\n", + " [ 0.8 1. 0.125 ..., 0.11111111 0.11111111\n", + " 0.11111111]\n", + " [ 0.14285714 0.125 1. ..., 0.8 0.8 0.8 ]\n", + " ..., \n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]\n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]\n", + " [ 0.125 0.11111111 0.8 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 38.880117\n", + "With standard deviation: 0.623999\n", + "\n", + " Mean performance on test set: 39.174317\n", + "With standard deviation: 6.195371\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 2.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 2 of size 185 built in 0.33235955238342285 seconds ---\n", + "[[ 1. 0.5 0.11111111 ..., 0.07692308 0.07692308\n", + " 0.07692308]\n", + " [ 0.5 1. 0.09090909 ..., 0.06666667 0.06666667\n", + " 0.06666667]\n", + " [ 0.11111111 0.09090909 1. ..., 0.55555556 0.55555556\n", + " 0.55555556]\n", + " ..., \n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]\n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]\n", + " [ 0.07692308 0.06666667 0.55555556 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 35.348332\n", + "With standard deviation: 0.727833\n", + "\n", + " Mean performance on test set: 35.604226\n", + "With standard deviation: 4.539211\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 3.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 3 of size 185 built in 0.5400393009185791 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.05555556 0.05555556\n", + " 0.05555556]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.04761905 0.04761905\n", + " 0.04761905]\n", + " [ 0.11111111 0.08333333 1. ..., 0.35714286 0.35714286\n", + " 0.35714286]\n", + " ..., \n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.04761905 0.35714286 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 28.047646\n", + "With standard deviation: 1.077805\n", + "\n", + " Mean performance on test set: 30.192177\n", + "With standard deviation: 5.110324\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 4.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 4 of size 185 built in 0.8054666519165039 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.04347826 0.04166667\n", + " 0.04347826]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03846154 0.03703704\n", + " 0.03846154]\n", + " [ 0.11111111 0.08333333 1. ..., 0.26315789 0.25 0.26315789]\n", + " ..., \n", + " [ 0.04347826 0.03846154 0.26315789 ..., 1. 0.95 0.9 ]\n", + " [ 0.04166667 0.03703704 0.25 ..., 0.95 1. 0.95 ]\n", + " [ 0.04347826 0.03846154 0.26315789 ..., 0.9 0.95 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Mean performance on train set: 18.878595\n", + "With standard deviation: 1.711897\n", + "\n", + " Mean performance on test set: 23.751530\n", + "With standard deviation: 7.808559\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 5.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 5 of size 185 built in 1.0195980072021484 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03703704 0.03333333\n", + " 0.03571429]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03333333 0.03030303\n", + " 0.03225806]\n", + " [ 0.11111111 0.08333333 1. ..., 0.2173913 0.19230769\n", + " 0.20833333]\n", + " ..., \n", + " [ 0.03703704 0.03333333 0.2173913 ..., 1. 0.88461538\n", + " 0.74074074]\n", + " [ 0.03333333 0.03030303 0.19230769 ..., 0.88461538 1. 0.85185185]\n", + " [ 0.03571429 0.03225806 0.20833333 ..., 0.74074074 0.85185185 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 16.339135\n", + "With standard deviation: 1.397693\n", + "\n", + " Mean performance on test set: 23.482309\n", + "With standard deviation: 7.727117\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 6.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 6 of size 185 built in 1.2962956428527832 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03333333 0.02857143\n", + " 0.03030303]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.03030303 0.02631579\n", + " 0.02777778]\n", + " [ 0.11111111 0.08333333 1. ..., 0.19230769 0.16129032\n", + " 0.17241379]\n", + " ..., \n", + " [ 0.03333333 0.03030303 0.19230769 ..., 1. 0.83870968\n", + " 0.57142857]\n", + " [ 0.02857143 0.02631579 0.16129032 ..., 0.83870968 1. 0.71428571]\n", + " [ 0.03030303 0.02777778 0.17241379 ..., 0.57142857 0.71428571 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 12.523830\n", + "With standard deviation: 1.040404\n", + "\n", + " Mean performance on test set: 22.745367\n", + "With standard deviation: 8.028051\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 7.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 7 of size 185 built in 1.5462064743041992 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03125 0.02564103\n", + " 0.02631579]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02857143 0.02380952\n", + " 0.02439024]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17857143 0.14285714\n", + " 0.14705882]\n", + " ..., \n", + " [ 0.03125 0.02857143 0.17857143 ..., 1. 0.8 0.47619048]\n", + " [ 0.02564103 0.02380952 0.14285714 ..., 0.8 1. 0.56818182]\n", + " [ 0.02631579 0.02439024 0.14705882 ..., 0.47619048 0.56818182 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 11.371668\n", + "With standard deviation: 0.925446\n", + "\n", + " Mean performance on test set: 22.831602\n", + "With standard deviation: 7.978369\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 8.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 8 of size 185 built in 1.8658208847045898 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02325581]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.02173913]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.12820513]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.41666667]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.49019608]\n", + " [ 0.02325581 0.02173913 0.12820513 ..., 0.41666667 0.49019608 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.132106\n", + "With standard deviation: 0.525580\n", + "\n", + " Mean performance on test set: 22.586071\n", + "With standard deviation: 8.067887\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 9.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 9 of size 185 built in 2.185042381286621 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.0212766 ]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727 0.02 ]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11627907]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.38461538]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.45454545]\n", + " [ 0.0212766 0.02 0.11627907 ..., 0.38461538 0.45454545 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.078464\n", + "With standard deviation: 0.518149\n", + "\n", + " Mean performance on test set: 22.766801\n", + "With standard deviation: 8.005709\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 10.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 10 of size 185 built in 2.35276198387146 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 11.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 11 of size 185 built in 2.6274359226226807 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 12.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 12 of size 185 built in 2.7209105491638184 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 13.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 13 of size 185 built in 2.699059247970581 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 14.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 14 of size 185 built in 2.6328344345092773 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 15.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 15 of size 185 built in 2.6556999683380127 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 16.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 16 of size 185 built in 2.621814012527466 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 17.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 17 of size 185 built in 2.5938243865966797 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 18.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 18 of size 185 built in 2.65336275100708 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 19.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 19 of size 185 built in 2.628486156463623 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 20.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 20 of size 185 built in 2.682689666748047 seconds ---\n", + "[[ 1. 0.44444444 0.11111111 ..., 0.03030303 0.02439024\n", + " 0.02040816]\n", + " [ 0.44444444 1. 0.08333333 ..., 0.02777778 0.02272727\n", + " 0.01923077]\n", + " [ 0.11111111 0.08333333 1. ..., 0.17241379 0.13513514\n", + " 0.11111111]\n", + " ..., \n", + " [ 0.03030303 0.02777778 0.17241379 ..., 1. 0.73684211\n", + " 0.37037037]\n", + " [ 0.02439024 0.02272727 0.13513514 ..., 0.73684211 1. 0.43859649]\n", + " [ 0.02040816 0.01923077 0.11111111 ..., 0.37037037 0.43859649 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.075607\n", + "With standard deviation: 0.672820\n", + "\n", + " Mean performance on test set: 22.869720\n", + "With standard deviation: 7.944560\n", + "\n", + "\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 42.6459 6.56063 42.7871 0.675806 0.102753\n", + " 1 39.1743 6.19537 38.8801 0.623999 0.183017\n", + " 2 35.6042 4.53921 35.3483 0.727833 0.33236\n", + " 3 30.1922 5.11032 28.0476 1.0778 0.540039\n", + " 4 23.7515 7.80856 18.8786 1.7119 0.805467\n", + " 5 23.4823 7.72712 16.3391 1.39769 1.0196\n", + " 6 22.7454 8.02805 12.5238 1.0404 1.2963\n", + " 7 22.8316 7.97837 11.3717 0.925446 1.54621\n", + " 8 22.5861 8.06789 10.1321 0.52558 1.86582\n", + " 9 22.7668 8.00571 10.0785 0.518149 2.18504\n", + " 10 22.8697 7.94456 10.0756 0.67282 2.35276\n", + " 11 22.8697 7.94456 10.0756 0.67282 2.62744\n", + " 12 22.8697 7.94456 10.0756 0.67282 2.72091\n", + " 13 22.8697 7.94456 10.0756 0.67282 2.69906\n", + " 14 22.8697 7.94456 10.0756 0.67282 2.63283\n", + " 15 22.8697 7.94456 10.0756 0.67282 2.6557\n", + " 16 22.8697 7.94456 10.0756 0.67282 2.62181\n", + " 17 22.8697 7.94456 10.0756 0.67282 2.59382\n", + " 18 22.8697 7.94456 10.0756 0.67282 2.65336\n", + " 19 22.8697 7.94456 10.0756 0.67282 2.62849\n", + " 20 22.8697 7.94456 10.0756 0.67282 2.68269\n", + "\n", + " --- This is a regression problem ---\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 0.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 0 of size 185 built in 0.3893899917602539 seconds ---\n", + "[[ 1. 0.75 0.5 ..., 0.16666667 0.16666667\n", + " 0.16666667]\n", + " [ 0.75 1. 0.4 ..., 0.15384615 0.15384615\n", + " 0.15384615]\n", + " [ 0.5 0.4 1. ..., 0.27272727 0.27272727\n", + " 0.27272727]\n", + " ..., \n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]\n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]\n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 12.207923\n", + "With standard deviation: 0.700182\n", + "\n", + " Mean performance on test set: 12.682718\n", + "With standard deviation: 2.748815\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 1.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 1 of size 185 built in 0.4729621410369873 seconds ---\n", + "[[ 1. 0.7 0.16666667 ..., 0.05555556 0.05555556\n", + " 0.05555556]\n", + " [ 0.7 1. 0.13333333 ..., 0.05128205 0.05128205\n", + " 0.05128205]\n", + " [ 0.16666667 0.13333333 1. ..., 0.22580645 0.22580645\n", + " 0.22580645]\n", + " ..., \n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.279220\n", + "With standard deviation: 0.914688\n", + "\n", + " Mean performance on test set: 12.609828\n", + "With standard deviation: 2.372778\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 2.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 2 of size 185 built in 0.576836109161377 seconds ---\n", + "[[ 1. 0.4375 0.125 ..., 0.03333333 0.03333333\n", + " 0.03571429]\n", + " [ 0.4375 1. 0.0952381 ..., 0.03076923 0.03076923\n", + " 0.03278689]\n", + " [ 0.125 0.0952381 1. ..., 0.16981132 0.16981132\n", + " 0.18367347]\n", + " ..., \n", + " [ 0.03333333 0.03076923 0.16981132 ..., 1. 1. 0.9245283 ]\n", + " [ 0.03333333 0.03076923 0.16981132 ..., 1. 1. 0.9245283 ]\n", + " [ 0.03571429 0.03278689 0.18367347 ..., 0.9245283 0.9245283 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 2.588811\n", + "With standard deviation: 0.557162\n", + "\n", + " Mean performance on test set: 8.060609\n", + "With standard deviation: 2.470450\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 3.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 3 of size 185 built in 0.7169125080108643 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.02631579 0.02631579\n", + " 0.02777778]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.02409639 0.02409639\n", + " 0.02531646]\n", + " [ 0.125 0.08695652 1. ..., 0.13043478 0.13043478\n", + " 0.13846154]\n", + " ..., \n", + " [ 0.02631579 0.02409639 0.13043478 ..., 1. 0.94366197\n", + " 0.83561644]\n", + " [ 0.02631579 0.02409639 0.13043478 ..., 0.94366197 1. 0.78666667]\n", + " [ 0.02777778 0.02531646 0.13846154 ..., 0.83561644 0.78666667 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.272670\n", + "With standard deviation: 0.760432\n", + "\n", + " Mean performance on test set: 9.755135\n", + "With standard deviation: 3.049170\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 4.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 4 of size 185 built in 0.8342421054840088 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.02222222 0.02222222\n", + " 0.02325581]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.02061856 0.02061856\n", + " 0.02150538]\n", + " [ 0.125 0.08695652 1. ..., 0.10843373 0.10843373\n", + " 0.11392405]\n", + " ..., \n", + " [ 0.02222222 0.02061856 0.10843373 ..., 1. 0.82417582\n", + " 0.67010309]\n", + " [ 0.02222222 0.02061856 0.10843373 ..., 0.82417582 1. 0.70526316]\n", + " [ 0.02325581 0.02150538 0.11392405 ..., 0.67010309 0.70526316 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.032293\n", + "With standard deviation: 0.728380\n", + "\n", + " Mean performance on test set: 10.319167\n", + "With standard deviation: 3.616673\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 5.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 5 of size 185 built in 0.9938209056854248 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01960784 0.01960784\n", + " 0.02040816]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01834862 0.01834862\n", + " 0.01904762]\n", + " [ 0.125 0.08695652 1. ..., 0.09473684 0.09473684\n", + " 0.0989011 ]\n", + " ..., \n", + " [ 0.01960784 0.01834862 0.09473684 ..., 1. 0.74311927\n", + " 0.56302521]\n", + " [ 0.01960784 0.01834862 0.09473684 ..., 0.74311927 1. 0.6173913 ]\n", + " [ 0.02040816 0.01904762 0.0989011 ..., 0.56302521 0.6173913 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 0.923543\n", + "With standard deviation: 0.660532\n", + "\n", + " Mean performance on test set: 10.659250\n", + "With standard deviation: 4.120523\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 6.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 6 of size 185 built in 1.1753439903259277 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01785714 0.01785714\n", + " 0.01851852]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01680672 0.01680672\n", + " 0.0173913 ]\n", + " [ 0.125 0.08695652 1. ..., 0.08571429 0.08571429\n", + " 0.08910891]\n", + " ..., \n", + " [ 0.01785714 0.01680672 0.08571429 ..., 1. 0.68 0.48201439]\n", + " [ 0.01785714 0.01680672 0.08571429 ..., 0.68 1. 0.54887218]\n", + " [ 0.01851852 0.0173913 0.08910891 ..., 0.48201439 0.54887218 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 0.878589\n", + "With standard deviation: 0.603598\n", + "\n", + " Mean performance on test set: 11.102521\n", + "With standard deviation: 4.330554\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 7.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 7 of size 185 built in 1.4358420372009277 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01666667 0.01666667\n", + " 0.01724138]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01574803 0.01574803\n", + " 0.01626016]\n", + " [ 0.125 0.08695652 1. ..., 0.07964602 0.07964602\n", + " 0.08256881]\n", + " ..., \n", + " [ 0.01666667 0.01574803 0.07964602 ..., 1. 0.64963504\n", + " 0.43225806]\n", + " [ 0.01666667 0.01574803 0.07964602 ..., 0.64963504 1. 0.48993289]\n", + " [ 0.01724138 0.01626016 0.08256881 ..., 0.43225806 0.48993289 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 0.944049\n", + "With standard deviation: 0.694844\n", + "\n", + " Mean performance on test set: 11.352962\n", + "With standard deviation: 4.305459\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 8.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 8 of size 185 built in 1.7005987167358398 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625\n", + " 0.01639344]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01550388]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07826087]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.3964497 ]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.44785276]\n", + " [ 0.01639344 0.01550388 0.07826087 ..., 0.3964497 0.44785276 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.033979\n", + "With standard deviation: 0.775622\n", + "\n", + " Mean performance on test set: 11.298981\n", + "With standard deviation: 4.349648\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 9.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 9 of size 185 built in 2.0194287300109863 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625\n", + " 0.01587302]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01503759]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07563025]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.38728324]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.43712575]\n", + " [ 0.01587302 0.01503759 0.07563025 ..., 0.38728324 0.43712575 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.003187\n", + "With standard deviation: 0.572070\n", + "\n", + " Mean performance on test set: 11.332669\n", + "With standard deviation: 4.324120\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 10.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 10 of size 185 built in 2.243326187133789 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625 0.015625 ]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01481481]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07438017]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.38285714]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.43195266]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.38285714 0.43195266 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.002272\n", + "With standard deviation: 0.570937\n", + "\n", + " Mean performance on test set: 11.343515\n", + "With standard deviation: 4.327265\n", + "\n", + "\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 12.6827 2.74882 12.2079 0.700182 0.38939\n", + " 1 12.6098 2.37278 10.2792 0.914688 0.472962\n", + " 2 8.06061 2.47045 2.58881 0.557162 0.576836\n", + " 3 9.75514 3.04917 1.27267 0.760432 0.716913\n", + " 4 10.3192 3.61667 1.03229 0.72838 0.834242\n", + " 5 10.6593 4.12052 0.923543 0.660532 0.993821\n", + " 6 11.1025 4.33055 0.878589 0.603598 1.17534\n", + " 7 11.353 4.30546 0.944049 0.694844 1.43584\n", + " 8 11.299 4.34965 1.03398 0.775622 1.7006\n", + " 9 11.3327 4.32412 1.00319 0.57207 2.01943\n", + " 10 11.3435 4.32726 1.00227 0.570937 2.24333\n", + "\n", + " --- This is a regression problem ---\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 0.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 0 of size 185 built in 0.3775763511657715 seconds ---\n", + "[[ 1. 0.75 0.5 ..., 0.16666667 0.16666667\n", + " 0.16666667]\n", + " [ 0.75 1. 0.4 ..., 0.15384615 0.15384615\n", + " 0.15384615]\n", + " [ 0.5 0.4 1. ..., 0.27272727 0.27272727\n", + " 0.27272727]\n", + " ..., \n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]\n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]\n", + " [ 0.16666667 0.15384615 0.27272727 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 12.120872\n", + "With standard deviation: 0.500467\n", + "\n", + " Mean performance on test set: 12.579966\n", + "With standard deviation: 2.732346\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 1.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 1 of size 185 built in 0.4563324451446533 seconds ---\n", + "[[ 1. 0.7 0.16666667 ..., 0.05555556 0.05555556\n", + " 0.05555556]\n", + " [ 0.7 1. 0.13333333 ..., 0.05128205 0.05128205\n", + " 0.05128205]\n", + " [ 0.16666667 0.13333333 1. ..., 0.22580645 0.22580645\n", + " 0.22580645]\n", + " ..., \n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]\n", + " [ 0.05555556 0.05128205 0.22580645 ..., 1. 1. 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 10.224322\n", + "With standard deviation: 0.734261\n", + "\n", + " Mean performance on test set: 12.621509\n", + "With standard deviation: 2.188664\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 2.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 2 of size 185 built in 0.5852782726287842 seconds ---\n", + "[[ 1. 0.4375 0.125 ..., 0.03333333 0.03333333\n", + " 0.03571429]\n", + " [ 0.4375 1. 0.0952381 ..., 0.03076923 0.03076923\n", + " 0.03278689]\n", + " [ 0.125 0.0952381 1. ..., 0.16981132 0.16981132\n", + " 0.18367347]\n", + " ..., \n", + " [ 0.03333333 0.03076923 0.16981132 ..., 1. 1. 0.9245283 ]\n", + " [ 0.03333333 0.03076923 0.16981132 ..., 1. 1. 0.9245283 ]\n", + " [ 0.03571429 0.03278689 0.18367347 ..., 0.9245283 0.9245283 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 2.718851\n", + "With standard deviation: 0.732922\n", + "\n", + " Mean performance on test set: 7.429032\n", + "With standard deviation: 2.693953\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 3.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 3 of size 185 built in 0.7065560817718506 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.02631579 0.02631579\n", + " 0.02777778]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.02409639 0.02409639\n", + " 0.02531646]\n", + " [ 0.125 0.08695652 1. ..., 0.13043478 0.13043478\n", + " 0.13846154]\n", + " ..., \n", + " [ 0.02631579 0.02409639 0.13043478 ..., 1. 0.94366197\n", + " 0.83561644]\n", + " [ 0.02631579 0.02409639 0.13043478 ..., 0.94366197 1. 0.78666667]\n", + " [ 0.02777778 0.02531646 0.13846154 ..., 0.83561644 0.78666667 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.540000\n", + "With standard deviation: 1.138134\n", + "\n", + " Mean performance on test set: 9.024680\n", + "With standard deviation: 2.508084\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 4.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 4 of size 185 built in 0.8479568958282471 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.02222222 0.02222222\n", + " 0.02325581]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.02061856 0.02061856\n", + " 0.02150538]\n", + " [ 0.125 0.08695652 1. ..., 0.10843373 0.10843373\n", + " 0.11392405]\n", + " ..., \n", + " [ 0.02222222 0.02061856 0.10843373 ..., 1. 0.82417582\n", + " 0.67010309]\n", + " [ 0.02222222 0.02061856 0.10843373 ..., 0.82417582 1. 0.70526316]\n", + " [ 0.02325581 0.02150538 0.11392405 ..., 0.67010309 0.70526316 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.360291\n", + "With standard deviation: 1.423990\n", + "\n", + " Mean performance on test set: 10.081112\n", + "With standard deviation: 3.647700\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 5.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 5 of size 185 built in 1.0008597373962402 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01960784 0.01960784\n", + " 0.02040816]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01834862 0.01834862\n", + " 0.01904762]\n", + " [ 0.125 0.08695652 1. ..., 0.09473684 0.09473684\n", + " 0.0989011 ]\n", + " ..., \n", + " [ 0.01960784 0.01834862 0.09473684 ..., 1. 0.74311927\n", + " 0.56302521]\n", + " [ 0.01960784 0.01834862 0.09473684 ..., 0.74311927 1. 0.6173913 ]\n", + " [ 0.02040816 0.01904762 0.0989011 ..., 0.56302521 0.6173913 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.085175\n", + "With standard deviation: 1.062063\n", + "\n", + " Mean performance on test set: 11.300476\n", + "With standard deviation: 4.441634\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 6.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " --- kernel matrix of path kernel up to 6 of size 185 built in 1.1979196071624756 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01785714 0.01785714\n", + " 0.01851852]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01680672 0.01680672\n", + " 0.0173913 ]\n", + " [ 0.125 0.08695652 1. ..., 0.08571429 0.08571429\n", + " 0.08910891]\n", + " ..., \n", + " [ 0.01785714 0.01680672 0.08571429 ..., 1. 0.68 0.48201439]\n", + " [ 0.01785714 0.01680672 0.08571429 ..., 0.68 1. 0.54887218]\n", + " [ 0.01851852 0.0173913 0.08910891 ..., 0.48201439 0.54887218 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.064431\n", + "With standard deviation: 1.001911\n", + "\n", + " Mean performance on test set: 12.186014\n", + "With standard deviation: 4.888158\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 7.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 7 of size 185 built in 1.4372029304504395 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.01666667 0.01666667\n", + " 0.01724138]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01574803 0.01574803\n", + " 0.01626016]\n", + " [ 0.125 0.08695652 1. ..., 0.07964602 0.07964602\n", + " 0.08256881]\n", + " ..., \n", + " [ 0.01666667 0.01574803 0.07964602 ..., 1. 0.64963504\n", + " 0.43225806]\n", + " [ 0.01666667 0.01574803 0.07964602 ..., 0.64963504 1. 0.48993289]\n", + " [ 0.01724138 0.01626016 0.08256881 ..., 0.43225806 0.48993289 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.199119\n", + "With standard deviation: 1.340313\n", + "\n", + " Mean performance on test set: 12.753387\n", + "With standard deviation: 5.145288\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 8.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 8 of size 185 built in 1.68448805809021 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625\n", + " 0.01639344]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01550388]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07826087]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.3964497 ]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.44785276]\n", + " [ 0.01639344 0.01550388 0.07826087 ..., 0.3964497 0.44785276 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.358221\n", + "With standard deviation: 1.843147\n", + "\n", + " Mean performance on test set: 13.047098\n", + "With standard deviation: 5.271835\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 9.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 9 of size 185 built in 1.9654510021209717 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625\n", + " 0.01587302]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01503759]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07563025]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.38728324]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.43712575]\n", + " [ 0.01587302 0.01503759 0.07563025 ..., 0.38728324 0.43712575 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.360024\n", + "With standard deviation: 1.848342\n", + "\n", + " Mean performance on test set: 13.178933\n", + "With standard deviation: 5.277067\n", + "\n", + "\n", + " #--- calculating kernel matrix when depth = 10.0 ---#\n", + "\n", + " Loading dataset from file...\n", + "\n", + " Calculating kernel matrix, this could take a while...\n", + "\n", + " --- kernel matrix of path kernel up to 10 of size 185 built in 2.2494258880615234 seconds ---\n", + "[[ 1. 0.38888889 0.125 ..., 0.015625 0.015625 0.015625 ]\n", + " [ 0.38888889 1. 0.08695652 ..., 0.01481481 0.01481481\n", + " 0.01481481]\n", + " [ 0.125 0.08695652 1. ..., 0.07438017 0.07438017\n", + " 0.07438017]\n", + " ..., \n", + " [ 0.015625 0.01481481 0.07438017 ..., 1. 0.58169935\n", + " 0.38285714]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.58169935 1. 0.43195266]\n", + " [ 0.015625 0.01481481 0.07438017 ..., 0.38285714 0.43195266 1. ]]\n", + "\n", + " Saving kernel matrix to file...\n", + "\n", + " Mean performance on train set: 1.362078\n", + "With standard deviation: 1.854262\n", + "\n", + " Mean performance on test set: 13.253773\n", + "With standard deviation: 5.264247\n", + "\n", + "\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 12.58 2.73235 12.1209 0.500467 0.377576\n", + " 1 12.6215 2.18866 10.2243 0.734261 0.456332\n", + " 2 7.42903 2.69395 2.71885 0.732922 0.585278\n", + " 3 9.02468 2.50808 1.54 1.13813 0.706556\n", + " 4 10.0811 3.6477 1.36029 1.42399 0.847957\n", + " 5 11.3005 4.44163 1.08518 1.06206 1.00086\n", + " 6 12.186 4.88816 1.06443 1.00191 1.19792\n", + " 7 12.7534 5.14529 1.19912 1.34031 1.4372\n", + " 8 13.0471 5.27184 1.35822 1.84315 1.68449\n", + " 9 13.1789 5.27707 1.36002 1.84834 1.96545\n", + " 10 13.2538 5.26425 1.36208 1.85426 2.24943\n" + ] + } + ], + "source": [ + "%load_ext line_profiler\n", + "\n", + "import sys\n", + "sys.path.insert(0, \"../\")\n", + "from pygraph.utils.utils import kernel_train_test\n", + "from pygraph.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)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# results\n", + "\n", + "# kernel Tanimoto with y normalization\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- ---------\n", + " 0 41.6202 6.453 43.6169 2.13212 0.0904737\n", + " 1 38.8446 6.44648 40.8329 3.44147 0.175414\n", + " 2 35.2915 4.7813 35.7461 1.61134 0.344896\n", + " 3 29.4845 3.90351 28.4646 3.00137 0.553939\n", + " 4 22.6693 6.28053 19.2517 3.42893 0.770649\n", + " 5 21.7956 5.5225 16.886 2.60519 1.01558\n", + " 6 20.6049 5.49983 13.1097 2.58431 1.33302\n", + " 7 20.3479 5.17631 12.0152 2.5928 1.60266\n", + " 8 19.8228 5.13769 10.7981 2.13082 1.81218\n", + " 9 19.8734 5.10369 10.7997 2.09549 2.21726\n", + " 10 19.8708 5.09217 10.7787 2.10002 2.41006\n", + " 11 19.8708 5.09217 10.7787 2.10002 2.74401\n", + " 12 19.8708 5.09217 10.7787 2.10002 2.72344\n", + " 13 19.8708 5.09217 10.7787 2.10002 2.61634\n", + " 14 19.8708 5.09217 10.7787 2.10002 2.6295\n", + " 15 19.8708 5.09217 10.7787 2.10002 2.66416\n", + " 16 19.8708 5.09217 10.7787 2.10002 2.73013\n", + " 17 19.8708 5.09217 10.7787 2.10002 2.63286\n", + " 18 19.8708 5.09217 10.7787 2.10002 2.59294\n", + " 19 19.8708 5.09217 10.7787 2.10002 2.63685\n", + " 20 19.8708 5.09217 10.7787 2.10002 2.52734\n", + "\n", + "# kernel Tanimoto without y normalization\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 42.6459 6.56063 42.7871 0.675806 0.102753\n", + " 1 39.1743 6.19537 38.8801 0.623999 0.183017\n", + " 2 35.6042 4.53921 35.3483 0.727833 0.33236\n", + " 3 30.1922 5.11032 28.0476 1.0778 0.540039\n", + " 4 23.7515 7.80856 18.8786 1.7119 0.805467\n", + " 5 23.4823 7.72712 16.3391 1.39769 1.0196\n", + " 6 22.7454 8.02805 12.5238 1.0404 1.2963\n", + " 7 22.8316 7.97837 11.3717 0.925446 1.54621\n", + " 8 22.5861 8.06789 10.1321 0.52558 1.86582\n", + " 9 22.7668 8.00571 10.0785 0.518149 2.18504\n", + " 10 22.8697 7.94456 10.0756 0.67282 2.35276\n", + " 11 22.8697 7.94456 10.0756 0.67282 2.62744\n", + " 12 22.8697 7.94456 10.0756 0.67282 2.72091\n", + " 13 22.8697 7.94456 10.0756 0.67282 2.69906\n", + " 14 22.8697 7.94456 10.0756 0.67282 2.63283\n", + " 15 22.8697 7.94456 10.0756 0.67282 2.6557\n", + " 16 22.8697 7.94456 10.0756 0.67282 2.62181\n", + " 17 22.8697 7.94456 10.0756 0.67282 2.59382\n", + " 18 22.8697 7.94456 10.0756 0.67282 2.65336\n", + " 19 22.8697 7.94456 10.0756 0.67282 2.62849\n", + " 20 22.8697 7.94456 10.0756 0.67282 2.68269\n", + " \n", + "# kernel MinMax with y normalization \n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 12.6827 2.74882 12.2079 0.700182 0.38939\n", + " 1 12.6098 2.37278 10.2792 0.914688 0.472962\n", + " 2 8.06061 2.47045 2.58881 0.557162 0.576836\n", + " 3 9.75514 3.04917 1.27267 0.760432 0.716913\n", + " 4 10.3192 3.61667 1.03229 0.72838 0.834242\n", + " 5 10.6593 4.12052 0.923543 0.660532 0.993821\n", + " 6 11.1025 4.33055 0.878589 0.603598 1.17534\n", + " 7 11.353 4.30546 0.944049 0.694844 1.43584\n", + " 8 11.299 4.34965 1.03398 0.775622 1.7006\n", + " 9 11.3327 4.32412 1.00319 0.57207 2.01943\n", + " 10 11.3435 4.32726 1.00227 0.570937 2.24333\n", + "\n", + "# kernel MinMax without y normalization\n", + " depth rmse_test std_test rmse_train std_train k_time\n", + "------- ----------- ---------- ------------ ----------- --------\n", + " 0 12.58 2.73235 12.1209 0.500467 0.377576\n", + " 1 12.6215 2.18866 10.2243 0.734261 0.456332\n", + " 2 7.42903 2.69395 2.71885 0.732922 0.585278\n", + " 3 9.02468 2.50808 1.54 1.13813 0.706556\n", + " 4 10.0811 3.6477 1.36029 1.42399 0.847957\n", + " 5 11.3005 4.44163 1.08518 1.06206 1.00086\n", + " 6 12.186 4.88816 1.06443 1.00191 1.19792\n", + " 7 12.7534 5.14529 1.19912 1.34031 1.4372\n", + " 8 13.0471 5.27184 1.35822 1.84315 1.68449\n", + " 9 13.1789 5.27707 1.36002 1.84834 1.96545\n", + " 10 13.2538 5.26425 1.36208 1.85426 2.24943" + ] + } + ], + "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.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/pygraph/kernels/.##untildPathKernel.py# b/pygraph/kernels/.##untildPathKernel.py# new file mode 120000 index 0000000..f20a452 --- /dev/null +++ b/pygraph/kernels/.##untildPathKernel.py# @@ -0,0 +1 @@ +ljia@ljia-Precision-7520.5692:1516782025 \ No newline at end of file diff --git a/pygraph/kernels/__pycache__/treeletKernel.cpython-35.pyc b/pygraph/kernels/__pycache__/treeletKernel.cpython-35.pyc index 7e648db..05209a4 100644 Binary files a/pygraph/kernels/__pycache__/treeletKernel.cpython-35.pyc and b/pygraph/kernels/__pycache__/treeletKernel.cpython-35.pyc differ diff --git a/pygraph/kernels/__pycache__/untildPathKernel.cpython-35.pyc b/pygraph/kernels/__pycache__/untildPathKernel.cpython-35.pyc new file mode 100644 index 0000000..a2124fa Binary files /dev/null and b/pygraph/kernels/__pycache__/untildPathKernel.cpython-35.pyc differ diff --git a/pygraph/kernels/pathKernel.py b/pygraph/kernels/pathKernel.py index 869ed7a..cb2b244 100644 --- a/pygraph/kernels/pathKernel.py +++ b/pygraph/kernels/pathKernel.py @@ -10,7 +10,7 @@ from pygraph.kernels.deltaKernel import deltakernel def pathkernel(*args, node_label = 'atom', edge_label = 'bond_type'): """Calculate mean average path kernels between graphs. - + Parameters ---------- Gn : List of NetworkX graph @@ -19,15 +19,15 @@ def pathkernel(*args, node_label = 'atom', edge_label = 'bond_type'): G1, G2 : NetworkX graphs 2 graphs between which the kernel is calculated. node_label : string - node attribute used as label. The default node label is atom. + node attribute used as label. The default node label is atom. edge_label : string edge attribute used as label. The default edge label is bond_type. - + Return ------ Kmatrix/kernel : Numpy matrix/float Kernel matrix, each element of which is the path kernel between 2 praphs. / Path kernel between 2 graphs. - + References ---------- [1] Suard F, Rakotomamonjy A, Bensrhair A. Kernel on Bag of Paths For Measuring Similarity of Shapes. InESANN 2007 Apr 25 (pp. 355-360). @@ -35,13 +35,13 @@ def pathkernel(*args, node_label = 'atom', edge_label = 'bond_type'): some_graph = args[0][0] if len(args) == 1 else args[0] # only edge attributes of type int or float can be used as edge weight to calculate the shortest paths. some_weight = list(nx.get_edge_attributes(some_graph, edge_label).values())[0] weight = edge_label if isinstance(some_weight, float) or isinstance(some_weight, int) else None - + if len(args) == 1: # for a list of graphs - Gn = args[0] + Gn = args[0] Kmatrix = np.zeros((len(Gn), len(Gn))) start_time = time.time() - + for i in range(0, len(Gn)): for j in range(i, len(Gn)): Kmatrix[i][j] = _pathkernel_do(Gn[i], Gn[j], node_label, edge_label, weight = weight) @@ -49,34 +49,34 @@ def pathkernel(*args, node_label = 'atom', edge_label = 'bond_type'): run_time = time.time() - start_time print("\n --- mean average path kernel matrix of size %d built in %s seconds ---" % (len(Gn), run_time)) - + return Kmatrix, run_time - + else: # for only 2 graphs start_time = time.time() - + kernel = _pathkernel_do(args[0], args[1], node_label, edge_label, weight = weight) run_time = time.time() - start_time print("\n --- mean average path kernel built in %s seconds ---" % (run_time)) - + return kernel, run_time - - + + def _pathkernel_do(G1, G2, node_label = 'atom', edge_label = 'bond_type', weight = None): """Calculate mean average path kernel between 2 graphs. - + Parameters ---------- G1, G2 : NetworkX graphs 2 graphs between which the kernel is calculated. node_label : string - node attribute used as label. The default node label is atom. + node attribute used as label. The default node label is atom. edge_label : string edge attribute used as label. The default edge label is bond_type. weight : string/None edge attribute used as weight to calculate the shortest path. The default edge label is None. - + Return ------ kernel : float @@ -88,7 +88,7 @@ def _pathkernel_do(G1, G2, node_label = 'atom', edge_label = 'bond_type', weight for node1 in range(num_nodes): for node2 in range(node1 + 1, num_nodes): sp1.append(nx.shortest_path(G1, node1, node2, weight = weight)) - + sp2 = [] num_nodes = G2.number_of_nodes() for node1 in range(num_nodes): @@ -108,5 +108,5 @@ def _pathkernel_do(G1, G2, node_label = 'atom', edge_label = 'bond_type', weight kernel += kernel_path # add up kernels of all paths kernel = kernel / (len(sp1) * len(sp2)) # calculate mean average - - return kernel \ No newline at end of file + + return kernel diff --git a/pygraph/kernels/results.md b/pygraph/kernels/results.md index 8a5fa09..b0b50e8 100644 --- a/pygraph/kernels/results.md +++ b/pygraph/kernels/results.md @@ -7,13 +7,14 @@ For predition we randomly divide the data in train and test subset, where 90% of ## Summary -| Kernels | RMSE(℃) | STD(℃) | Parameter | k_time | -|---------------|:---------:|:--------:|-------------:|-------:| -| Shortest path | 35.19 | 4.50 | - | 14.58" | -| Marginalized | 18.02 | 6.29 | p_quit = 0.1 | 4'19" | -| Path | 14.00 | 6.94 | - | 37.58" | -| WL subtree | 7.55 | 2.33 | height = 1 | 0.84" | -| Treelet | 8.31 | 3.38 | - | 49.58" | +| Kernels | RMSE(℃) | STD(℃) | Parameter | k_time | +|---------------|:-------:|:------:|-------------:|-------:| +| Shortest path | 35.19 | 4.50 | - | 14.58" | +| Marginalized | 18.02 | 6.29 | p_quit = 0.1 | 4'19" | +| Path | 14.00 | 6.94 | - | 37.58" | +| WL subtree | 7.55 | 2.33 | height = 1 | 0.84" | +| Treelet | 8.31 | 3.38 | - | 0.50" | +| Path up to d | 7.43 | 2.69 | depth = 2 | 0.52" | * RMSE stands for arithmetic mean of the root mean squared errors on all splits. * STD stands for standard deviation of the root mean squared errors on all splits. @@ -76,9 +77,46 @@ The table below shows the results of the WL subtree under different subtree heig ``` ### Treelet kernel -**The targets of training data are normalized before calculating the kernel.** + **The targets of training data are normalized before calculating the kernel.** ``` RMSE_test std_test RMSE_train std_train k_time ----------- ---------- ------------ ----------- -------- - 8.3079 3.37838 2.90887 1.2679 49.5814 -``` \ No newline at end of file + 8.3079 3.37838 2.90887 1.2679 0.500302 +``` + +### Path kernel up to depth *d* +The table below shows the results of the path kernel up to different depth *d*. + +The first table is the results using Tanimoto kernel, where **The targets of training data are normalized before calculating the kernel.**. +``` + depth rmse_test std_test rmse_train std_train k_time +------- ----------- ---------- ------------ ----------- --------- + 0 41.6202 6.453 43.6169 2.13212 0.0904737 + 1 38.8446 6.44648 40.8329 3.44147 0.175414 + 2 35.2915 4.7813 35.7461 1.61134 0.344896 + 3 29.4845 3.90351 28.4646 3.00137 0.553939 + 4 22.6693 6.28053 19.2517 3.42893 0.770649 + 5 21.7956 5.5225 16.886 2.60519 1.01558 + 6 20.6049 5.49983 13.1097 2.58431 1.33302 + 7 20.3479 5.17631 12.0152 2.5928 1.60266 + 8 19.8228 5.13769 10.7981 2.13082 1.81218 + 9 19.8734 5.10369 10.7997 2.09549 2.21726 + 10 19.8708 5.09217 10.7787 2.10002 2.41006 +``` + +The second table is the results using MinMax kernel. +``` +depth rmse_test std_test rmse_train std_train k_time +------- ----------- ---------- ------------ ----------- -------- + 0 12.58 2.73235 12.1209 0.500467 0.377576 + 1 12.6215 2.18866 10.2243 0.734261 0.456332 + 2 7.42903 2.69395 2.71885 0.732922 0.585278 + 3 9.02468 2.50808 1.54 1.13813 0.706556 + 4 10.0811 3.6477 1.36029 1.42399 0.847957 + 5 11.3005 4.44163 1.08518 1.06206 1.00086 + 6 12.186 4.88816 1.06443 1.00191 1.19792 + 7 12.7534 5.14529 1.19912 1.34031 1.4372 + 8 13.0471 5.27184 1.35822 1.84315 1.68449 + 9 13.1789 5.27707 1.36002 1.84834 1.96545 + 10 13.2538 5.26425 1.36208 1.85426 2.24943 +``` diff --git a/pygraph/kernels/treeletKernel.py b/pygraph/kernels/treeletKernel.py index 9e99c89..073150a 100644 --- a/pygraph/kernels/treeletKernel.py +++ b/pygraph/kernels/treeletKernel.py @@ -38,9 +38,13 @@ def treeletkernel(*args, node_label = 'atom', edge_label = 'bond_type', labeled start_time = time.time() + # get all canonical keys of all graphs before calculating kernels to save time, but this may cost a lot of memory for large dataset. + canonkeys = [ get_canonkeys(Gn[i], node_label = node_label, edge_label = edge_label, labeled = labeled) \ + for i in range(0, len(Gn)) ] + for i in range(0, len(Gn)): for j in range(i, len(Gn)): - Kmatrix[i][j] = _treeletkernel_do(Gn[i], Gn[j], node_label = node_label, edge_label = edge_label, labeled = labeled) + Kmatrix[i][j] = _treeletkernel_do(canonkeys[i], canonkeys[j], node_label = node_label, edge_label = edge_label, labeled = labeled) Kmatrix[j][i] = Kmatrix[i][j] run_time = time.time() - start_time @@ -51,8 +55,11 @@ def treeletkernel(*args, node_label = 'atom', edge_label = 'bond_type', labeled else: # for only 2 graphs start_time = time.time() + + canonkey1 = get_canonkeys(args[0], node_label = node_label, edge_label = edge_label, labeled = labeled) + canonkey2 = get_canonkeys(args[1], node_label = node_label, edge_label = edge_label, labeled = labeled) - kernel = _treeletkernel_do(args[0], args[1], node_label = node_label, edge_label = edge_label, labeled = labeled) + kernel = _treeletkernel_do(canonkey1, canonkey2, node_label = node_label, edge_label = edge_label, labeled = labeled) run_time = time.time() - start_time print("\n --- treelet kernel built in %s seconds ---" % (run_time)) @@ -60,17 +67,17 @@ def treeletkernel(*args, node_label = 'atom', edge_label = 'bond_type', labeled return kernel, run_time -def _treeletkernel_do(G1, G2, node_label = 'atom', edge_label = 'bond_type', labeled = True): +def _treeletkernel_do(canonkey1, canonkey2, node_label = 'atom', edge_label = 'bond_type', labeled = True): """Calculate treelet graph kernel between 2 graphs. Parameters ---------- - G1, G2 : NetworkX graphs - 2 graphs between which the kernel is calculated. + canonkey1, canonkey2 : list + List of canonical keys in 2 graphs, where each key is represented by a string. node_label : string - node attribute used as label. The default node label is atom. + Node attribute used as label. The default node label is atom. edge_label : string - edge attribute used as label. The default edge label is bond_type. + Edge attribute used as label. The default edge label is bond_type. labeled : boolean Whether the graphs are labeled. The default is True. @@ -79,12 +86,9 @@ def _treeletkernel_do(G1, G2, node_label = 'atom', edge_label = 'bond_type', lab kernel : float Treelet Kernel between 2 graphs. """ - canonkey1 = get_canonkeys(G1, node_label = node_label, edge_label = edge_label, labeled = labeled) - canonkey2 = get_canonkeys(G2, node_label = node_label, edge_label = edge_label, labeled = labeled) - keys = set(canonkey1.keys()) & set(canonkey2.keys()) # find same canonical keys in both graphs - vector1 = np.matrix([ (canonkey1[key] if (key in canonkey1.keys()) else 0) for key in keys ]) - vector2 = np.matrix([ (canonkey2[key] if (key in canonkey2.keys()) else 0) for key in keys ]) + vector1 = np.array([ (canonkey1[key] if (key in canonkey1.keys()) else 0) for key in keys ]) + vector2 = np.array([ (canonkey2[key] if (key in canonkey2.keys()) else 0) for key in keys ]) kernel = np.sum(np.exp(- np.square(vector1 - vector2) / 2)) return kernel diff --git a/pygraph/kernels/untildPathKernel.py b/pygraph/kernels/untildPathKernel.py new file mode 100644 index 0000000..8b91536 --- /dev/null +++ b/pygraph/kernels/untildPathKernel.py @@ -0,0 +1,203 @@ +import sys +import pathlib +sys.path.insert(0, "../") +import time + +from collections import Counter + +import networkx as nx +import numpy as np + + +def untildpathkernel(*args, node_label = 'atom', edge_label = 'bond_type', labeled = True, depth = 10, k_func = 'tanimoto'): + """Calculate path graph kernels up to depth d between graphs. + Parameters + ---------- + Gn : List of NetworkX graph + List of graphs between which the kernels are calculated. + / + G1, G2 : NetworkX graphs + 2 graphs between which the kernel is calculated. + node_label : string + node attribute used as label. The default node label is atom. + edge_label : string + edge attribute used as label. The default edge label is bond_type. + labeled : boolean + Whether the graphs are labeled. The default is True. + depth : integer + Depth of search. Longest length of paths. + k_func : function + A kernel function used using different notions of fingerprint similarity. + + Return + ------ + Kmatrix/kernel : Numpy matrix/float + Kernel matrix, each element of which is the path kernel up to d between 2 praphs. / Path kernel up to d between 2 graphs. + """ + depth = int(depth) + if len(args) == 1: # for a list of graphs + Gn = args[0] + Kmatrix = np.zeros((len(Gn), len(Gn))) + + start_time = time.time() + + # get all paths of all graphs before calculating kernels to save time, but this may cost a lot of memory for large dataset. + all_paths = [ find_all_paths_until_length(Gn[i], depth, node_label = node_label, edge_label = edge_label, labeled = labeled) for i in range(0, len(Gn)) ] + + for i in range(0, len(Gn)): + for j in range(i, len(Gn)): + Kmatrix[i][j] = _untildpathkernel_do(all_paths[i], all_paths[j], k_func, node_label = node_label, edge_label = edge_label, labeled = labeled) + Kmatrix[j][i] = Kmatrix[i][j] + + run_time = time.time() - start_time + print("\n --- kernel matrix of path kernel up to %d of size %d built in %s seconds ---" % (depth, len(Gn), run_time)) + + return Kmatrix, run_time + + else: # for only 2 graphs + + start_time = time.time() + + all_paths1 = find_all_paths_until_length(args[0], depth, node_label = node_label, edge_label = edge_label, labeled = labeled) + all_paths2 = find_all_paths_until_length(args[1], depth, node_label = node_label, edge_label = edge_label, labeled = labeled) + + kernel = _untildpathkernel_do(all_paths1, all_paths2, k_func, node_label = node_label, edge_label = edge_label, labeled = labeled) + + run_time = time.time() - start_time + print("\n --- path kernel up to %d built in %s seconds ---" % (depth, run_time)) + + return kernel, run_time + + +def _untildpathkernel_do(paths1, paths2, k_func, node_label = 'atom', edge_label = 'bond_type', labeled = True): + """Calculate path graph kernels up to depth d between 2 graphs. + + Parameters + ---------- + paths1, paths2 : list + List of paths in 2 graphs, where for unlabeled graphs, each path is represented by a list of nodes; while for labeled graphs, each path is represented by a string consists of labels of nodes and edges on that path. + k_func : function + A kernel function used using different notions of fingerprint similarity. + node_label : string + node attribute used as label. The default node label is atom. + edge_label : string + edge attribute used as label. The default edge label is bond_type. + labeled : boolean + Whether the graphs are labeled. The default is True. + + Return + ------ + kernel : float + Treelet Kernel between 2 graphs. + """ + all_paths = list(set(paths1 + paths2)) + + if k_func == 'tanimoto': + vector1 = [ (1 if path in paths1 else 0) for path in all_paths ] + vector2 = [ (1 if path in paths2 else 0) for path in all_paths ] + kernel_uv = np.dot(vector1, vector2) + kernel = kernel_uv / (len(set(paths1)) + len(set(paths2)) - kernel_uv) + + else: # MinMax kernel + path_count1 = Counter(paths1) + path_count2 = Counter(paths2) + vector1 = [ (path_count1[key] if (key in path_count1.keys()) else 0) for key in all_paths ] + vector2 = [ (path_count2[key] if (key in path_count2.keys()) else 0) for key in all_paths ] + kernel = np.sum(np.minimum(vector1, vector2)) / np.sum(np.maximum(vector1, vector2)) + + return kernel + +# this method find paths repetively, it could be faster. +def find_all_paths_until_length(G, length, node_label = 'atom', edge_label = 'bond_type', labeled = True): + """Find all paths with a certain maximum length in a graph. A recursive depth first search is applied. + + Parameters + ---------- + G : NetworkX graphs + The graph in which paths are searched. + length : integer + The maximum length of paths. + node_label : string + node attribute used as label. The default node label is atom. + edge_label : string + edge attribute used as label. The default edge label is bond_type. + labeled : boolean + Whether the graphs are labeled. The default is True. + + Return + ------ + path : list + List of paths retrieved, where for unlabeled graphs, each path is represented by a list of nodes; while for labeled graphs, each path is represented by a string consists of labels of nodes and edges on that path. + """ + all_paths = [] + for i in range(0, length + 1): + new_paths = find_all_paths(G, i) + if new_paths == []: + break + all_paths.extend(new_paths) + + if labeled == True: # convert paths to strings + path_strs = [] + for path in all_paths: + strlist = [ G.node[node][node_label] + G[node][path[path.index(node) + 1]][edge_label] for node in path[:-1] ] + path_strs.append(''.join(strlist) + G.node[path[-1]][node_label]) + + return path_strs + + return all_paths + + +def find_paths(G, source_node, length): + """Find all paths with a certain length those start from a source node. A recursive depth first search is applied. + + Parameters + ---------- + G : NetworkX graphs + The graph in which paths are searched. + source_node : integer + The number of the node from where all paths start. + length : integer + The length of paths. + + Return + ------ + path : list of list + List of paths retrieved, where each path is represented by a list of nodes. + """ + return [[source_node]] if length == 0 else \ + [ [source_node] + path for neighbor in G[source_node] \ + for path in find_paths(G, neighbor, length - 1) if source_node not in path ] + + +def find_all_paths(G, length): + """Find all paths with a certain length in a graph. A recursive depth first search is applied. + + Parameters + ---------- + G : NetworkX graphs + The graph in which paths are searched. + length : integer + The length of paths. + + Return + ------ + path : list of list + List of paths retrieved, where each path is represented by a list of nodes. + """ + all_paths = [] + for node in G: + all_paths.extend(find_paths(G, node, length)) + + ### The following process is not carried out according to the original article + # all_paths_r = [ path[::-1] for path in all_paths ] + + + # # For each path, two presentation are retrieved from its two extremities. Remove one of them. + # for idx, path in enumerate(all_paths[:-1]): + # for path2 in all_paths_r[idx+1::]: + # if path == path2: + # all_paths[idx] = [] + # break + + # return list(filter(lambda a: a != [], all_paths)) + return all_paths \ No newline at end of file diff --git a/pygraph/utils/__pycache__/utils.cpython-35.pyc b/pygraph/utils/__pycache__/utils.cpython-35.pyc index c35566f..0710a16 100644 Binary files a/pygraph/utils/__pycache__/utils.cpython-35.pyc and b/pygraph/utils/__pycache__/utils.cpython-35.pyc differ diff --git a/pygraph/utils/utils.py b/pygraph/utils/utils.py index 91e4d87..1dbb584 100644 --- a/pygraph/utils/utils.py +++ b/pygraph/utils/utils.py @@ -170,10 +170,10 @@ def kernel_train_test(datafile, kernel_file_path, kernel_func, kernel_para, tria test_stds_list.append(test_std) print('\n') - table_dict = {'RMSE_test': test_means_list, 'std_test': test_stds_list, \ - 'RMSE_train': train_means_list, 'std_train': train_stds_list, 'k_time': kernel_time_list} + table_dict = {'rmse_test': test_means_list, 'std_test': test_stds_list, \ + 'rmse_train': train_means_list, 'std_train': train_stds_list, 'k_time': kernel_time_list} if hyper_name == '': - keyorder = ['RMSE_test', 'std_test', 'RMSE_train', 'std_train', 'k_time'] + keyorder = ['rmse_test', 'std_test', 'rmse_train', 'std_train', 'k_time'] else: table_dict[hyper_name] = hyper_range