Skip to content

Commit 639b25e

Browse files
committed
Pushing the docs to dev/ for branch: main, commit e31ba777bc5e66b04dcb58b2bdf95ff8a9d3741b
1 parent 59293d4 commit 639b25e

File tree

1,315 files changed

+5722
-5740
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,315 files changed

+5722
-5740
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: 68c657e4b58a45a23ad28d523944e85a
3+
config: 6bd6b226cfe6702d2bb6a77ccc4183ee
44
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.

dev/_downloads/1ecb1284f0b785cd0011e155bf44657c/plot_lof_novelty_detection.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-
"import matplotlib\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom sklearn.neighbors import LocalOutlierFactor\n\nnp.random.seed(42)\n\nxx, yy = np.meshgrid(np.linspace(-5, 5, 500), np.linspace(-5, 5, 500))\n# Generate normal (not abnormal) training observations\nX = 0.3 * np.random.randn(100, 2)\nX_train = np.r_[X + 2, X - 2]\n# Generate new normal (not abnormal) observations\nX = 0.3 * np.random.randn(20, 2)\nX_test = np.r_[X + 2, X - 2]\n# Generate some abnormal novel observations\nX_outliers = np.random.uniform(low=-4, high=4, size=(20, 2))\n\n# fit the model for novelty detection (novelty=True)\nclf = LocalOutlierFactor(n_neighbors=20, novelty=True, contamination=0.1)\nclf.fit(X_train)\n# DO NOT use predict, decision_function and score_samples on X_train as this\n# would give wrong results but only on new unseen data (not used in X_train),\n# e.g. X_test, X_outliers or the meshgrid\ny_pred_test = clf.predict(X_test)\ny_pred_outliers = clf.predict(X_outliers)\nn_error_test = y_pred_test[y_pred_test == -1].size\nn_error_outliers = y_pred_outliers[y_pred_outliers == 1].size\n\n# plot the learned frontier, the points, and the nearest vectors to the plane\nZ = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\n\nplt.title(\"Novelty Detection with LOF\")\nplt.contourf(xx, yy, Z, levels=np.linspace(Z.min(), 0, 7), cmap=plt.cm.PuBu)\na = plt.contour(xx, yy, Z, levels=[0], linewidths=2, colors=\"darkred\")\nplt.contourf(xx, yy, Z, levels=[0, Z.max()], colors=\"palevioletred\")\n\ns = 40\nb1 = plt.scatter(X_train[:, 0], X_train[:, 1], c=\"white\", s=s, edgecolors=\"k\")\nb2 = plt.scatter(X_test[:, 0], X_test[:, 1], c=\"blueviolet\", s=s, edgecolors=\"k\")\nc = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c=\"gold\", s=s, edgecolors=\"k\")\nplt.axis(\"tight\")\nplt.xlim((-5, 5))\nplt.ylim((-5, 5))\nplt.legend(\n [a.collections[0], b1, b2, c],\n [\n \"learned frontier\",\n \"training observations\",\n \"new regular observations\",\n \"new abnormal observations\",\n ],\n loc=\"upper left\",\n prop=matplotlib.font_manager.FontProperties(size=11),\n)\nplt.xlabel(\n \"errors novel regular: %d/40 ; errors novel abnormal: %d/40\"\n % (n_error_test, n_error_outliers)\n)\nplt.show()"
18+
"import matplotlib\nimport matplotlib.lines as mlines\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom sklearn.neighbors import LocalOutlierFactor\n\nnp.random.seed(42)\n\nxx, yy = np.meshgrid(np.linspace(-5, 5, 500), np.linspace(-5, 5, 500))\n# Generate normal (not abnormal) training observations\nX = 0.3 * np.random.randn(100, 2)\nX_train = np.r_[X + 2, X - 2]\n# Generate new normal (not abnormal) observations\nX = 0.3 * np.random.randn(20, 2)\nX_test = np.r_[X + 2, X - 2]\n# Generate some abnormal novel observations\nX_outliers = np.random.uniform(low=-4, high=4, size=(20, 2))\n\n# fit the model for novelty detection (novelty=True)\nclf = LocalOutlierFactor(n_neighbors=20, novelty=True, contamination=0.1)\nclf.fit(X_train)\n# DO NOT use predict, decision_function and score_samples on X_train as this\n# would give wrong results but only on new unseen data (not used in X_train),\n# e.g. X_test, X_outliers or the meshgrid\ny_pred_test = clf.predict(X_test)\ny_pred_outliers = clf.predict(X_outliers)\nn_error_test = y_pred_test[y_pred_test == -1].size\nn_error_outliers = y_pred_outliers[y_pred_outliers == 1].size\n\n# plot the learned frontier, the points, and the nearest vectors to the plane\nZ = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\n\nplt.title(\"Novelty Detection with LOF\")\nplt.contourf(xx, yy, Z, levels=np.linspace(Z.min(), 0, 7), cmap=plt.cm.PuBu)\na = plt.contour(xx, yy, Z, levels=[0], linewidths=2, colors=\"darkred\")\nplt.contourf(xx, yy, Z, levels=[0, Z.max()], colors=\"palevioletred\")\n\ns = 40\nb1 = plt.scatter(X_train[:, 0], X_train[:, 1], c=\"white\", s=s, edgecolors=\"k\")\nb2 = plt.scatter(X_test[:, 0], X_test[:, 1], c=\"blueviolet\", s=s, edgecolors=\"k\")\nc = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c=\"gold\", s=s, edgecolors=\"k\")\nplt.axis(\"tight\")\nplt.xlim((-5, 5))\nplt.ylim((-5, 5))\nplt.legend(\n [mlines.Line2D([], [], color=\"darkred\"), b1, b2, c],\n [\n \"learned frontier\",\n \"training observations\",\n \"new regular observations\",\n \"new abnormal observations\",\n ],\n loc=\"upper left\",\n prop=matplotlib.font_manager.FontProperties(size=11),\n)\nplt.xlabel(\n \"errors novel regular: %d/40 ; errors novel abnormal: %d/40\"\n % (n_error_test, n_error_outliers)\n)\nplt.show()"
1919
]
2020
}
2121
],

dev/_downloads/42b321f3e1d8c7a657ebec98c5d6ea0d/plot_lof_novelty_detection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"""
2727

2828
import matplotlib
29+
import matplotlib.lines as mlines
2930
import matplotlib.pyplot as plt
3031
import numpy as np
3132

@@ -71,7 +72,7 @@
7172
plt.xlim((-5, 5))
7273
plt.ylim((-5, 5))
7374
plt.legend(
74-
[a.collections[0], b1, b2, c],
75+
[mlines.Line2D([], [], color="darkred"), b1, b2, c],
7576
[
7677
"learned frontier",
7778
"training observations",
Binary file not shown.

dev/_downloads/scikit-learn-docs.zip

10.7 KB
Binary file not shown.
-208 Bytes
166 Bytes
87 Bytes
-32 Bytes

0 commit comments

Comments
 (0)