diff --git a/ex1/ex1.py b/ex1/ex1.py index 89f87e9..84fa45c 100644 --- a/ex1/ex1.py +++ b/ex1/ex1.py @@ -106,11 +106,11 @@ for j in range(theta1_vals.size): t = np.array([theta0_vals[i], theta1_vals[j]]) col.append(computeCost(X, y, t.T)) - J_vals = np.column_stack((J_vals,col)) + J_vals = np.column_stack((J_vals, col)) # Because of the way meshgrids work in the surf command, we need to # transpose J_vals before calling surf, or else the axes will be flipped -J_vals = J_vals[:,1:].T +J_vals = J_vals[:, 1:].T theta0_vals, theta1_vals = np.meshgrid(theta0_vals, theta1_vals) # Surface plot @@ -152,7 +152,7 @@ plt.figure() plotData(x=data[:, 0], y=data[:, 1]) -plt.plot(X[:, 1], X.dot(regr.coef_), '-', color='black', label='Linear regression wit scikit') +plt.plot(X[:, 1], X.dot(regr.coef_), '-', color='black', label='Linear regression with scikit') plt.legend(loc='upper right', shadow=True, fontsize='x-large', numpoints=1) show() diff --git a/ex1/normalEqn.py b/ex1/normalEqn.py index dd45fc5..f1df033 100644 --- a/ex1/normalEqn.py +++ b/ex1/normalEqn.py @@ -1,7 +1,7 @@ import numpy as np -def normalEqn(X,y): +def normalEqn(X, y): """ Computes the closed-form solution to linear regression normalEqn(X,y) computes the closed-form solution to linear regression using the normal equations.