Skip to content

Commit 381e463

Browse files
committed
Pushing the docs to dev/ for branch: main, commit f4959ead4846005194ef02d82329b91f88e419e2
1 parent 7260421 commit 381e463

File tree

1,540 files changed

+6015
-6012
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,540 files changed

+6015
-6012
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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-
"# Authors: The scikit-learn developers\n# SPDX-License-Identifier: BSD-3-Clause\n\nimport 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()"
18+
"# Authors: The scikit-learn developers\n# SPDX-License-Identifier: BSD-3-Clause\n\nimport 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=(1.05, 0.4),\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.tight_layout()\nplt.show()"
1919
]
2020
}
2121
],
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

dev/_downloads/42b321f3e1d8c7a657ebec98c5d6ea0d/plot_lof_novelty_detection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@
8282
"new regular observations",
8383
"new abnormal observations",
8484
],
85-
loc="upper left",
85+
loc=(1.05, 0.4),
8686
prop=matplotlib.font_manager.FontProperties(size=11),
8787
)
8888
plt.xlabel(
8989
"errors novel regular: %d/40 ; errors novel abnormal: %d/40"
9090
% (n_error_test, n_error_outliers)
9191
)
92+
plt.tight_layout()
9293
plt.show()

0 commit comments

Comments
 (0)