Skip to content

Commit 1de4db1

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 1dc7b1d84a668a08453effc83d4391f12002be96
1 parent bddad35 commit 1de4db1

File tree

1,073 files changed

+3291
-3291
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,073 files changed

+3291
-3291
lines changed
104 Bytes
Binary file not shown.
104 Bytes
Binary file not shown.

dev/_downloads/plot_omp.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +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# 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()"
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], use_line_collection=True)\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], use_line_collection=True)\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], use_line_collection=True)\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], use_line_collection=True)\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()"
3030
]
3131
}
3232
],

dev/_downloads/plot_omp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
plt.subplot(4, 1, 1)
3939
plt.xlim(0, 512)
4040
plt.title("Sparse signal")
41-
plt.stem(idx, w[idx])
41+
plt.stem(idx, w[idx], use_line_collection=True)
4242

4343
# plot the noise-free reconstruction
4444
omp = OrthogonalMatchingPursuit(n_nonzero_coefs=n_nonzero_coefs)
@@ -48,7 +48,7 @@
4848
plt.subplot(4, 1, 2)
4949
plt.xlim(0, 512)
5050
plt.title("Recovered signal from noise-free measurements")
51-
plt.stem(idx_r, coef[idx_r])
51+
plt.stem(idx_r, coef[idx_r], use_line_collection=True)
5252

5353
# plot the noisy reconstruction
5454
omp.fit(X, y_noisy)
@@ -57,7 +57,7 @@
5757
plt.subplot(4, 1, 3)
5858
plt.xlim(0, 512)
5959
plt.title("Recovered signal from noisy measurements")
60-
plt.stem(idx_r, coef[idx_r])
60+
plt.stem(idx_r, coef[idx_r], use_line_collection=True)
6161

6262
# plot the noisy reconstruction with number of non-zeros set by CV
6363
omp_cv = OrthogonalMatchingPursuitCV(cv=5)
@@ -67,7 +67,7 @@
6767
plt.subplot(4, 1, 4)
6868
plt.xlim(0, 512)
6969
plt.title("Recovered signal from noisy measurements with CV")
70-
plt.stem(idx_r, coef[idx_r])
70+
plt.stem(idx_r, coef[idx_r], use_line_collection=True)
7171

7272
plt.subplots_adjust(0.06, 0.04, 0.94, 0.90, 0.20, 0.38)
7373
plt.suptitle('Sparse signal recovery with Orthogonal Matching Pursuit',

dev/_downloads/scikit-learn-docs.pdf

9.96 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes
586 Bytes
586 Bytes
-471 Bytes
-471 Bytes

0 commit comments

Comments
 (0)