Skip to content

Instantly share code, notes, and snippets.

@choldgraf
Last active August 29, 2015 14:07
Show Gist options
  • Save choldgraf/6a7be7866f2a3a3d3f98 to your computer and use it in GitHub Desktop.
Save choldgraf/6a7be7866f2a3a3d3f98 to your computer and use it in GitHub Desktop.
GridSearchCV memory usage
{
"metadata": {
"name": "",
"signature": "sha256:dfb7fdbd72babce26c85e0d1420b1e20600c1dd13eb385470e9a3bc420f2bf64"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sklearn import grid_search, linear_model\n",
"import numpy as np\n",
"%load_ext memory_profiler"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"X = np.random.randn(24000, 2000)\n",
"w = np.random.randn(2000)\n",
"y = np.dot(X, w)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"lsqr"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"rid = linear_model.Ridge(solver='lsqr')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit rid.fit(X, y)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 800.43 MiB, increment: 367.09 MiB\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit [rid.fit(X, y) for _ in range(4)]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 1899.48 MiB, increment: 1465.39 MiB\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit [rid.fit(X, y) for _ in range(8)]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 2726.49 MiB, increment: 2291.86 MiB\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"sparse_cg"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"rid = linear_model.Ridge(solver='sparse_cg')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit rid.fit(X, y)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 789.27 MiB, increment: 366.42 MiB\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit [rid.fit(X, y) for _ in range(4)]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 1888.10 MiB, increment: 1464.92 MiB\n"
]
}
],
"prompt_number": 10
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit [rid.fit(X, y) for _ in range(8)]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 3352.96 MiB, increment: 2929.69 MiB\n"
]
}
],
"prompt_number": 11
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Cholesky"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"rid = linear_model.Ridge(solver='cholesky')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 12
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit rid.fit(X, y)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 859.59 MiB, increment: 436.30 MiB\n"
]
}
],
"prompt_number": 13
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit [rid.fit(X, y) for _ in range(4)]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 859.64 MiB, increment: 366.24 MiB\n"
]
}
],
"prompt_number": 14
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%memit [rid.fit(X, y) for _ in range(8)]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"peak memory: 859.64 MiB, increment: 366.21 MiB\n"
]
}
],
"prompt_number": 15
},
{
"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