{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from sklearn.metrics import f1_score as sklearn_f1\n", "from autotagger.evaluation import basic" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "predicted,actual = basic.build_dummy_pred_test_pair()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "0.7000000000000001" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# manually calculating f1 score and averaging the results for each instance\n", "basic.get_samples_f1(predicted,actual)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "0.70000000000000007" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sklearn_f1(actual,predicted,average='samples')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "0.7142857142857143" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "basic.get_micro_f1(predicted,actual)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "0.7142857142857143" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sklearn_f1(actual,predicted,average='micro')" ] } ], "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 }