Update app.py
Browse files116 unmodified lines117118119120121122123124125126127128129130131132133116 unmodified linesplt.contourf(b,w,Z, 50, alpha=0.5, cmap=plt.get_cmap('jet'))### (5.5) Add optimal loss#plt.plot(theta0_best, theta1_best, 'x', ms=12, markeredgewidth=3, color='orange')#plt.text(theta0_best, theta1_best,'MSE:'+str(np.round(cal_mse(X,y,theta0_best, theta1_best),2)), color='red', fontsize=22)### (5.6) Add loss of random lines#if intercept_random != intercept or slope_random != slope: #avoid overlap#plt.plot(intercept_random, slope_random, 'o', ms=5, markeredgewidth=3, color='orange')#plt.text(intercept_random, slope_random,'MSE:'+str(np.round(cal_mse(X,y,intercept_random, slope_random),2)), fontsize=22)### (5.7) draw gradient updates#if gradient_descent:# plt.plot(b_history, w_history, 'o-', ms=3, lw=1.5, color='black')116 unmodified lines117118119120121122123124125126127128129130131132133116 unmodified linesplt.contourf(b,w,Z, 50, alpha=0.5, cmap=plt.get_cmap('jet'))### (5.5) Add optimal lossplt.plot(theta0_best, theta1_best, 'x', ms=12, markeredgewidth=3, color='orange')plt.text(theta0_best, theta1_best,'MSE:'+str(np.round(cal_mse(X,y,theta0_best, theta1_best),2)), color='red', fontsize=22)### (5.6) Add loss of random linesif intercept_random != intercept or slope_random != slope: #avoid overlapplt.plot(intercept_random, slope_random, 'o', ms=5, markeredgewidth=3, color='orange')plt.text(intercept_random, slope_random,'MSE:'+str(np.round(cal_mse(X,y,intercept_random, slope_random),2)), fontsize=22)### (5.7) draw gradient updatesif gradient_descent:plt.plot(b_history, w_history, 'o-', ms=3, lw=1.5, color='black')
app.py+7-7