Halloween Sale: Flat 70% + Addl. 25% Off + 30 Days Extra Lab on all Courses | Use Coupon HS25 in Checkout | Offer Expires In

  Enroll Now

Cat vs Non-cat Classifier - Defining some utility functions - Predict

This function predicts the labels of the dataset by calling the sigmoid function.

The prediction for a sample is given out as

  • 1 if the sigmoid function returns a value greater than 0.5
  • 0 if the sigmoid function returns a value lesser than 0.5
INSTRUCTIONS

Copy-paste the following code to predict.

def predict(w, b, X):
    m = X.shape[1]
    Y_prediction = np.zeros((1, m))
    w = w.reshape(X.shape[0], 1)

    #Compute probability vector
    A = sigmoid(np.dot(w.T, X) + b)

    for i in range(A.shape[1]):
        Y_prediction[0, i] = 1 if A[0, i] > 0.5 else 0

    return Y_prediction

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...