In [1]:
import ext_datos as ext
import pandas as pd
import matplotlib.pyplot as plt
import procesar as pr
import rellenar as re
In [2]:
data = ext.extraer_data('dia2')
In [3]:
motores = pr.procesar(data)
In [5]:
motoresTest=motores.dropna()
In [21]:
len(motores)
Out[21]:
In [22]:
motoresTest=motoresTest[['busVoltage_m1','busVoltage_m2']]
motoresTest=motoresTest.reindex(np.random.permutation(motoresTest.index))
In [23]:
motor1=motoresTest['busVoltage_m1']
motor2=motoresTest['busVoltage_m2']
In [24]:
from sklearn import linear_model
In [25]:
motor1test=motor1[:len(motor1)/2]
motor2test=motor2[:len(motor2)/2]
motor1val=motor1[len(motor1)/2:]
motor2val=motor2[len(motor2)/2:]
In [26]:
xx = motor1test.reshape((motor1test.shape[0],-1))
yy = motor2test.reshape((motor2test.shape[0],-1))
xt = motor1val.reshape((motor1val.shape[0],-1))
yt = motor2val.reshape((motor2val.shape[0],-1))
In [27]:
regr = linear_model.LinearRegression()
In [28]:
regr.fit(xx,yy)
Out[28]:
In [29]:
print(regr.coef_,regr.intercept_)
In [30]:
np.mean((regr.predict(xt)-yt)**2)
Out[30]:
In [31]:
regr.score(xt, yt)
Out[31]:
In [32]:
plt.scatter(xt,yt, color='black')
plt.plot(xt, regr.predict(xt), color='blue',linewidth=3)
plt.show()
In [ ]:
np.array([regr.intercept_[0], regr.coef_[0]])
In [33]:
ecuacion_lineal_voltaje_m2=re.regresion_lineal(motores,'busVoltage_m1','busVoltage_m2')
In [34]:
ecuacion_lineal_voltaje_m1=re.regresion_lineal(motores,'busVoltage_m2','busVoltage_m1')
In [35]:
ecuacion_lineal_corriente_m2=re.regresion_lineal(motores,'busCurrent_m1','busCurrent_m2')
In [36]:
ecuacion_lineal_corriente_m1=re.regresion_lineal(motores,'busCurrent_m2','busCurrent_m1')
In [ ]:
motortest=motores[motores['busVoltage_m2'].isnull()]['busVoltage_m2']
motortest=ecuacion_lineal_voltaje_m2[0]+ecuacion_lineal_voltaje_m2[1]*motores[motores['busVoltage_m2'].isnull()]['busVoltage_m1']
In [ ]:
series=motores
series['busVoltage_m2'][series['busVoltage_m2'].isnull()].replace(motortest,inplace=True)
In [ ]:
motores['busVoltage_m2']
In [ ]: