In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from bokeh.charts import Scatter, show
from bokeh.plotting import figure
from bokeh.io import output_notebook
output_notebook()
df = pd.read_csv('../MA490-MachineLearning-FinalProject//sineData5.csv')
In [2]:
df['Actual'] = np.zeros(100)
for i in range(100):
df['Actual'].values[i] = np.sin(df['Input'].values[i])
df.head()
Out[2]:
In [11]:
fig = Scatter(df[20:80], x='Input',y='Prediction',color='blue')
f = figure()
f.line(df.Input.values[18:82], df.Prediction.values[18:82], color='blue')
x = np.linspace(-3*np.pi-np.pi/2, 3*np.pi+np.pi/2, 100)
y = np.sin(x)
f.line(x,y,color='red')
x = [-3*np.pi,-3*np.pi]
y = [-3,3]
f.line(x,y,color='black')
x = [3*np.pi,3*np.pi]
y = [-3,3]
f.line(x,y,color='black')
show(f)
Out[11]:
Using skflow and its library I trained a TensorFlowDNNRegressor with 9 hidden units.
Process:
Originally trained using random data by picking random numbers between 0 and 1000 and converting to radians
Next used 0 to 720 degrees and fed all the values to the net.
Generated 10000 numbers between -π to π and fed the neural network the sine taylor expansion (9 of the terms) for each value.
In [ ]: