示例#1
0
def dataSmoothing3(changes):
    length = len(changes)
    x = np.linspace(1, length, num=length, endpoint=True)
    y = np.array(changes)
    kr = KernelReg(y, x, 'c')
    r_fit = KernelReg.r_squared(kr)
    #plt.figure(1)
    #plt.subplot(131)
    #plt.plot(x, y, 'go-')
    #plt.title("Original",fontsize=20)
    #plt.xlabel('Periods',fontsize=20)
    #plt.ylabel('Dockerfile Size',fontsize=20)
    #plt.grid(True)
    if length < 20:
        x1 = np.linspace(1, length, num=3 * length, endpoint=True)
    else:
        x1 = x
    y_pred, y_std = kr.fit(x1)
    #plt.subplot(132)
    #plt.plot(x1, y_pred,'bo-')
    #plt.title("Smoothing",fontsize=20)
    #plt.xlabel('Periods',fontsize=20)
    #plt.ylabel('Dockerfile Size',fontsize=20)
    #plt.grid(True)
    #plt.show()
    ynew = dataResampling(y_pred)
    xnew = np.linspace(1, 20, 20, endpoint=False)
    #plt.subplot(133)
    #plt.plot(xnew, ynew,'ro-')
    #plt.title("Resampling",fontsize=20)
    #plt.xlabel('Periods',fontsize=20)
    #plt.ylabel('Dockerfile Size',fontsize=20)
    #plt.grid(True)
    #plt.show()
    return ynew, r_fit