MCPcopy Index your code
hub / github.com/wepe/MachineLearning / plot_contour

Function plot_contour

SVM/SVM_by_QP/testSVM.py:86–99  ·  view source on GitHub ↗
(X1_train, X2_train, clf)

Source from the content-addressed store, hash-verified

84 pl.show()
85
86def plot_contour(X1_train, X2_train, clf):
87 pl.plot(X1_train[:,0], X1_train[:,1], "ro")
88 pl.plot(X2_train[:,0], X2_train[:,1], "bo")
89 pl.scatter(clf.sv[:,0], clf.sv[:,1], s=100, c="g")
90
91 X1, X2 = np.meshgrid(np.linspace(-6,6,50), np.linspace(-6,6,50))
92 X = np.array([[x1, x2] for x1, x2 in zip(np.ravel(X1), np.ravel(X2))])
93 Z = clf.project(X).reshape(X1.shape)
94 pl.contour(X1, X2, Z, [0.0], colors='k', linewidths=1, origin='lower')
95 pl.contour(X1, X2, Z + 1, [0.0], colors='grey', linewidths=1, origin='lower')
96 pl.contour(X1, X2, Z - 1, [0.0], colors='grey', linewidths=1, origin='lower')
97
98 pl.axis("tight")
99 pl.show()
100
101def test_linear():
102 X1, y1, X2, y2 = gen_lin_separable_data()

Callers 2

test_non_linearFunction · 0.85
test_softFunction · 0.85

Calls 2

projectMethod · 0.80
showMethod · 0.80

Tested by

no test coverage detected