示例#1
0
def CuSumPlots():
#=============================================================================
    cusum_data = PD._cusum(data)    
    def change(dates,headings,cusum_data,DateLine,row,col,plot_num,y_col):
        plt.subplot(row,col,plot_num)
        plt.plot(dates,cusum_data[:,y_col])
        date = np.int(np.floor(len(dates) * DateLine))
        plt.axvline(dates[date], color='red')
        plt.grid(True)
        plt.title(headings[y_col])
        plt.xticks(rotation = 90)
        fig = plt.gcf()
        fig.subplots_adjust(top=0.95) 
        fig.subplots_adjust(bottom=0.12) 
        fig.subplots_adjust(left=0.08) 
        fig.subplots_adjust(right=0.97) 
        ax = plt.gca()
        ax.xaxis.label.set_color([0.75,0.75,0.75])
        ax.tick_params(axis='x', colors=[0.75,0.75,0.75])
    
    
    
    plt.figure('CuSum plots')
    plt.clf()
    row = 7
    col = 1
    DateLine = 0.85
    
    y_col = 3
    plot_num = 1
    change(dates,headings,cusum_data,DateLine,row,col,plot_num,y_col)
    
    y_col = 4
    plot_num = plot_num + 1
    change(dates,headings,cusum_data,DateLine,row,col,plot_num,y_col)
    
    y_col = 5
    plot_num = plot_num + 1
    change(dates,headings,cusum_data,DateLine,row,col,plot_num,y_col)
    
    y_col = 8
    plot_num = plot_num + 1
    change(dates,headings,cusum_data,DateLine,row,col,plot_num,y_col)
    
    y_col = 12
    plot_num = plot_num + 1
    change(dates,headings,cusum_data,DateLine,row,col,plot_num,y_col)
    
    y_col = 10
    plot_num = plot_num + 1
    change(dates,headings,cusum_data,DateLine,row,col,plot_num,y_col)
    
    y_col = 11
    plot_num = plot_num + 1
    change(dates,headings,cusum_data,DateLine,row,col,plot_num,y_col)
    
    ax = plt.gca()
    ax.xaxis.label.set_color([0,0,0])
    ax.tick_params(axis='x', colors=[0,0,0])
    
    plt.show()
示例#2
0
for i in range(len(data)):
    if (data[i,2] > 0 and
        data[i,2] > 0):
            data1[m,] = data[i,]
            ave_data1[m,] = ave_data[i,]
            m = m + 1

data = np.zeros((m,a[1]))
ave_data = np.zeros((m,a[1]))
dates = range(m)
for i in range(m):
    data[i,] = data1[i,]
    ave_data[i,] = ave_data1[i,]
    dates[i] = datetime.datetime(*xlrd.xldate_as_tuple(data[i,0],0)) 
 
cusum_data = PD._cusum(data)



   
"""
==============================================================================
=================================== PCA ======================================
"""   

def PCA():
#=============================================================================
    #select which elements of the "data" matirx you wish to analyse    
    data_set = [2,3,8,12,30,17,34,35]     
    
    #define the variable column for which predictors need to be identified