Created
February 11, 2019 09:51
-
-
Save nithyadurai87/8c120370181f5bb9ad966dc9fdd7935b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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