I guess you have an error in your model
function, where you calculate Y_prediction_train
. You are most likely using X_test
, which contains 50 examples, instead of X_train
, which has 209 examples.
Number of training examples: m_train = 209
Number of testing examples: m_test = 50
If I swap the datasets, I get the same error:
Cost after iteration 1800: 0.146542
Cost after iteration 1900: 0.140872
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-19-b8051f6b0651> in <module>
----> 1 logistic_regression_model = model(train_set_x, train_set_y, test_set_x, test_set_y, num_iterations=2000, learning_rate=0.005, print_cost=True)
<ipython-input-17-4d64b275fb28> in model(X_train, Y_train, X_test, Y_test, num_iterations, learning_rate, print_cost)
45 # Print train/test Errors
46 if print_cost:
---> 47 print("train accuracy: {} %".format(100 - np.mean(np.abs(Y_prediction_train - Y_train)) * 100))
48 print("test accuracy: {} %".format(100 - np.mean(np.abs(Y_prediction_test - Y_test)) * 100))
49
ValueError: operands could not be broadcast together with shapes (1,50) (1,209)