Last active
April 20, 2020 07:11
-
-
Save SkalskiP/da4eb493c73e6d29c673978d4c67a248 to your computer and use it in GitHub Desktop.
Calculating the value of the cost function and accuracy
This file contains hidden or 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 get_cost_value(Y_hat, Y): | |
| m = Y_hat.shape[1] | |
| cost = -1 / m * (np.dot(Y, np.log(Y_hat).T) + np.dot(1 - Y, np.log(1 - Y_hat).T)) | |
| return np.squeeze(cost) | |
| def get_accuracy_value(Y_hat, Y): | |
| Y_hat_ = convert_prob_into_class(Y_hat) | |
| return (Y_hat_ == Y).all(axis=0).mean() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i am not sure but i think it is