Mercurial > hg > plosone_underreview
diff notebooks/sensitivity_experiment.ipynb @ 82:4395037087b6 branch-tests
notebooks
author | mpanteli <m.x.panteli@gmail.com> |
---|---|
date | Tue, 26 Sep 2017 21:18:26 +0100 |
parents | 92a5e280946d |
children | e279ccea5f9b |
line wrap: on
line diff
--- a/notebooks/sensitivity_experiment.ipynb Tue Sep 26 14:37:28 2017 +0100 +++ b/notebooks/sensitivity_experiment.ipynb Tue Sep 26 21:18:26 2017 +0100 @@ -3,11 +3,16 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { + "name": "stdout", + "output_type": "stream", + "text": [ + "ERROR! Session/line number was not unique in database. History logging moved to new session 32\n" + ] + }, + { "name": "stderr", "output_type": "stream", "text": [ @@ -37,9 +42,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "OUTPUT_FILES = load_dataset.OUTPUT_FILES\n", @@ -49,9 +52,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -72,9 +73,7 @@ { "cell_type": "code", "execution_count": 48, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -284,9 +283,7 @@ { "cell_type": "code", "execution_count": 52, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -455,9 +452,7 @@ { "cell_type": "code", "execution_count": 56, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -480,9 +475,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -741,9 +734,7 @@ { "cell_type": "code", "execution_count": 47, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -842,9 +833,7 @@ { "cell_type": "code", "execution_count": 59, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -4591,9 +4580,7 @@ { "cell_type": "code", "execution_count": 21, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -4943,9 +4930,7 @@ { "cell_type": "code", "execution_count": 52, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -5271,9 +5256,7 @@ { "cell_type": "code", "execution_count": 67, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -5613,7 +5596,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 7, "metadata": { "collapsed": true }, @@ -5630,10 +5613,8 @@ }, { "cell_type": "code", - "execution_count": 69, - "metadata": { - "collapsed": false - }, + "execution_count": 8, + "metadata": {}, "outputs": [ { "data": { @@ -5641,7 +5622,7 @@ "(137, 10)" ] }, - "execution_count": 69, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -5659,10 +5640,8 @@ }, { "cell_type": "code", - "execution_count": 70, - "metadata": { - "collapsed": false - }, + "execution_count": 9, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -5702,6 +5681,7 @@ "first_zero_idx = np.min(zero_idx)\n", "ranked_countries = ranked_countries.iloc[:first_zero_idx, :]\n", "ranked_outliers = ranked_outliers.iloc[:first_zero_idx, :]\n", + "ranked_countries_arr = ranked_countries.get_values()\n", "\n", "print ranked_countries.head()\n", "print ranked_outliers.head()" @@ -5737,9 +5717,7 @@ { "cell_type": "code", "execution_count": 72, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -5756,9 +5734,7 @@ { "cell_type": "code", "execution_count": 80, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -5787,9 +5763,7 @@ { "cell_type": "code", "execution_count": 81, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -5824,9 +5798,7 @@ { "cell_type": "code", "execution_count": 76, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -5844,11 +5816,16 @@ ] }, { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Try precision at K" + ] + }, + { "cell_type": "code", - "execution_count": 97, - "metadata": { - "collapsed": true - }, + "execution_count": 10, + "metadata": {}, "outputs": [], "source": [ "# majority voting + precision at K (top5?)\n", @@ -5859,10 +5836,8 @@ }, { "cell_type": "code", - "execution_count": 98, - "metadata": { - "collapsed": false - }, + "execution_count": 11, + "metadata": {}, "outputs": [ { "data": { @@ -5915,7 +5890,7 @@ "4 Bhutan 7" ] }, - "execution_count": 98, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -5927,10 +5902,8 @@ }, { "cell_type": "code", - "execution_count": 99, - "metadata": { - "collapsed": false - }, + "execution_count": 12, + "metadata": {}, "outputs": [ { "data": { @@ -6067,7 +6040,7 @@ "9 Malta 1" ] }, - "execution_count": 99, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -6078,20 +6051,15 @@ }, { "cell_type": "code", - "execution_count": 102, - "metadata": { - "collapsed": false - }, + "execution_count": 14, + "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "0.51000000000000001" - ] - }, - "execution_count": 102, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "0.51 0.0830662386292\n" + ] } ], "source": [ @@ -6104,7 +6072,27 @@ "for j in range(ranked_countries_arr.shape[1]):\n", " p_.append(precision_at_k(ranked_countries_arr[:, j], ground_truth, k))\n", "p_ = np.array(p_)\n", - "np.mean(p_)" + "print np.mean(p_), np.std(p_)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 0.6, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.4, 0.7, 0.4])" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "p_" ] }, { @@ -6133,7 +6121,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.11" + "version": "2.7.12" } }, "nbformat": 4,