Created
December 11, 2014 18:40
-
-
Save amueller/5bbbe6275ef7f94f87cb to your computer and use it in GitHub Desktop.
Shuffle once benchmarks
This file contains hidden or 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
| { | |
| "metadata": { | |
| "name": "sgdclassifier shuffling" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "from sklearn.linear_model import SGDClassifier\nfrom sklearn.datasets import fetch_mldata", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 2 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "mnist = fetch_mldata(\"MNIST original\")\nX, y = mnist.data / 255., mnist.target", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 3 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "%timeit SGDClassifier(shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle=True, shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle_once=True).fit(X, y)\n%timeit SGDClassifier(shuffle_once=False, shuffle=2).fit(X, y)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "1 loops, best of 3: 2.8 s per loop\n1 loops, best of 3: 3.32 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n1 loops, best of 3: 3.48 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n1 loops, best of 3: 3.64 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n" | |
| } | |
| ], | |
| "prompt_number": 4 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "%timeit SGDClassifier(shuffle_once=False, n_iter=100).fit(X, y)\n%timeit SGDClassifier(shuffle=True, n_iter=100, shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle_once=True, n_iter=100).fit(X, y)\n%timeit SGDClassifier(shuffle_once=False, shuffle=2, n_iter=100).fit(X, y)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "1 loops, best of 3: 10.2 s per loop\n1 loops, best of 3: 12.8 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n1 loops, best of 3: 10.6 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n1 loops, best of 3: 13 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n" | |
| } | |
| ], | |
| "prompt_number": 15 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "from sklearn.datasets import load_digits\ndigits = load_digits()\nX, y = digits.data / 16., digits.target", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 4 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "%timeit SGDClassifier(shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle=True, shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle_once=True).fit(X, y)\n%timeit SGDClassifier(shuffle_once=False, shuffle=2).fit(X, y)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "100 loops, best of 3: 7.87 ms per loop\n100 loops, best of 3: 9.23 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n100 loops, best of 3: 9.29 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n100 loops, best of 3: 8.84 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n" | |
| } | |
| ], | |
| "prompt_number": 5 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "%timeit SGDClassifier(shuffle_once=False, n_iter=100).fit(X, y)\n%timeit SGDClassifier(shuffle=True, n_iter=100, shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle_once=True, n_iter=100).fit(X, y)\n%timeit SGDClassifier(shuffle_once=False, shuffle=2, n_iter=100).fit(X, y)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "10 loops, best of 3: 137 ms per loop\n10 loops, best of 3: 161 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n10 loops, best of 3: 134 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n10 loops, best of 3: 152 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n" | |
| } | |
| ], | |
| "prompt_number": 7 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "from sklearn.datasets import fetch_20newsgroups_vectorized", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 8 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "news = fetch_20newsgroups_vectorized()", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 9 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "news.data.shape", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 10, | |
| "text": "(11314, 130107)" | |
| } | |
| ], | |
| "prompt_number": 10 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "X, y = news.data, news.target", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 11 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "%timeit SGDClassifier(shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle=True, shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle_once=True).fit(X, y)\n%timeit SGDClassifier(shuffle_once=False, shuffle=2).fit(X, y)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "1 loops, best of 3: 550 ms per loop\n1 loops, best of 3: 654 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n1 loops, best of 3: 582 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n1 loops, best of 3: 630 ms per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n" | |
| } | |
| ], | |
| "prompt_number": 13 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "%timeit SGDClassifier(shuffle_once=False, n_iter=100).fit(X, y)\n%timeit SGDClassifier(shuffle=True, n_iter=100, shuffle_once=False).fit(X, y)\n%timeit SGDClassifier(shuffle_once=False, n_iter=100, shuffle=2).fit(X, y)\n%timeit SGDClassifier(shuffle_once=False, shuffle=2, n_iter=100).fit(X, y)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "1 loops, best of 3: 10.5 s per loop\n1 loops, best of 3: 12.3 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n1 loops, best of 3: 12.4 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n1 loops, best of 3: 12.9 s per loop" | |
| }, | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "\n" | |
| } | |
| ], | |
| "prompt_number": 14 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [] | |
| } | |
| ], | |
| "metadata": {} | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment