In [1]:
%%HTML
<style>
# div.prompt {display:none}
</style>
In [2]:
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
%matplotlib inline
import sys
In [3]:
sys.path.append('/home/pedro/git/ElCuadernillo/ElCuadernillo/20160220_TensorFlowRegresionMultiple')
In [4]:
import gradient_descent_tensorflow as gdt
In [5]:
grado=4
tamano=100000
x,y,coeficentes=gdt.generar_muestra(grado,tamano)
print ("Coeficientes: ",coeficentes)
plt.plot(x,y,'.')
Out[5]:
Generamos la matriz de coeficientes de grado 5
In [6]:
train_x=gdt.generar_matriz_coeficientes(x,grado) # MatrizA
train_y=np.reshape(y,(y.shape[0],-1)) # VectorColumna
In [7]:
pesos_gd,ecm,t_c_gd=gdt.regression_gradient_descent(train_x,train_y,diff_error_parada=1e-4)
Mostramos la curva de error por iteracion
In [34]:
pesos_sgd,ecm,t_c_sgd=gdt.regression_stochastic_gradient_descent(train_x,train_y,1,diff_error_parada=1e-4)
In [9]:
plt=gdt.grafica_resultados(coeficentes,pesos_gd,pesos_sgd,t_c_gd,t_c_sgd)
plt.show()
In [19]:
(0.339/(100*382))/(8.45/(100000*618))
Out[19]:
In [16]:
(100000*618)/(100*382)
Out[16]:
In [12]:
0.339/382
Out[12]:
In [14]:
0.014158576051779935/0.0008874345549738221
Out[14]: