print('Caso 1 Tipo Abrupto/Repentino - Aumento de pendiente ONLINE') np.random.seed(1) xbuild, ybuild = genDataLine(4, 10, 500, 0, 3) x0, y0 = genDataLine(4, 10, 500, 0, 3) x1, y1 = genDataLine(10, 10, 75, 0, 3) x2, y2 = genDataLine(10, 10, 425, 0, 3) x = x0 + x1 y = y0 + y1 dfList = list(zip(x0,y0)) data0 = pd.DataFrame(dfList, columns = ['x' , 'y']) sns.lmplot(x="x", y="y", data=data0, line_kws = {'color':'cyan'}) plt.scatter(x1+x2,y1+y2) plt.show() alg = ac.DetectChangeAlgOnline(300, 100, xbuild, ybuild, 0.2, 20) alg.printModel() start = time.time() alg.addData(x, y) time1 = time.time()-start alg.printModel() start = time.time() alg.addData(x2, y2) print(f"Add data Time Taken: {(time.time() - start)+time1:.3f} sec") alg.plotResiduals() alg.plotErrorAcum() alg.printModel() alg.mae() print('Change Points: ' + str(alg.changePoints))
if __name__ == "__main__": print('Caso 4 Outliers - Prueba de robustez}') print('Prueba 2 - Outliers dispersos') np.random.seed(2) xbuild, ybuild = genDataLine(4, 10, 300, 0, 3) x, y = genDataLine(4, 10, 1000, 0, 3) y[500] = 47 y[600] = 15 y[650] = 10 y[720] = 30 plt.scatter(x, y) plt.show() print('\u03BB = 20') alg = ac.DetectChangeAlg(300, 100, xbuild, ybuild, 0.2, 20) alg.addData(x, y) alg.plotErrorAcum() print('Change Points: ' + str(alg.changePoints)) print('\u03BB = 40') alg = ac.DetectChangeAlg(300, 100, xbuild, ybuild, 0.2, 40) alg.addData(x, y) alg.plotErrorAcum() print('Change Points: ' + str(alg.changePoints)) print('\u03BB = 100') alg = ac.DetectChangeAlg(300, 100, xbuild, ybuild, 0.2, 100) alg.addData(x, y) alg.plotErrorAcum() print('Change Points: ' + str(alg.changePoints))
xbuild, ybuild = genDataLine(4, 10, 500, 0, 3) x0, y0 = genDataLine(4, 10, 500, 0, 3) x1, y1 = genDataPol(aArray, bArray, cArray, dArray, 125, 0, 3) x = x0 + x1 y = y0 + y1 x2, y2 = genDataPol(aArray2, bArray2, cArray2, dArray2, 375, 0, 3) dfList = list(zip(x0,y0)) data0 = pd.DataFrame(dfList, columns = ['x' , 'y']) sns.lmplot(x="x", y="y", data=data0, line_kws = {'color':'cyan'}) plt.scatter(x1,y1) plt.scatter(x2,y2) plt.show() alg = ac.DetectChangeAlg(300, 100, xbuild, ybuild, 0.2, 50) alg.printModel() start = time.time() alg.addData(x, y) time1 = time.time()-start alg.printModel() start = time.time() alg.addData(x2, y2) print(f"Add data Time Taken: {(time.time() - start)+time1:.3f} sec") alg.plotResiduals() alg.plotErrorAcum() alg.printModel() alg.mae() print('Change Points: ' + str(alg.changePoints))