Skip to content

Commit 49af9c3

Browse files
committed
Pushing the docs to dev/ for branch: main, commit c176beadf8a0afa372897a6af1f02864e72071a3
1 parent 3d2243c commit 49af9c3

File tree

1,217 files changed

+4368
-4376
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,217 files changed

+4368
-4376
lines changed

dev/_downloads/006fc185672e58b056a5c134db26935c/plot_coin_segmentation.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-
"# Author: Gael Varoquaux <[email protected]>\n# Brian Cheung\n# Andrew Knyazev <[email protected]>\n# License: BSD 3 clause\n\nimport time\n\nimport numpy as np\nfrom scipy.ndimage.filters import gaussian_filter\nimport matplotlib.pyplot as plt\nfrom skimage.data import coins\nfrom skimage.transform import rescale\n\nfrom sklearn.feature_extraction import image\nfrom sklearn.cluster import spectral_clustering\n\n\n# load the coins as a numpy array\norig_coins = coins()\n\n# Resize it to 20% of the original size to speed up the processing\n# Applying a Gaussian filter for smoothing prior to down-scaling\n# reduces aliasing artifacts.\nsmoothened_coins = gaussian_filter(orig_coins, sigma=2)\nrescaled_coins = rescale(\n smoothened_coins, 0.2, mode=\"reflect\", anti_aliasing=False, multichannel=False\n)\n\n# Convert the image into a graph with the value of the gradient on the\n# edges.\ngraph = image.img_to_graph(rescaled_coins)\n\n# Take a decreasing function of the gradient: an exponential\n# The smaller beta is, the more independent the segmentation is of the\n# actual image. For beta=1, the segmentation is close to a voronoi\nbeta = 10\neps = 1e-6\ngraph.data = np.exp(-beta * graph.data / graph.data.std()) + eps\n\n# The number of segmented regions to display needs to be chosen manually.\n# The current version of 'spectral_clustering' does not support determining\n# the number of good quality clusters automatically.\nn_regions = 26"
29+
"# Author: Gael Varoquaux <[email protected]>\n# Brian Cheung\n# Andrew Knyazev <[email protected]>\n# License: BSD 3 clause\n\nimport time\n\nimport numpy as np\nfrom scipy.ndimage import gaussian_filter\nimport matplotlib.pyplot as plt\nfrom skimage.data import coins\nfrom skimage.transform import rescale\n\nfrom sklearn.feature_extraction import image\nfrom sklearn.cluster import spectral_clustering\n\n\n# load the coins as a numpy array\norig_coins = coins()\n\n# Resize it to 20% of the original size to speed up the processing\n# Applying a Gaussian filter for smoothing prior to down-scaling\n# reduces aliasing artifacts.\nsmoothened_coins = gaussian_filter(orig_coins, sigma=2)\nrescaled_coins = rescale(\n smoothened_coins, 0.2, mode=\"reflect\", anti_aliasing=False, multichannel=False\n)\n\n# Convert the image into a graph with the value of the gradient on the\n# edges.\ngraph = image.img_to_graph(rescaled_coins)\n\n# Take a decreasing function of the gradient: an exponential\n# The smaller beta is, the more independent the segmentation is of the\n# actual image. For beta=1, the segmentation is close to a voronoi\nbeta = 10\neps = 1e-6\ngraph.data = np.exp(-beta * graph.data / graph.data.std()) + eps\n\n# The number of segmented regions to display needs to be chosen manually.\n# The current version of 'spectral_clustering' does not support determining\n# the number of good quality clusters automatically.\nn_regions = 26"
3030
]
3131
},
3232
{
Binary file not shown.

dev/_downloads/2e86a4838807f09bbbb529d9643d45ab/plot_coin_segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import time
2929

3030
import numpy as np
31-
from scipy.ndimage.filters import gaussian_filter
31+
from scipy.ndimage import gaussian_filter
3232
import matplotlib.pyplot as plt
3333
from skimage.data import coins
3434
from skimage.transform import rescale

dev/_downloads/5eeecece5c41d6edcf4555b5e7c34350/plot_coin_ward_segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import time as time
1717

1818
import numpy as np
19-
from scipy.ndimage.filters import gaussian_filter
19+
from scipy.ndimage import gaussian_filter
2020

2121
import matplotlib.pyplot as plt
2222

Binary file not shown.

dev/_downloads/c8c7c5458b84586cacd8498015126bc4/plot_coin_ward_segmentation.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-
"# Author : Vincent Michel, 2010\n# Alexandre Gramfort, 2011\n# License: BSD 3 clause\n\nimport time as time\n\nimport numpy as np\nfrom scipy.ndimage.filters import gaussian_filter\n\nimport matplotlib.pyplot as plt\n\nfrom skimage.data import coins\nfrom skimage.transform import rescale\n\nfrom sklearn.feature_extraction.image import grid_to_graph\nfrom sklearn.cluster import AgglomerativeClustering\n\n\n# #############################################################################\n# Generate data\norig_coins = coins()\n\n# Resize it to 20% of the original size to speed up the processing\n# Applying a Gaussian filter for smoothing prior to down-scaling\n# reduces aliasing artifacts.\nsmoothened_coins = gaussian_filter(orig_coins, sigma=2)\nrescaled_coins = rescale(\n smoothened_coins, 0.2, mode=\"reflect\", anti_aliasing=False, multichannel=False\n)\n\nX = np.reshape(rescaled_coins, (-1, 1))\n\n# #############################################################################\n# Define the structure A of the data. Pixels connected to their neighbors.\nconnectivity = grid_to_graph(*rescaled_coins.shape)\n\n# #############################################################################\n# Compute clustering\nprint(\"Compute structured hierarchical clustering...\")\nst = time.time()\nn_clusters = 27 # number of regions\nward = AgglomerativeClustering(\n n_clusters=n_clusters, linkage=\"ward\", connectivity=connectivity\n)\nward.fit(X)\nlabel = np.reshape(ward.labels_, rescaled_coins.shape)\nprint(\"Elapsed time: \", time.time() - st)\nprint(\"Number of pixels: \", label.size)\nprint(\"Number of clusters: \", np.unique(label).size)\n\n# #############################################################################\n# Plot the results on an image\nplt.figure(figsize=(5, 5))\nplt.imshow(rescaled_coins, cmap=plt.cm.gray)\nfor l in range(n_clusters):\n plt.contour(\n label == l,\n colors=[\n plt.cm.nipy_spectral(l / float(n_clusters)),\n ],\n )\nplt.xticks(())\nplt.yticks(())\nplt.show()"
29+
"# Author : Vincent Michel, 2010\n# Alexandre Gramfort, 2011\n# License: BSD 3 clause\n\nimport time as time\n\nimport numpy as np\nfrom scipy.ndimage import gaussian_filter\n\nimport matplotlib.pyplot as plt\n\nfrom skimage.data import coins\nfrom skimage.transform import rescale\n\nfrom sklearn.feature_extraction.image import grid_to_graph\nfrom sklearn.cluster import AgglomerativeClustering\n\n\n# #############################################################################\n# Generate data\norig_coins = coins()\n\n# Resize it to 20% of the original size to speed up the processing\n# Applying a Gaussian filter for smoothing prior to down-scaling\n# reduces aliasing artifacts.\nsmoothened_coins = gaussian_filter(orig_coins, sigma=2)\nrescaled_coins = rescale(\n smoothened_coins, 0.2, mode=\"reflect\", anti_aliasing=False, multichannel=False\n)\n\nX = np.reshape(rescaled_coins, (-1, 1))\n\n# #############################################################################\n# Define the structure A of the data. Pixels connected to their neighbors.\nconnectivity = grid_to_graph(*rescaled_coins.shape)\n\n# #############################################################################\n# Compute clustering\nprint(\"Compute structured hierarchical clustering...\")\nst = time.time()\nn_clusters = 27 # number of regions\nward = AgglomerativeClustering(\n n_clusters=n_clusters, linkage=\"ward\", connectivity=connectivity\n)\nward.fit(X)\nlabel = np.reshape(ward.labels_, rescaled_coins.shape)\nprint(\"Elapsed time: \", time.time() - st)\nprint(\"Number of pixels: \", label.size)\nprint(\"Number of clusters: \", np.unique(label).size)\n\n# #############################################################################\n# Plot the results on an image\nplt.figure(figsize=(5, 5))\nplt.imshow(rescaled_coins, cmap=plt.cm.gray)\nfor l in range(n_clusters):\n plt.contour(\n label == l,\n colors=[\n plt.cm.nipy_spectral(l / float(n_clusters)),\n ],\n )\nplt.xticks(())\nplt.yticks(())\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/scikit-learn-docs.zip

820 Bytes
Binary file not shown.
204 Bytes
-23 Bytes
-116 Bytes

0 commit comments

Comments
 (0)