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

Function test_non_linear

SVM/SVM_by_QP/testSVM.py:115–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113 plot_margin(X_train[y_train==1], X_train[y_train==-1], clf)
114
115def test_non_linear():
116 X1, y1, X2, y2 = gen_non_lin_separable_data()
117 X_train, y_train = split_train(X1, y1, X2, y2)
118 X_test, y_test = split_test(X1, y1, X2, y2)
119
120 # X_train = np.load('inputClf/X_train.npy')
121 # y_train = np.load('inputClf/y_train.npy')
122 # X_test = np.load('inputClf/X_test.npy')
123 # y_test = np.load('inputClf/y_test.npy')
124 clf = SVM(gaussian_kernel, C=1)
125 clf.fit(X_train, y_train)
126
127 y_predict = clf.predict(X_test)
128 correct = np.sum(y_predict == y_test)
129 print "%d out of %d predictions correct" % (correct, len(y_predict))
130
131 plot_contour(X_train[y_train==1], X_train[y_train==-1], clf)
132
133def test_soft():
134 X1, y1, X2, y2 = gen_lin_separable_overlap_data()

Callers 1

testSVM.pyFile · 0.85

Calls 7

fitMethod · 0.95
predictMethod · 0.95
split_trainFunction · 0.85
split_testFunction · 0.85
SVMClass · 0.85
plot_contourFunction · 0.85

Tested by

no test coverage detected