diff --git a/ex2/ex2_reg.py b/ex2/ex2_reg.py index a278948..bc1a5eb 100644 --- a/ex2/ex2_reg.py +++ b/ex2/ex2_reg.py @@ -13,6 +13,7 @@ from costFunctionReg import costFunctionReg from gradientFunctionReg import gradientFunctionReg from sigmoid import sigmoid +from predict import predict def optimize(Lambda): @@ -97,14 +98,14 @@ def plotBoundary(theta, X, y): plotBoundary(theta, X, y) # Compute accuracy on our training set -p = np.round(sigmoid(X.dot(theta))) -acc = np.mean(np.where(p == y.T, 1, 0)) * 100 +p = predict(theta, X) +acc = np.mean(np.where(p == y, 1, 0)) * 100 print('Train Accuracy: %f' % acc) input('Program paused. Press Enter to continue...') -# ============= Part 3: Optional Exercises ============= +# ============= Part 3: Optional Exercises ============= for Lambda in np.arange(0.0, 10.1, 1.0): result = optimize(Lambda)