Created
June 13, 2016 18:27
-
-
Save karlnapf/3c5ddc7dbb85879efdfe89c238acfe5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.\n", | |
" warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')\n" | |
] | |
} | |
], | |
"source": [ | |
"from modshogun import *\n", | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"%matplotlib inline\n", | |
"import time" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"# use scipy for generating samples\n", | |
"from scipy.stats import norm, laplace\n", | |
"\n", | |
"def sample_gaussian_vs_laplace(n=220, mu=0.0, sigma2=1, b=np.sqrt(0.5)): \n", | |
" # sample from both distributions\n", | |
" X=norm.rvs(size=n, loc=mu, scale=sigma2)\n", | |
" Y=laplace.rvs(size=n, loc=mu, scale=b)\n", | |
" \n", | |
" return X,Y" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"(10,) (10,)\n" | |
] | |
} | |
], | |
"source": [ | |
"X,Y = sample_gaussian_vs_laplace(n=10)\n", | |
"print X.shape, Y.shape\n", | |
"samples_p = RealFeatures(X.reshape(1,len(X)))\n", | |
"samples_q = RealFeatures(Y.reshape(1,len(Y)))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"True\n" | |
] | |
} | |
], | |
"source": [ | |
"mmd = QuadraticTimeMMD(samples_p, samples_q)\n", | |
"alpha = 0.05\n", | |
"sigma = 0.25\n", | |
"num_runs = 1\n", | |
"train_test_ratio = 4\n", | |
"mmd.set_statistic_type(ST_BIASED_FULL)\n", | |
"mmd.set_null_approximation_method(NAM_PERMUTATION)\n", | |
"mmd.set_variance_estimation_method(VEM_DIRECT)\n", | |
"\n", | |
"mmd.set_kernel(GaussianKernel(10, 2*sigma**2))\n", | |
"mmd.set_train_test_mode(True)\n", | |
"mmd.set_train_test_ratio(train_test_ratio)\n", | |
"# the following computes statistic on the test-dataset\n", | |
"statistic = mmd.compute_statistic()\n", | |
"# the following performs test on the test-dataset\n", | |
"rejected = mmd.perform_test(alpha)\n", | |
"print rejected\n", | |
"mmd.set_train_test_mode(False)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"taus = 2**np.linspace(-5, 5, 5)\n", | |
"#taus = np.array([1, 10])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"# shogun cross validation\n", | |
"def shogun_xval(num_samples = 125, num_folds = 5, num_runs = 100, alpha = 0.05):\n", | |
" X,Y = sample_gaussian_vs_laplace(n = num_samples)\n", | |
" samples_p = RealFeatures(X.reshape(1, len(X)))\n", | |
" samples_q = RealFeatures(Y.reshape(1, len(Y)))\n", | |
" \n", | |
" train_test_ratio = num_folds-1\n", | |
"\n", | |
" mmd = QuadraticTimeMMD(samples_p, samples_q) \n", | |
" mmd.set_train_test_mode(True)\n", | |
" mmd.set_train_test_ratio(train_test_ratio) \n", | |
"\n", | |
" for tau in taus:\n", | |
" mmd.add_kernel(GaussianKernel(10, tau))\n", | |
"\n", | |
" mmd.set_kernel_selection_strategy(KSM_MAXIMIZE_XVALIDATION, num_runs, alpha)\n", | |
" mmd.select_kernel()\n", | |
" \n", | |
" strategy = mmd.get_kernel_selection_strategy()\n", | |
" measure_vec = strategy.get_measure_vector()\n", | |
" measure_mat = strategy.get_measure_matrix() \n", | |
" \n", | |
" selected_kernel = GaussianKernel.obtain_from_generic(mmd.get_kernel())\n", | |
" print np.log2(selected_kernel.get_width())\n", | |
"\n", | |
" # the following computes statistic on the test-dataset\n", | |
" #statistic = mmd.compute_statistic()\n", | |
" # the following performs test on the test-dataset\n", | |
" #rejected = mmd.perform_test(alpha)\n", | |
" #print rejected\n", | |
" mmd.set_train_test_mode(False)\n", | |
" \n", | |
" return taus, measure_mat" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0.0\n" | |
] | |
} | |
], | |
"source": [ | |
"taus, measure = shogun_xval(num_samples = 120, num_folds = 3, num_runs = 20)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(0, 1)" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAEPCAYAAACgFqixAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGodJREFUeJzt3Xu0XWV57/HvLwmIKJeCHgqJMYIgiiCoRByiDUUkYAFP\nbxJ6PEI9bSoXpXQgFy8wjlJA7ZCL1RqKSalVbAUkVFRATT14QBANREwgiMEQ7liiYJUkPP1jzm2W\ni7V23p295ppzvuv3GWMN9lx77pnnY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1w1d4Gki8rnF0r6lKSbJN0jaY6kRZJ+JOmz\nHcf/lKRbyhvF9FwszKwuLgZmG80F1kTEfhGxD/CbZRck7UyxsuxsikXOultH20fE64FTKNYn+mhE\nvALYR9I+5T5nRsRsipuMzCkXJzRrBBcDs42WAYdIOlfSgV03ApkNLImItRGxAfi3rp+9puMYD0bE\n2IJgd1KsRgtwtKTbgB8ArygfZo3QtoXqzCoTESvLltDhwIclfZPfvvHJeAsHjq3C+kzH12Pb08qb\nw/wN8JqI+LmkhcBWg4rdbLJ8ZmBWKltB/1XedOfjFDcGGXMrxV32tivX+P+j8Q7V47ltgSeBX0ja\nCThsQGGbDYTPDMw22hv4mKRngKcp7rn9cYCIeEDS3wK3AD8DVgBry5/r/khedH8dEXdIWkpxH+HV\nwI1VJWG2OfzRUrNEkp4XEU9JmgpcRXH/gpzu/mUjzG0is3Rnlzd5WQbc60JgOfGZgZmZ+czAzMxc\nDMzMDBcDMzPDxcDMzHAxMDMzXAzMzAz4by8Wq1hY8y0YAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x7fae9524e950>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"test_powers = np.mean(measure, 0)\n", | |
"plt.plot(np.log2(taus), test_powers)\n", | |
"plt.xlabel(\"sigma\")\n", | |
"plt.ylabel(\"test power\")\n", | |
"plt.grid(True)\n", | |
"plt.ylim([0, 1])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"def get_test_power_xval(width = 2*0.5**2, num_runs = 10, num_folds = 3, num_samples = 300, alpha = 0.05):\n", | |
" X,Y = sample_gaussian_vs_laplace(num_samples)\n", | |
" test_power = []\n", | |
" for _ in range(num_runs):\n", | |
" inds_x = np.random.permutation(len(X))\n", | |
" inds_y = np.random.permutation(len(Y)) \n", | |
"\n", | |
" for k in range(num_folds):\n", | |
" binsize = num_samples/num_folds\n", | |
" train_inds_x = inds_x[(k*binsize):((k+1)*binsize)]\n", | |
" train_inds_y = inds_y[(k*binsize):((k+1)*binsize)]\n", | |
" \n", | |
" train_inds_x = np.setdiff1d(inds_x, train_inds_x)\n", | |
" train_inds_y = np.setdiff1d(inds_y, train_inds_y)\n", | |
" \n", | |
" X_train = X[train_inds_x]\n", | |
" Y_train = Y[train_inds_y] \n", | |
"\n", | |
" samples_p = RealFeatures(X_train.reshape(1, len(X_train)))\n", | |
" samples_q = RealFeatures(Y_train.reshape(1, len(X_train)))\n", | |
"\n", | |
" mmd=QuadraticTimeMMD(samples_p, samples_q) \n", | |
" mmd.set_kernel(GaussianKernel(10, width))\n", | |
" test_power += [mmd.perform_test(alpha)]\n", | |
"\n", | |
" return test_power" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[0.056666666666666664, 0.70499999999999996, 0.040000000000000001, 0.021666666666666667, 0.013333333333333334]\n" | |
] | |
} | |
], | |
"source": [ | |
"# compute test power for one kernel\n", | |
"\n", | |
"test_powers = []\n", | |
"for tau in taus:\n", | |
" test_power = get_test_power_xval(width = tau, num_runs=200, num_samples = 150)\n", | |
" test_powers += [np.mean(test_power)]\n", | |
"print test_powers" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(0, 1)" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAEPCAYAAACgFqixAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYHVW1/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LZ8ZmJXKVtC/ykV3jqJY\nGKTH9RSr7C1ezvG/3WCH6ue5xYDngeckLQtsVVPYZrXwmYHZ69YEjpT0KvAyxZrbRwFExOOSDgWu\nA/4B3A08U76v7yV50ffvEXGbpFso1hF+BLiqqSTMRsKXlppVJGnhiHhB0jzALyjWL8hp9S8bw9wm\nMqvu4HKRl9uBB10ILCc+MzAzM58ZmJmZi4GZmeFiYGZmuBiYmRkuBmZmhouBmZkB/x+N4GqHODke\nUQAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x7fae9524e610>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"plt.plot(np.log2(taus), test_powers)\n", | |
"plt.xlabel(\"sigma\")\n", | |
"plt.ylabel(\"test power\")\n", | |
"plt.grid(True)\n", | |
"plt.ylim([0, 1])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"def get_test_power_new_data(width = 2*0.5**2, num_runs = 100, num_samples = 100, alpha = 0.05): \n", | |
" test_power = []\n", | |
" for _ in range(num_runs):\n", | |
" #X = norm.rvs(size=num_samples, loc=0.0, scale=1)\n", | |
" #Y = norm.rvs(size=num_samples, loc=1.0, scale=1)\n", | |
" \n", | |
" X,Y = sample_gaussian_vs_laplace(num_samples)\n", | |
" samples_p = RealFeatures(X.reshape(1, len(X)))\n", | |
" samples_q = RealFeatures(Y.reshape(1, len(Y)))\n", | |
"\n", | |
" mmd=QuadraticTimeMMD(samples_p, samples_q) \n", | |
" mmd.set_kernel(GaussianKernel(10, width))\n", | |
" test_power += [mmd.perform_test(alpha)]\n", | |
" return test_power" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[0.31, 0.44, 0.37, 0.059999999999999998, 0.080000000000000002]\n" | |
] | |
} | |
], | |
"source": [ | |
"# compute test power for one kernel\n", | |
"\n", | |
"\n", | |
"test_powers = []\n", | |
"for tau in taus:\n", | |
" test_power = get_test_power_new_data(width = tau)\n", | |
" test_powers += [np.mean(test_power)]\n", | |
"print test_powers" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEPCAYAAAC3NDh4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XvcZXPd//HX2/EOlZQfv4hJIkWFkqKacnNPyanj5O5A\nxUiSpB9xK9WvX+mgdLgZOUx30tQtQmkipSKHwRDTDBM5Ralu5BCN8f79sdawXXMd1jXXXnvtva73\n8/HYj9nrtNfn+1hz7c9e389a3yXbREREDGeFpgOIiIj+lSQREREjSpKIiIgRJUlERMSIkiQiImJE\nSRIRETGi2pOEpGmSFkq6QdKho6z3UkmLJb2xY97Nkq6RNE/S5XXHGhERT7RSnR8uaQXg68AOwB3A\nXEln2V44zHqfA3465CMeBabavrvOOCMiYnh1n0lsAyyyfYvtxcBsYLdh1vsgcDpw15D5Il1iERGN\nqfsLeD3gto7p28t5j5H0TGB328dRJIVOBs6XNFfSPrVGGhERy6i1u6mirwCdtYrORLGd7TslrU2R\nLBbYvqi34UVETF51J4k/Aht0TK9fzuv0EmC2JAHPAF4nabHts23fCWD7L5LOpOi+WiZJSMoAVBER\n42R7aO/NMupOEnOBjSVtCNwJTAfe3rmC7Y2Wvpd0CnCO7bMlrQasYPt+SasDOwGfHGlHVRo7iCQd\nZfuopuOoS9o32NK+wVX1x3WtScL2EkkHAOdR1D9Osr1A0oxisU8YuknH+3WAM8uGrAR8x/Z5dcbb\np6Y0HUDNpjQdQM2mNB1AzaY0HUDNpjQdQNNqr0nYngNsO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J\nEhERMaIkiYiIGFGSREREjChJIiIiRpQkERERI/r/VbqCeNX/kj8AAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x7fae8f18ad50>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"plt.plot(np.log2(taus), test_powers)\n", | |
"plt.xlabel(\"width\")\n", | |
"plt.ylabel(\"test power\")\n", | |
"plt.grid(True)\n", | |
"#plt.ylim([0, 1])" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"collapsed": true | |
}, | |
"source": [ | |
"# TODO\n", | |
"\n", | |
"try:\n", | |
" * max mmd\n", | |
" * max test power\n", | |
" * weighted version and plain (single kernel)\n", | |
" * median\n", | |
" * xvalidation (above)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment