# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 2
#     language: python
#     name: python2
# ---

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')

# +
df['Actual'] = np.zeros(100)
for i in range(100): 
    df['Actual'].values[i] = np.sin(df['Input'].values[i])
    
df.head()
# -

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)

# ##### sine(x): Calculates the sine of x.

# Using skflow and its library I trained a TensorFlowDNNRegressor with 9 hidden units.
# <br>Process:
# * Originally trained using random data by picking random numbers between 0 and 1000 and converting to radians
#     * Trained over 10,000 iterations.
#     * Used 2 hidden units.
#     * Had very high error.
#     
# * Next used 0 to 720 degrees and fed all the values to the net.
#     * Trained over 10,000 iterations.
#     * Used 2 hidden units.
#     * Still had very high error, didn't seem to learn very well.
#     
# * Generated 10000 numbers between -π to π and fed the neural network the sine taylor expansion (9 of the terms) for each value.
#     * Trained over 10,000 iterations.
#     * Used 9 hidden units.
#     * Was much more accurate than the previous attempts, can predict in the range between -pi and pi almost spot on.
#     * As you increase the range the prediction becomes less accurate and heads off to infinite and can't seem to generalize the sine curve.
# * Generated 10000 numbers between -3π to 3π
#     * Trained over 100,000 iterations
#     * Used 9 hidden units
#     * Still accurate between -3π and 3π yet outside of that range still expands to infinity



StarcoderdataJupyterScriptsDedupFiltered