Skip to content

Commit 07969a7

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 8342548ae18b36d814440b46ed154c96bd8e15ce
1 parent f148214 commit 07969a7

File tree

1,090 files changed

+3316
-3448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,090 files changed

+3316
-3448
lines changed
-936 Bytes
Binary file not shown.
-209 Bytes
Binary file not shown.

dev/_downloads/plot_omp.ipynb

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,62 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"print(__doc__)\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom sklearn.linear_model import OrthogonalMatchingPursuit\nfrom sklearn.linear_model import OrthogonalMatchingPursuitCV\nfrom sklearn.datasets import make_sparse_coded_signal\n\nn_components, n_features = 512, 100\nn_nonzero_coefs = 17\n\n# generate the data\n###################\n\n# y = Xw\n# |x|_0 = n_nonzero_coefs\n\ny, X, w = make_sparse_coded_signal(n_samples=1,\n n_components=n_components,\n n_features=n_features,\n n_nonzero_coefs=n_nonzero_coefs,\n random_state=0)\n\nidx, = w.nonzero()\n\n# distort the clean signal"
30-
]
31-
},
32-
{
33-
"cell_type": "code",
34-
"execution_count": null,
35-
"metadata": {
36-
"collapsed": false
37-
},
38-
"outputs": [],
39-
"source": [
40-
"y_noisy = y + 0.05 * np.random.randn(len(y))\n\n# plot the sparse signal"
41-
]
42-
},
43-
{
44-
"cell_type": "code",
45-
"execution_count": null,
46-
"metadata": {
47-
"collapsed": false
48-
},
49-
"outputs": [],
50-
"source": [
51-
"plt.figure(figsize=(7, 7))\nplt.subplot(4, 1, 1)\nplt.xlim(0, 512)\nplt.title(\"Sparse signal\")\nplt.stem(idx, w[idx])\n\n# plot the noise-free reconstruction"
52-
]
53-
},
54-
{
55-
"cell_type": "code",
56-
"execution_count": null,
57-
"metadata": {
58-
"collapsed": false
59-
},
60-
"outputs": [],
61-
"source": [
62-
"omp = OrthogonalMatchingPursuit(n_nonzero_coefs=n_nonzero_coefs)\nomp.fit(X, y)\ncoef = omp.coef_\nidx_r, = coef.nonzero()\nplt.subplot(4, 1, 2)\nplt.xlim(0, 512)\nplt.title(\"Recovered signal from noise-free measurements\")\nplt.stem(idx_r, coef[idx_r])\n\n# plot the noisy reconstruction"
63-
]
64-
},
65-
{
66-
"cell_type": "code",
67-
"execution_count": null,
68-
"metadata": {
69-
"collapsed": false
70-
},
71-
"outputs": [],
72-
"source": [
73-
"omp.fit(X, y_noisy)\ncoef = omp.coef_\nidx_r, = coef.nonzero()\nplt.subplot(4, 1, 3)\nplt.xlim(0, 512)\nplt.title(\"Recovered signal from noisy measurements\")\nplt.stem(idx_r, coef[idx_r])\n\n# plot the noisy reconstruction with number of non-zeros set by CV"
74-
]
75-
},
76-
{
77-
"cell_type": "code",
78-
"execution_count": null,
79-
"metadata": {
80-
"collapsed": false
81-
},
82-
"outputs": [],
83-
"source": [
84-
"omp_cv = OrthogonalMatchingPursuitCV(cv=5)\nomp_cv.fit(X, y_noisy)\ncoef = omp_cv.coef_\nidx_r, = coef.nonzero()\nplt.subplot(4, 1, 4)\nplt.xlim(0, 512)\nplt.title(\"Recovered signal from noisy measurements with CV\")\nplt.stem(idx_r, coef[idx_r])\n\nplt.subplots_adjust(0.06, 0.04, 0.94, 0.90, 0.20, 0.38)\nplt.suptitle('Sparse signal recovery with Orthogonal Matching Pursuit',\n fontsize=16)\nplt.show()"
29+
"print(__doc__)\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom sklearn.linear_model import OrthogonalMatchingPursuit\nfrom sklearn.linear_model import OrthogonalMatchingPursuitCV\nfrom sklearn.datasets import make_sparse_coded_signal\n\nn_components, n_features = 512, 100\nn_nonzero_coefs = 17\n\n# generate the data\n\n# y = Xw\n# |x|_0 = n_nonzero_coefs\n\ny, X, w = make_sparse_coded_signal(n_samples=1,\n n_components=n_components,\n n_features=n_features,\n n_nonzero_coefs=n_nonzero_coefs,\n random_state=0)\n\nidx, = w.nonzero()\n\n# distort the clean signal\ny_noisy = y + 0.05 * np.random.randn(len(y))\n\n# plot the sparse signal\nplt.figure(figsize=(7, 7))\nplt.subplot(4, 1, 1)\nplt.xlim(0, 512)\nplt.title(\"Sparse signal\")\nplt.stem(idx, w[idx])\n\n# plot the noise-free reconstruction\nomp = OrthogonalMatchingPursuit(n_nonzero_coefs=n_nonzero_coefs)\nomp.fit(X, y)\ncoef = omp.coef_\nidx_r, = coef.nonzero()\nplt.subplot(4, 1, 2)\nplt.xlim(0, 512)\nplt.title(\"Recovered signal from noise-free measurements\")\nplt.stem(idx_r, coef[idx_r])\n\n# plot the noisy reconstruction\nomp.fit(X, y_noisy)\ncoef = omp.coef_\nidx_r, = coef.nonzero()\nplt.subplot(4, 1, 3)\nplt.xlim(0, 512)\nplt.title(\"Recovered signal from noisy measurements\")\nplt.stem(idx_r, coef[idx_r])\n\n# plot the noisy reconstruction with number of non-zeros set by CV\nomp_cv = OrthogonalMatchingPursuitCV(cv=5)\nomp_cv.fit(X, y_noisy)\ncoef = omp_cv.coef_\nidx_r, = coef.nonzero()\nplt.subplot(4, 1, 4)\nplt.xlim(0, 512)\nplt.title(\"Recovered signal from noisy measurements with CV\")\nplt.stem(idx_r, coef[idx_r])\n\nplt.subplots_adjust(0.06, 0.04, 0.94, 0.90, 0.20, 0.38)\nplt.suptitle('Sparse signal recovery with Orthogonal Matching Pursuit',\n fontsize=16)\nplt.show()"
8530
]
8631
}
8732
],

dev/_downloads/plot_omp.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
n_nonzero_coefs = 17
1919

2020
# generate the data
21-
###################
2221

2322
# y = Xw
2423
# |x|_0 = n_nonzero_coefs
@@ -32,20 +31,16 @@
3231
idx, = w.nonzero()
3332

3433
# distort the clean signal
35-
##########################
3634
y_noisy = y + 0.05 * np.random.randn(len(y))
3735

3836
# plot the sparse signal
39-
########################
4037
plt.figure(figsize=(7, 7))
4138
plt.subplot(4, 1, 1)
4239
plt.xlim(0, 512)
4340
plt.title("Sparse signal")
4441
plt.stem(idx, w[idx])
4542

4643
# plot the noise-free reconstruction
47-
####################################
48-
4944
omp = OrthogonalMatchingPursuit(n_nonzero_coefs=n_nonzero_coefs)
5045
omp.fit(X, y)
5146
coef = omp.coef_
@@ -56,7 +51,6 @@
5651
plt.stem(idx_r, coef[idx_r])
5752

5853
# plot the noisy reconstruction
59-
###############################
6054
omp.fit(X, y_noisy)
6155
coef = omp.coef_
6256
idx_r, = coef.nonzero()
@@ -66,7 +60,6 @@
6660
plt.stem(idx_r, coef[idx_r])
6761

6862
# plot the noisy reconstruction with number of non-zeros set by CV
69-
##################################################################
7063
omp_cv = OrthogonalMatchingPursuitCV(cv=5)
7164
omp_cv.fit(X, y_noisy)
7265
coef = omp_cv.coef_

dev/_downloads/scikit-learn-docs.pdf

8.73 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes
-310 Bytes
-310 Bytes
-639 Bytes
-639 Bytes

0 commit comments

Comments
 (0)