clean up SVM code

This commit is contained in:
Satya Mallick committed 2018-07-26 11:37:40 -07:00
1 parent 65aee4ede9
commit 6cbf4d5222
9 files changed
+5 -3

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 KiB

@@ -1,20 +1,22 @@
import matplotlib.pyplot as plt
from sklearn import svm
from sklearn.cross_validation import train_test_split
from sklearn.model_selection import train_test_split
import numpy as np
import sys
import os
sys.path.append(os.path.abspath("../../"))
sys.path.append(os.path.abspath("../"))
from utils import read_data, plot_data, plot_decision_function
# Read data
x, labels = read_data("../points_rightside.txt", "../points_leftside.txt")
x, labels = read_data("points_class_0.txt", "points_class_1.txt")
# Split data to train and test on 80-20 ratio
X_train, X_test, y_train, y_test = train_test_split(x, labels, test_size = 0.2, random_state=0)
# Plot traning and test data
plot_data(X_train, y_train, X_test, y_test)
# Create a linear SVM classifier
clf = svm.SVC(C = 1.0, kernel='linear')