Skip to content

Commit 3844f62

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 39c341ad91b545c895ede9c6240a04659b82defb
1 parent 5acc45c commit 3844f62

File tree

1,219 files changed

+4413
-4405
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,219 files changed

+4413
-4405
lines changed
Binary file not shown.

dev/_downloads/1fbe96ffa301da6ec5d1c4be786df135/plot_sgd_weighted_samples.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
# plot the weighted data points
2424
xx, yy = np.meshgrid(np.linspace(-4, 5, 500), np.linspace(-4, 5, 500))
25-
plt.figure()
26-
plt.scatter(
25+
fig, ax = plt.subplots()
26+
ax.scatter(
2727
X[:, 0],
2828
X[:, 1],
2929
c=y,
@@ -38,21 +38,22 @@
3838
clf.fit(X, y)
3939
Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
4040
Z = Z.reshape(xx.shape)
41-
no_weights = plt.contour(xx, yy, Z, levels=[0], linestyles=["solid"])
41+
no_weights = ax.contour(xx, yy, Z, levels=[0], linestyles=["solid"])
4242

4343
# fit the weighted model
4444
clf = linear_model.SGDClassifier(alpha=0.01, max_iter=100)
4545
clf.fit(X, y, sample_weight=sample_weight)
4646
Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
4747
Z = Z.reshape(xx.shape)
48-
samples_weights = plt.contour(xx, yy, Z, levels=[0], linestyles=["dashed"])
48+
samples_weights = ax.contour(xx, yy, Z, levels=[0], linestyles=["dashed"])
4949

50-
plt.legend(
51-
[no_weights.collections[0], samples_weights.collections[0]],
50+
no_weights_handles, _ = no_weights.legend_elements()
51+
weights_handles, _ = samples_weights.legend_elements()
52+
ax.legend(
53+
[no_weights_handles[0], weights_handles[0]],
5254
["no weights", "with weights"],
5355
loc="lower left",
5456
)
5557

56-
plt.xticks(())
57-
plt.yticks(())
58+
ax.set(xticks=(), yticks=())
5859
plt.show()

dev/_downloads/6142de78d839661549389d7029cf98b0/plot_sgd_weighted_samples.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-
"import numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import linear_model\n\n# we create 20 points\nnp.random.seed(0)\nX = np.r_[np.random.randn(10, 2) + [1, 1], np.random.randn(10, 2)]\ny = [1] * 10 + [-1] * 10\nsample_weight = 100 * np.abs(np.random.randn(20))\n# and assign a bigger weight to the last 10 samples\nsample_weight[:10] *= 10\n\n# plot the weighted data points\nxx, yy = np.meshgrid(np.linspace(-4, 5, 500), np.linspace(-4, 5, 500))\nplt.figure()\nplt.scatter(\n X[:, 0],\n X[:, 1],\n c=y,\n s=sample_weight,\n alpha=0.9,\n cmap=plt.cm.bone,\n edgecolor=\"black\",\n)\n\n# fit the unweighted model\nclf = linear_model.SGDClassifier(alpha=0.01, max_iter=100)\nclf.fit(X, y)\nZ = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\nno_weights = plt.contour(xx, yy, Z, levels=[0], linestyles=[\"solid\"])\n\n# fit the weighted model\nclf = linear_model.SGDClassifier(alpha=0.01, max_iter=100)\nclf.fit(X, y, sample_weight=sample_weight)\nZ = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\nsamples_weights = plt.contour(xx, yy, Z, levels=[0], linestyles=[\"dashed\"])\n\nplt.legend(\n [no_weights.collections[0], samples_weights.collections[0]],\n [\"no weights\", \"with weights\"],\n loc=\"lower left\",\n)\n\nplt.xticks(())\nplt.yticks(())\nplt.show()"
29+
"import numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import linear_model\n\n# we create 20 points\nnp.random.seed(0)\nX = np.r_[np.random.randn(10, 2) + [1, 1], np.random.randn(10, 2)]\ny = [1] * 10 + [-1] * 10\nsample_weight = 100 * np.abs(np.random.randn(20))\n# and assign a bigger weight to the last 10 samples\nsample_weight[:10] *= 10\n\n# plot the weighted data points\nxx, yy = np.meshgrid(np.linspace(-4, 5, 500), np.linspace(-4, 5, 500))\nfig, ax = plt.subplots()\nax.scatter(\n X[:, 0],\n X[:, 1],\n c=y,\n s=sample_weight,\n alpha=0.9,\n cmap=plt.cm.bone,\n edgecolor=\"black\",\n)\n\n# fit the unweighted model\nclf = linear_model.SGDClassifier(alpha=0.01, max_iter=100)\nclf.fit(X, y)\nZ = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\nno_weights = ax.contour(xx, yy, Z, levels=[0], linestyles=[\"solid\"])\n\n# fit the weighted model\nclf = linear_model.SGDClassifier(alpha=0.01, max_iter=100)\nclf.fit(X, y, sample_weight=sample_weight)\nZ = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\nsamples_weights = ax.contour(xx, yy, Z, levels=[0], linestyles=[\"dashed\"])\n\nno_weights_handles, _ = no_weights.legend_elements()\nweights_handles, _ = samples_weights.legend_elements()\nax.legend(\n [no_weights_handles[0], weights_handles[0]],\n [\"no weights\", \"with weights\"],\n loc=\"lower left\",\n)\n\nax.set(xticks=(), yticks=())\nplt.show()"
3030
]
3131
}
3232
],
Binary file not shown.

dev/_downloads/scikit-learn-docs.zip

-18.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)