Last active
March 22, 2020 17:15
-
-
Save tarlanahad/484371b2fa035dbbfff54d62d638c963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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