Skip to content

Commit

Permalink
[MRG] Modify Svm examples for matplotlibv2 comp (scikit-learn#8456)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rishikksh20 authored and amueller committed Mar 4, 2017
1 parent 75c892c commit cdd693b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/svm/plot_custom_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def my_kernel(X, Y):
plt.pcolormesh(xx, yy, Z, cmap=plt.cm.Paired)

# Plot also the training points
plt.scatter(X[:, 0], X[:, 1], c=Y, cmap=plt.cm.Paired)
plt.scatter(X[:, 0], X[:, 1], c=Y, cmap=plt.cm.Paired, edgecolors='k')
plt.title('3-Class classification using Support Vector Machine with custom'
' kernel')
plt.axis('tight')
Expand Down
8 changes: 5 additions & 3 deletions examples/svm/plot_oneclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
plt.contourf(xx, yy, Z, levels=[0, Z.max()], colors='palevioletred')

s = 40
b1 = plt.scatter(X_train[:, 0], X_train[:, 1], c='white', s=s)
b2 = plt.scatter(X_test[:, 0], X_test[:, 1], c='blueviolet', s=s)
c = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c='gold', s=s)
b1 = plt.scatter(X_train[:, 0], X_train[:, 1], c='white', s=s, edgecolors='k')
b2 = plt.scatter(X_test[:, 0], X_test[:, 1], c='blueviolet', s=s,
edgecolors='k')
c = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c='gold', s=s,
edgecolors='k')
plt.axis('tight')
plt.xlim((-5, 5))
plt.ylim((-5, 5))
Expand Down
3 changes: 2 additions & 1 deletion examples/svm/plot_rbf_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def __call__(self, value, clip=None):

# visualize parameter's effect on decision function
plt.pcolormesh(xx, yy, -Z, cmap=plt.cm.RdBu)
plt.scatter(X_2d[:, 0], X_2d[:, 1], c=y_2d, cmap=plt.cm.RdBu_r)
plt.scatter(X_2d[:, 0], X_2d[:, 1], c=y_2d, cmap=plt.cm.RdBu_r,
edgecolors='k')
plt.xticks(())
plt.yticks(())
plt.axis('tight')
Expand Down
2 changes: 1 addition & 1 deletion examples/svm/plot_separating_hyperplane_unbalanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# plot separating hyperplanes and samples
h0 = plt.plot(xx, yy, 'k-', label='no weights')
h1 = plt.plot(xx, wyy, 'k--', label='with weights')
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired)
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired, edgecolors='k')
plt.legend()

plt.axis('tight')
Expand Down
5 changes: 3 additions & 2 deletions examples/svm/plot_svm_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
plt.clf()

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

plt.axis('tight')
x_min = -3
Expand Down
5 changes: 3 additions & 2 deletions examples/svm/plot_svm_margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@
plt.plot(xx, yy_up, 'k--')

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

plt.axis('tight')
x_min = -4.8
Expand Down
3 changes: 2 additions & 1 deletion examples/svm/plot_svm_nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
origin='lower', cmap=plt.cm.PuOr_r)
contours = plt.contour(xx, yy, Z, levels=[0], linewidths=2,
linetypes='--')
plt.scatter(X[:, 0], X[:, 1], s=30, c=Y, cmap=plt.cm.Paired)
plt.scatter(X[:, 0], X[:, 1], s=30, c=Y, cmap=plt.cm.Paired,
edgecolors='k')
plt.xticks(())
plt.yticks(())
plt.axis([-3, 3, -3, 3])
Expand Down

0 comments on commit cdd693b

Please sign in to comment.