Skip to content

Instantly share code, notes, and snippets.

@iamjalipo
Created February 12, 2022 13:28
Show Gist options
  • Save iamjalipo/a5c57dc313dadb37b2d512c73ffa0447 to your computer and use it in GitHub Desktop.
Save iamjalipo/a5c57dc313dadb37b2d512c73ffa0447 to your computer and use it in GitHub Desktop.
logistic-04
from sklearn.metrics import accuracy_score
test_x_1 = x_test[:,0]
test_x_2 = x_test[:,1]
test_x_3 = x_test[:,2]
test_x_4 = x_test[:,3]
test_x_1 = np.array(test_x_1)
test_x_2 = np.array(test_x_2)
test_x_3 = np.array(test_x_3)
test_x_4 = np.array(test_x_4)
test_x_1 = test_x_1.reshape(10,1)
test_x_2 = test_x_2.reshape(10,1)
test_x_3 = test_x_3.reshape(10,1)
test_x_4 = test_x_4.reshape(10,1)
index = list(range(10,90))
theta_0 = np.delete(theta_0, index)
theta_1 = np.delete(theta_1, index)
theta_2 = np.delete(theta_2, index)
theta_3 = np.delete(theta_3, index)
theta_4 = np.delete(theta_4, index)
theta_0 = theta_0.reshape(10,1)
theta_1 = theta_1.reshape(10,1)
theta_2 = theta_2.reshape(10,1)
theta_3 = theta_3.reshape(10,1)
theta_4 = theta_4.reshape(10,1)
y_pred = theta_0 + theta_1 * test_x_1 + theta_2 * test_x_2 + theta_3 * test_x_3 + theta_4 * test_x_4
y_pred = sigmoid(y_pred)
new_y_pred =[]
for val in y_pred:
if(val >= 0.5):
new_y_pred.append(1)
else:
new_y_pred.append(0)
print(accuracy_score(y_test,new_y_pred))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment