Skip to content

Commit 1b15cad

Browse files
committed
Pushing the docs to dev/ for branch: main, commit cb15a82e6439feda50b0605d70ce6d06c2eac7fd
1 parent 84afd1a commit 1b15cad

File tree

1,307 files changed

+5726
-5726
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,307 files changed

+5726
-5726
lines changed

dev/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: f22854fbba193671ecfa9e2d51734347
3+
config: df917163c3917b65e42063dbd2aaffb4
44
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.

dev/_downloads/0dd5e0a7942f1446accf7dffd47aed28/plot_label_propagation_digits_active_learning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
# select up to 5 digit examples that the classifier is most uncertain about
8080
uncertainty_index = np.argsort(pred_entropies)[::-1]
8181
uncertainty_index = uncertainty_index[
82-
np.in1d(uncertainty_index, unlabeled_indices)
82+
np.isin(uncertainty_index, unlabeled_indices)
8383
][:5]
8484

8585
# keep track of indices that we get labels for
Binary file not shown.

dev/_downloads/a72c1f35af8f7695645ce87422b177bf/plot_label_propagation_digits_active_learning.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"outputs": [],
1717
"source": [
18-
"# Authors: Clay Woolam <[email protected]>\n# License: BSD\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy import stats\n\nfrom sklearn import datasets\nfrom sklearn.metrics import classification_report, confusion_matrix\nfrom sklearn.semi_supervised import LabelSpreading\n\ndigits = datasets.load_digits()\nrng = np.random.RandomState(0)\nindices = np.arange(len(digits.data))\nrng.shuffle(indices)\n\nX = digits.data[indices[:330]]\ny = digits.target[indices[:330]]\nimages = digits.images[indices[:330]]\n\nn_total_samples = len(y)\nn_labeled_points = 40\nmax_iterations = 5\n\nunlabeled_indices = np.arange(n_total_samples)[n_labeled_points:]\nf = plt.figure()\n\nfor i in range(max_iterations):\n if len(unlabeled_indices) == 0:\n print(\"No unlabeled items left to label.\")\n break\n y_train = np.copy(y)\n y_train[unlabeled_indices] = -1\n\n lp_model = LabelSpreading(gamma=0.25, max_iter=20)\n lp_model.fit(X, y_train)\n\n predicted_labels = lp_model.transduction_[unlabeled_indices]\n true_labels = y[unlabeled_indices]\n\n cm = confusion_matrix(true_labels, predicted_labels, labels=lp_model.classes_)\n\n print(\"Iteration %i %s\" % (i, 70 * \"_\"))\n print(\n \"Label Spreading model: %d labeled & %d unlabeled (%d total)\"\n % (n_labeled_points, n_total_samples - n_labeled_points, n_total_samples)\n )\n\n print(classification_report(true_labels, predicted_labels))\n\n print(\"Confusion matrix\")\n print(cm)\n\n # compute the entropies of transduced label distributions\n pred_entropies = stats.distributions.entropy(lp_model.label_distributions_.T)\n\n # select up to 5 digit examples that the classifier is most uncertain about\n uncertainty_index = np.argsort(pred_entropies)[::-1]\n uncertainty_index = uncertainty_index[\n np.in1d(uncertainty_index, unlabeled_indices)\n ][:5]\n\n # keep track of indices that we get labels for\n delete_indices = np.array([], dtype=int)\n\n # for more than 5 iterations, visualize the gain only on the first 5\n if i < 5:\n f.text(\n 0.05,\n (1 - (i + 1) * 0.183),\n \"model %d\\n\\nfit with\\n%d labels\" % ((i + 1), i * 5 + 10),\n size=10,\n )\n for index, image_index in enumerate(uncertainty_index):\n image = images[image_index]\n\n # for more than 5 iterations, visualize the gain only on the first 5\n if i < 5:\n sub = f.add_subplot(5, 5, index + 1 + (5 * i))\n sub.imshow(image, cmap=plt.cm.gray_r, interpolation=\"none\")\n sub.set_title(\n \"predict: %i\\ntrue: %i\"\n % (lp_model.transduction_[image_index], y[image_index]),\n size=10,\n )\n sub.axis(\"off\")\n\n # labeling 5 points, remote from labeled set\n (delete_index,) = np.where(unlabeled_indices == image_index)\n delete_indices = np.concatenate((delete_indices, delete_index))\n\n unlabeled_indices = np.delete(unlabeled_indices, delete_indices)\n n_labeled_points += len(uncertainty_index)\n\nf.suptitle(\n (\n \"Active learning with Label Propagation.\\nRows show 5 most \"\n \"uncertain labels to learn with the next model.\"\n ),\n y=1.15,\n)\nplt.subplots_adjust(left=0.2, bottom=0.03, right=0.9, top=0.9, wspace=0.2, hspace=0.85)\nplt.show()"
18+
"# Authors: Clay Woolam <[email protected]>\n# License: BSD\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy import stats\n\nfrom sklearn import datasets\nfrom sklearn.metrics import classification_report, confusion_matrix\nfrom sklearn.semi_supervised import LabelSpreading\n\ndigits = datasets.load_digits()\nrng = np.random.RandomState(0)\nindices = np.arange(len(digits.data))\nrng.shuffle(indices)\n\nX = digits.data[indices[:330]]\ny = digits.target[indices[:330]]\nimages = digits.images[indices[:330]]\n\nn_total_samples = len(y)\nn_labeled_points = 40\nmax_iterations = 5\n\nunlabeled_indices = np.arange(n_total_samples)[n_labeled_points:]\nf = plt.figure()\n\nfor i in range(max_iterations):\n if len(unlabeled_indices) == 0:\n print(\"No unlabeled items left to label.\")\n break\n y_train = np.copy(y)\n y_train[unlabeled_indices] = -1\n\n lp_model = LabelSpreading(gamma=0.25, max_iter=20)\n lp_model.fit(X, y_train)\n\n predicted_labels = lp_model.transduction_[unlabeled_indices]\n true_labels = y[unlabeled_indices]\n\n cm = confusion_matrix(true_labels, predicted_labels, labels=lp_model.classes_)\n\n print(\"Iteration %i %s\" % (i, 70 * \"_\"))\n print(\n \"Label Spreading model: %d labeled & %d unlabeled (%d total)\"\n % (n_labeled_points, n_total_samples - n_labeled_points, n_total_samples)\n )\n\n print(classification_report(true_labels, predicted_labels))\n\n print(\"Confusion matrix\")\n print(cm)\n\n # compute the entropies of transduced label distributions\n pred_entropies = stats.distributions.entropy(lp_model.label_distributions_.T)\n\n # select up to 5 digit examples that the classifier is most uncertain about\n uncertainty_index = np.argsort(pred_entropies)[::-1]\n uncertainty_index = uncertainty_index[\n np.isin(uncertainty_index, unlabeled_indices)\n ][:5]\n\n # keep track of indices that we get labels for\n delete_indices = np.array([], dtype=int)\n\n # for more than 5 iterations, visualize the gain only on the first 5\n if i < 5:\n f.text(\n 0.05,\n (1 - (i + 1) * 0.183),\n \"model %d\\n\\nfit with\\n%d labels\" % ((i + 1), i * 5 + 10),\n size=10,\n )\n for index, image_index in enumerate(uncertainty_index):\n image = images[image_index]\n\n # for more than 5 iterations, visualize the gain only on the first 5\n if i < 5:\n sub = f.add_subplot(5, 5, index + 1 + (5 * i))\n sub.imshow(image, cmap=plt.cm.gray_r, interpolation=\"none\")\n sub.set_title(\n \"predict: %i\\ntrue: %i\"\n % (lp_model.transduction_[image_index], y[image_index]),\n size=10,\n )\n sub.axis(\"off\")\n\n # labeling 5 points, remote from labeled set\n (delete_index,) = np.where(unlabeled_indices == image_index)\n delete_indices = np.concatenate((delete_indices, delete_index))\n\n unlabeled_indices = np.delete(unlabeled_indices, delete_indices)\n n_labeled_points += len(uncertainty_index)\n\nf.suptitle(\n (\n \"Active learning with Label Propagation.\\nRows show 5 most \"\n \"uncertain labels to learn with the next model.\"\n ),\n y=1.15,\n)\nplt.subplots_adjust(left=0.2, bottom=0.03, right=0.9, top=0.9, wspace=0.2, hspace=0.85)\nplt.show()"
1919
]
2020
}
2121
],

dev/_downloads/scikit-learn-docs.zip

12.7 KB
Binary file not shown.
-46 Bytes
162 Bytes
-98 Bytes
79 Bytes

0 commit comments

Comments
 (0)