Skip to content

Instantly share code, notes, and snippets.

@SkalskiP
Last active April 20, 2020 07:11
Show Gist options
  • Select an option

  • Save SkalskiP/da4eb493c73e6d29c673978d4c67a248 to your computer and use it in GitHub Desktop.

Select an option

Save SkalskiP/da4eb493c73e6d29c673978d4c67a248 to your computer and use it in GitHub Desktop.
Calculating the value of the cost function and accuracy
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()
@imjcham

imjcham commented Oct 13, 2018

Copy link
Copy Markdown

Where is the convert_prob_into_class function defined?

@25shmeckles

Copy link
Copy Markdown

Yes, where can we find convert_prob_into_class ?

@Cheruiyotd

Cheruiyotd commented Jun 3, 2019

Copy link
Copy Markdown

Where is the convert_prob_into_class function defined?

i am not sure but i think it is

def convert_prob_into_class(probs):
         probs_ = np.copy(probs)
         probs_[probs_ > 0.5] = 1
         probs_[probs_ <= 0.5] = 0
         return probs_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment