Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Created February 11, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nithyadurai87/8c120370181f5bb9ad966dc9fdd7935b to your computer and use it in GitHub Desktop.
Save nithyadurai87/8c120370181f5bb9ad966dc9fdd7935b to your computer and use it in GitHub Desktop.
from mpl_toolkits.mplot3d.axes3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig, ax1 = plt.subplots(figsize=(8, 5),
subplot_kw={'projection': '3d'})
values = 2
r = np.linspace(-values,values,100)
theta0,theta1= np.meshgrid(r,r)
original_y = [1, 2, 3]
m = len(original_y)
predicted_y = [theta0+(theta1*1), theta0+(theta1*2), theta0+(theta1*3)]
sum=0
for i,j in zip(predicted_y,original_y):
sum = sum+((i-j)**2)
J = 1/(2*m)*sum
ax1.plot_wireframe(theta0,theta1,J)
ax1.set_title("plot")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment