Skip to content

Instantly share code, notes, and snippets.

@aateg
Last active October 27, 2019 06:06
Show Gist options
  • Save aateg/5c928c2da8601af49819845b92f924a2 to your computer and use it in GitHub Desktop.
Save aateg/5c928c2da8601af49819845b92f924a2 to your computer and use it in GitHub Desktop.
Cálculo da Acurácia
def classifications(theta_1, theta_2, X,):
a1 = np.append(np.ones(shape=(X.shape[0], 1)), X, axis=1)
z2 = a1 @ theta_1.transpose()
a2 = sigmoid(z2)
a2 = np.append(np.ones(shape=(a2.shape[0], 1)), a2, axis=1)
z3 = a2 @ theta_2.transpose()
a3 = sigmoid(z3)
classifs = np.argmax(a3, axis=1)
return classifs
def accuracy(theta_1, theta_2, X, y, y_classif):
classifs = classifications(theta_1, theta_2, X)
acertos = np.sum(classifs == y_classif)
total = classifs.size
return acertos / total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment