Skip to content

Commit 9b82ad4

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 61e722aa126207efcdbc1ddcd4453854ad44ea09
1 parent 607f631 commit 9b82ad4

File tree

977 files changed

+3011
-3006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

977 files changed

+3011
-3006
lines changed
46 Bytes
Binary file not shown.
45 Bytes
Binary file not shown.

dev/_downloads/plot_lof.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 numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.neighbors import LocalOutlierFactor\n\nnp.random.seed(42)\n\n# Generate train data\nX = 0.3 * np.random.randn(100, 2)\n# Generate some abnormal novel observations\nX_outliers = np.random.uniform(low=-4, high=4, size=(20, 2))\nX = np.r_[X + 2, X - 2, X_outliers]\n\n# fit the model\nclf = LocalOutlierFactor(n_neighbors=20)\ny_pred = clf.fit_predict(X)\ny_pred_outliers = y_pred[200:]\n\n# plot the level sets of the decision function\nxx, yy = np.meshgrid(np.linspace(-5, 5, 50), np.linspace(-5, 5, 50))\nZ = clf._decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\n\nplt.title(\"Local Outlier Factor (LOF)\")\nplt.contourf(xx, yy, Z, cmap=plt.cm.Blues_r)\n\na = plt.scatter(X[:200, 0], X[:200, 1], c='white',\n edgecolor='k', s=20)\nb = plt.scatter(X[200:, 0], X[200:, 1], c='red',\n edgecolor='k', s=20)\nplt.axis('tight')\nplt.xlim((-5, 5))\nplt.ylim((-5, 5))\nplt.legend([a, b],\n [\"normal observations\",\n \"abnormal observations\"],\n loc=\"upper left\")\nplt.show()"
29+
"print(__doc__)\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.neighbors import LocalOutlierFactor\n\nnp.random.seed(42)\n\n# Generate train data\nX_inliers = 0.3 * np.random.randn(100, 2)\nX_inliers = np.r_[X_inliers + 2, X_inliers - 2]\n\n# Generate some abnormal novel observations\nX_outliers = np.random.uniform(low=-4, high=4, size=(20, 2))\nX = np.r_[X_inliers, X_outliers]\n\n# fit the model\nclf = LocalOutlierFactor(n_neighbors=20)\ny_pred = clf.fit_predict(X)\n\n# plot the level sets of the decision function\nxx, yy = np.meshgrid(np.linspace(-5, 5, 50), np.linspace(-5, 5, 50))\nZ = clf._decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\n\nplt.title(\"Local Outlier Factor (LOF)\")\nplt.contourf(xx, yy, Z, cmap=plt.cm.Blues_r)\n\na = plt.scatter(X_inliers[:, 0], X_inliers[:, 1], c='white',\n edgecolor='k', s=20)\nb = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c='red',\n edgecolor='k', s=20)\nplt.axis('tight')\nplt.xlim((-5, 5))\nplt.ylim((-5, 5))\nplt.legend([a, b],\n [\"normal observations\",\n \"abnormal observations\"],\n loc=\"upper left\")\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/plot_lof.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@
2626
np.random.seed(42)
2727

2828
# Generate train data
29-
X = 0.3 * np.random.randn(100, 2)
29+
X_inliers = 0.3 * np.random.randn(100, 2)
30+
X_inliers = np.r_[X_inliers + 2, X_inliers - 2]
31+
3032
# Generate some abnormal novel observations
3133
X_outliers = np.random.uniform(low=-4, high=4, size=(20, 2))
32-
X = np.r_[X + 2, X - 2, X_outliers]
34+
X = np.r_[X_inliers, X_outliers]
3335

3436
# fit the model
3537
clf = LocalOutlierFactor(n_neighbors=20)
3638
y_pred = clf.fit_predict(X)
37-
y_pred_outliers = y_pred[200:]
3839

3940
# plot the level sets of the decision function
4041
xx, yy = np.meshgrid(np.linspace(-5, 5, 50), np.linspace(-5, 5, 50))
@@ -44,9 +45,9 @@
4445
plt.title("Local Outlier Factor (LOF)")
4546
plt.contourf(xx, yy, Z, cmap=plt.cm.Blues_r)
4647

47-
a = plt.scatter(X[:200, 0], X[:200, 1], c='white',
48+
a = plt.scatter(X_inliers[:, 0], X_inliers[:, 1], c='white',
4849
edgecolor='k', s=20)
49-
b = plt.scatter(X[200:, 0], X[200:, 1], c='red',
50+
b = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c='red',
5051
edgecolor='k', s=20)
5152
plt.axis('tight')
5253
plt.xlim((-5, 5))

dev/_downloads/scikit-learn-docs.pdf

1.23 KB
Binary file not shown.
496 Bytes
496 Bytes
-273 Bytes
-273 Bytes
260 Bytes

0 commit comments

Comments
 (0)