Skip to content

Instantly share code, notes, and snippets.

@grohith327
Created June 7, 2018 14:32
Show Gist options
  • Save grohith327/4af20afb307d335eb7b9d11eb957e7f5 to your computer and use it in GitHub Desktop.
Save grohith327/4af20afb307d335eb7b9d11eb957e7f5 to your computer and use it in GitHub Desktop.
from sklearn.metrics import accuracy_score
## Clip the weights
index = list(range(10,90))
w1 = np.delete(w1,index)
w2 = np.delete(w2,index)
w1 = w1.reshape(10,1)
w2 = w2.reshape(10,1)
## Extract the test data features
test_f1 = x_test[:,0]
test_f2 = x_test[:,1]
test_f1 = test_f1.reshape(10,1)
test_f2 = test_f2.reshape(10,1)
## Predict
y_pred = w1 * test_f1 + w2 * test_f2
predictions = []
for val in y_pred:
if(val > 1):
predictions.append(1)
else:
predictions.append(-1)
print(accuracy_score(y_test,predictions))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment