Last active
October 27, 2019 06:06
-
-
Save guilhermefgs/5c928c2da8601af49819845b92f924a2 to your computer and use it in GitHub Desktop.
Cálculo da Acurácia
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
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