Skip to content

Instantly share code, notes, and snippets.

@tarlanahad
Last active March 22, 2020 17:15
Show Gist options
  • Save tarlanahad/484371b2fa035dbbfff54d62d638c963 to your computer and use it in GitHub Desktop.
Save tarlanahad/484371b2fa035dbbfff54d62d638c963 to your computer and use it in GitHub Desktop.
data = np.genfromtxt('files/data.csv', dtype=float, delimiter=',')
np.random.shuffle(data)
train_y = data[:, 0]
train_x = data[:, 1:]
clf = SVM(train_x, train_y, num_of_epochs=10000, lr=1e-3, C=30)
clf.fit()
p = np.sign(clf.predict(train_x))
p = p - train_y.flatten()
# Prediction accuracy should be 1.0 for the training set
print("Accuracy |", len(np.where(p == 0)[0]) / len(p))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment