In [120]:
import numpy as np
import pandas as pd
pd = pd.read_csv("./pokemon.csv")
newcp = np.array(pd['cp_new'])
cp = np.array(pd['cp'])
cp = cp[:50]
newcp = newcp[:50]
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.scatter(cp, newcp)
plt.show()
In [121]:
import tensorflow as tf
# Initialize placeholders
x = tf.placeholder(tf.float32)
y = tf.placeholder(tf.float32)
W = tf.Variable([1], dtype=tf.float32)
b = tf.Variable([1], dtype=tf.float32)
linear_model = W*x + b
In [122]:
squared_deltas = tf.square(linear_model - y)
loss = (tf.reduce_sum(squared_deltas))
In [123]:
optimizer = tf.train.GradientDescentOptimizer(0.00000001)
train = optimizer.minimize(loss)
In [124]:
sess = tf.Session()
init = tf.global_variables_initializer()
sess.run(init)
plt.figure(figsize=(30, 50))
index =0
predict_cp = sess.run(linear_model,{x:cp})
#Draw Chart
ax = plt.subplot(6,4,1)
ax.scatter( cp,predict_cp)
ax.scatter( cp,newcp)
for i in range(100):
# Do Update !!!!
sess.run(train, {x:cp, y: newcp})
if i%5==0 :
predict_cp = sess.run(linear_model,{x:cp})
index +=1
error = sess.run(loss, {x: cp,y: newcp})/5
#Draw Chart
ax = plt.subplot(6,4,index+1)
ax.set_title(str(i)+":" + str(error))
ax.scatter( cp,predict_cp)
ax.scatter( cp,newcp)
plt.show()
In [ ]: