()
| 131 | plot_contour(X_train[y_train==1], X_train[y_train==-1], clf) |
| 132 | |
| 133 | def test_soft(): |
| 134 | X1, y1, X2, y2 = gen_lin_separable_overlap_data() |
| 135 | X_train, y_train = split_train(X1, y1, X2, y2) |
| 136 | X_test, y_test = split_test(X1, y1, X2, y2) |
| 137 | |
| 138 | |
| 139 | |
| 140 | clf = SVM(C=0.1) |
| 141 | clf.fit(X_train, y_train) |
| 142 | |
| 143 | y_predict = clf.predict(X_test) |
| 144 | correct = np.sum(y_predict == y_test) |
| 145 | print "%d out of %d predictions correct" % (correct, len(y_predict)) |
| 146 | |
| 147 | plot_contour(X_train[y_train==1], X_train[y_train==-1], clf) |
| 148 | |
| 149 | |
| 150 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected