Skip to content

Commit 4c78393

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 34f12da6d675b08b8c4570451a3b876b2b87626f
1 parent 6b1b826 commit 4c78393

File tree

1,040 files changed

+3234
-3190
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,040 files changed

+3234
-3190
lines changed
112 Bytes
Binary file not shown.
109 Bytes
Binary file not shown.

dev/_downloads/plot_separating_hyperplane_unbalanced.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 import svm\n\n# we create clusters with 1000 and 100 points\nrng = np.random.RandomState(0)\nn_samples_1 = 1000\nn_samples_2 = 100\nX = np.r_[1.5 * rng.randn(n_samples_1, 2),\n 0.5 * rng.randn(n_samples_2, 2) + [2, 2]]\ny = [0] * (n_samples_1) + [1] * (n_samples_2)\n\n# fit the model and get the separating hyperplane\nclf = svm.SVC(kernel='linear', C=1.0)\nclf.fit(X, y)\n\n# fit the model and get the separating hyperplane using weighted classes\nwclf = svm.SVC(kernel='linear', class_weight={1: 10})\nwclf.fit(X, y)\n\n# plot separating hyperplanes and samples\nplt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired, edgecolors='k')\nplt.legend()\n\n# plot the decision functions for both classifiers\nax = plt.gca()\nxlim = ax.get_xlim()\nylim = ax.get_ylim()\n\n# create grid to evaluate model\nxx = np.linspace(xlim[0], xlim[1], 30)\nyy = np.linspace(ylim[0], ylim[1], 30)\nYY, XX = np.meshgrid(yy, xx)\nxy = np.vstack([XX.ravel(), YY.ravel()]).T\n\n# get the separating hyperplane\nZ = clf.decision_function(xy).reshape(XX.shape)\n\n# plot decision boundary and margins\na = ax.contour(XX, YY, Z, colors='k', levels=[0], alpha=0.5, linestyles=['-'])\n\n# get the separating hyperplane for weighted classes\nZ = wclf.decision_function(xy).reshape(XX.shape)\n\n# plot decision boundary and margins for weighted classes\nb = ax.contour(XX, YY, Z, colors='r', levels=[0], alpha=0.5, linestyles=['-'])\n\nplt.legend([a.collections[0], b.collections[0]], [\"non weighted\", \"weighted\"],\n loc=\"upper right\")\nplt.show()"
29+
"print(__doc__)\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import svm\nfrom sklearn.datasets import make_blobs\n\n# we create two clusters of random points\nn_samples_1 = 1000\nn_samples_2 = 100\ncenters = [[0.0, 0.0], [2.0, 2.0]]\nclusters_std = [1.5, 0.5]\nX, y = make_blobs(n_samples=[n_samples_1, n_samples_2],\n centers=centers,\n cluster_std=clusters_std,\n random_state=0, shuffle=False)\n\n# fit the model and get the separating hyperplane\nclf = svm.SVC(kernel='linear', C=1.0)\nclf.fit(X, y)\n\n# fit the model and get the separating hyperplane using weighted classes\nwclf = svm.SVC(kernel='linear', class_weight={1: 10})\nwclf.fit(X, y)\n\n# plot separating hyperplanes and samples\nplt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired, edgecolors='k')\nplt.legend()\n\n# plot the decision functions for both classifiers\nax = plt.gca()\nxlim = ax.get_xlim()\nylim = ax.get_ylim()\n\n# create grid to evaluate model\nxx = np.linspace(xlim[0], xlim[1], 30)\nyy = np.linspace(ylim[0], ylim[1], 30)\nYY, XX = np.meshgrid(yy, xx)\nxy = np.vstack([XX.ravel(), YY.ravel()]).T\n\n# get the separating hyperplane\nZ = clf.decision_function(xy).reshape(XX.shape)\n\n# plot decision boundary and margins\na = ax.contour(XX, YY, Z, colors='k', levels=[0], alpha=0.5, linestyles=['-'])\n\n# get the separating hyperplane for weighted classes\nZ = wclf.decision_function(xy).reshape(XX.shape)\n\n# plot decision boundary and margins for weighted classes\nb = ax.contour(XX, YY, Z, colors='r', levels=[0], alpha=0.5, linestyles=['-'])\n\nplt.legend([a.collections[0], b.collections[0]], [\"non weighted\", \"weighted\"],\n loc=\"upper right\")\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/plot_separating_hyperplane_unbalanced.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@
2929
import numpy as np
3030
import matplotlib.pyplot as plt
3131
from sklearn import svm
32+
from sklearn.datasets import make_blobs
3233

33-
# we create clusters with 1000 and 100 points
34-
rng = np.random.RandomState(0)
34+
# we create two clusters of random points
3535
n_samples_1 = 1000
3636
n_samples_2 = 100
37-
X = np.r_[1.5 * rng.randn(n_samples_1, 2),
38-
0.5 * rng.randn(n_samples_2, 2) + [2, 2]]
39-
y = [0] * (n_samples_1) + [1] * (n_samples_2)
37+
centers = [[0.0, 0.0], [2.0, 2.0]]
38+
clusters_std = [1.5, 0.5]
39+
X, y = make_blobs(n_samples=[n_samples_1, n_samples_2],
40+
centers=centers,
41+
cluster_std=clusters_std,
42+
random_state=0, shuffle=False)
4043

4144
# fit the model and get the separating hyperplane
4245
clf = svm.SVC(kernel='linear', C=1.0)

dev/_downloads/scikit-learn-docs.pdf

-60.4 KB
Binary file not shown.
16 Bytes
16 Bytes
339 Bytes
339 Bytes
270 Bytes

0 commit comments

Comments
 (0)