8000 [MRG] Modify Svm examples for matplotlibv2 comp (#8456) · massich/scikit-learn@f3d5243 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit f3d5243

Browse files
rishikksh20Joan Massich
authored andcommitted
[MRG] Modify Svm examples for matplotlibv2 comp (scikit-learn#8456)
* Modify plot_custom_kernel for matplotlib v2 comp Add `edgecolors` attribute in scatter plot for better visualization in matplotlib version 2 Issue: scikit-learn#8364 * Modify plot_oneclass.py for matplotlib v2 comp Add `edgecolors` attribute to scatter plot for better visualization in matplotlib version 2 Issue: scikit-learn#8364 * Modify plot_rbf_parameters for matplotlib v2 Add `edgecolors` attribute to scatter plot for better visualization. Issue: scikit-learn#8364 * Modify plot_separating_hyperplane_unbalanced for matplotlib v2 Add `edgecolors` attribute to scatter plot for better visualization. Issue: scikit-learn#8364 * Modify plo_svm_kernels for matplotlib v2 Add `edgecolors` attribute to scatter plot for better visualization. Issue: scikit-learn#8364 * Modify plot_svm_margin for matplotlib v2 comp Add `edgecolors` attribute to scatter plot for better visualization. Issue: scikit-learn#8364 * Modify plot_svm_nonlinear for matplotlib v2 Add `edgecolors` attribute to scatter plot for matplotlib version 2 compatibility Issue: scikit-learn#8364 * Modify file for remove flake8 error Remove extra white space. Issue: scikit-learn#8364
1 parent 2350158 commit f3d5243

7 files changed

+17
-11
lines changed

examples/svm/plot_custom_kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def my_kernel(X, Y):
5050
plt.pcolormesh(xx, yy, Z, cmap=plt.cm.Paired)
5151

5252
# Plot also the training points
53-
plt.scatter(X[:, 0], X[:, 1], c=Y, cmap=plt.cm.Paired)
53+
plt.scatter(X[:, 0], X[:, 1], c=Y, cmap=plt.cm.Paired, edgecolors='k')
5454
plt.title('3-Class classification using Support Vector Machine with custom'
5555
' kernel')
5656
plt.axis('tight')

examples/svm/plot_oneclass.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646
plt.contourf(xx, yy, Z, levels=[0, Z.max()], colors='palevioletred')
4747

4848
s = 40
49-
b1 = plt.scatter(X_train[:, 0], X_train[:, 1], c='white', s=s)
50-
b2 = plt.scatter(X_test[:, 0], X_test[:, 1], c='blueviolet', s=s)
51-
c = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c='gold', s=s)
49+
b1 = plt.scatter(X_train[:, 0], X_train[:, 1], c='white', s=s, edgecolors='k')
50+
b2 = plt.scatter(X_test[:, 0], X_test[:, 1], c='blueviolet', s=s,
51+
edgecolors='k')
52+
c = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c='gold', s=s,
53+
edgecolors='k')
5254
plt.axis('tight')
5355
plt.xlim((-5, 5))
5456
plt.ylim((-5, 5))

examples/svm/plot_rbf_parameters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def __call__(self, value, clip=None):
166166

167167
# visualize parameter's effect on decision function
168168
plt.pcolormesh(xx, yy, -Z, cmap=plt.cm.RdBu)
169-
plt.scatter(X_2d[:, 0], X_2d[:, 1], c=y_2d, cmap=plt.cm.RdBu_r)
169+
plt.scatter(X_2d[:, 0], X_2d[:, 1], c=y_2d, cmap=plt.cm.RdBu_r,
170+
edgecolors='k')
170171
plt.xticks(())
171172
plt.yticks(())
172173
plt.axis('tight')

examples/svm/plot_separating_hyperplane_unbalanced.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
# plot separating hyperplanes and samples
6161
h0 = plt.plot(xx, yy, 'k-', label='no weights')
6262
h1 = plt.plot(xx, wyy, 'k--', label='with weights')
63-
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired)
63+
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired, edgecolors='k')
6464
plt.legend()
6565

6666
plt.axis('tight')

examples/svm/plot_svm_kernels.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@
5656
plt.clf()
5757

5858
plt.scatter(clf.support_vectors_[:, 0], clf.support_vectors_[:, 1], s=80,
59-
facecolors='none', zorder=10)
60-
plt.scatter(X[:, 0], X[:, 1], c=Y, zorder=10, cmap=plt.cm.Paired)
59+
facecolors='none', zorder=10, edgecolors='k')
60+
plt.scatter(X[:, 0], X[:, 1], c=Y, zorder=10, cmap=plt.cm.Paired,
61+
edgecolors='k')
6162

6263
plt.axis('tight')
6364
x_min = -3

examples/svm/plot_svm_margin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
plt.plot(xx, yy_up, 'k--')
6363

6464
plt.scatter(clf.support_vectors_[:, 0], clf.support_vectors_[:, 1], s=80,
65-
facecolors='none', zorder=10)
66-
plt.scatter(X[:, 0], X[:, 1], c=Y, zorder=10, cmap=plt.cm.Paired)
65+
facecolors='none', zorder=10, edgecolors='k')
66+
plt.scatter(X[:, 0], X[:, 1], c=Y, zorder=10, cmap=plt.cm.Paired,
67+
edgecolors='k')
6768

6869
plt.axis('tight')
6970
x_min = -4.8

examples/svm/plot_svm_nonlinear.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
origin='lower', cmap=plt.cm.PuOr_r)
3535
contours = plt.contour(xx, yy, Z, levels=[0], linewidths=2,
3636
linetypes='--')
37-
plt.scatter(X[:, 0], X[:, 1], s=30, c=Y, cmap=plt.cm.Paired)
37+
plt.scatter(X[:, 0], X[:, 1], s=30, c=Y, cmap=plt.cm.Paired,
38+
edgecolors='k')
3839
plt.xticks(())
3940
plt.yticks(())
4041
plt.axis([-3, 3, -3, 3])

0 commit comments

Comments
 (0)
0