e_high = 0.98
    e_low = 0.96
    alpha = 0.96

    holdOFF = 0

    # My version
    res_me = FRAHST_V3_1(
        data, alpha=0.96, e_low=0.96, e_high=0.98, holdOffTime=holdOFF, fix_init_Q=1, r=1, evalMetrics="T"
    )

    res_me["Alg"] = "My Implimentation of FRAUST"

    # metric_me, sets_me, anom_det_tab_me = analysis(res_me, AbileneMat['P_g_truth_tab'], n)

    pltSummary(res_me, data)

    # Pedros Version
    res_ped = frahst_pedro(
        data, r=1, alpha=0.96, energy_low=0.96, energy_high=0.98, holdOffTime=holdOFF, evaluateTruth="FALSE"
    )

    res_ped["Alg"] = "Pedros Implimentation of FRAUST"

    # metric_ped, sets_ped, anom_det_tab_ped = analysis(res_ped, AbileneMat['P_g_truth_tab'], n)

    pltSummary(res_ped, data)

#    x = arange(data.shape[0])
#    figure(); step(x,res['r_hist']) ; title('r_hist')
#    figure(); plot(res['RSRE']) ; title('RSRE')
Example #2
0
# -*- coding: utf-8 -*-
"""
Created on Wed May 18 11:23:36 2011
Test SPIRIT and Frahst on Contol Time Series: Cyclic 
@author: - Musselle
"""
from ControlCharts import Tseries
from CUSUM import cusum
import numpy as np
import matplotlib.pyplot as plt
from Frahst_v3_1 import FRAHST_V3_1
from SPIRIT import SPIRIT
from utils import analysis, QRsolveA, pltSummary
#===============================================================================
# Runscript
#===============================================================================
#============
# Initialise
#============
'Create time series string'
series_1 = Tseries(0)
series_2 = Tseries(0)
series_3 = Tseries(0)
series_4 = Tseries(0)
series_5 = Tseries(0)
# S 1
# CYCLIC - Normal - Cyclic
series_1.cyclicEt(100, base=6, noise=0.1, amp=2, period=5, phase=0, \
                    noise_type = 'gauss')
series_1.normalEt(100, base=6, noise=0.00000000000000001, noise_type='gauss')
Example #3
0
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 05 23:19:11 2011
THIS IS THE VERSION TO RUN ON MAC, NOT WINDOWS
@author: musselle
"""
from numpy import eye, zeros, dot, sqrt, log10, trace, arccos, nan, arange
import numpy as np
from numpy.random import rand
from numpy.linalg import qr, eig, norm, solve
from matplotlib.pyplot import plot, figure, title, step
from artSigs import genCosSignals_no_rand , genCosSignals
import scipy.io as sio
from utils import analysis, QRsolveA, pltSummary
from PedrosFrahst import frahst_pedro_original

def FRAHST_V3_2(data, r=1, alpha=0.96, e_low=0.96, e_high=0.98, fix_init_Q = 0, holdOffTime=0, 
                evalMetrics = 'F', static_r = 0, r_upper_bound = None, ignoreUp2 = 0):
    """
        Fast Rank Adaptive Householder Subspace Tracking Algorithm (FRAHST)  
    
    Version 3.2 -  Added ability to fix r to a static value., and also give it an upper bound.
                   If undefined, defaults to num of data streams. 
        
    Version 3.1 - Combines good bits of Pedros version, with my correction of the bugs
    
    Changed how the algorithm deals with sci. only difference, but somehow has a bigish 
    effect on the output.
    
    """   
Example #4
0
# -*- coding: utf-8 -*-
"""
Created on Wed May 18 11:23:36 2011
Test SPIRIT and Frahst on Contol Time Series: Cyclic 
@author: - Musselle
"""
from ControlCharts import Tseries
from CUSUM import cusum 
import numpy as np
import matplotlib.pyplot as plt
from Frahst_v3_1 import FRAHST_V3_1
from SPIRIT import SPIRIT
from utils import analysis, QRsolveA, pltSummary
#===============================================================================
# Runscript 
#===============================================================================
#============
# Initialise
#============
'Create time series string'
series_1 = Tseries(0)
series_2 = Tseries(0)
series_3 = Tseries(0)
series_4 = Tseries(0)
series_5 = Tseries(0)
# S 1
# CYCLIC - Normal - Cyclic
series_1.cyclicEt(100, base=6, noise=0.1, amp=2, period=5, phase=0, \
                    noise_type = 'gauss')
series_1.normalEt(100, base=6, noise = 0.00000000000000001, noise_type ='gauss')
Example #5
0
holdOFF = 0.0


# var_vals = [0.98, 0.96, 0.94, 0.92, 0.9]
var_vals = [0.88, 0.86, 0.84, 0.82, 0.8]

# Run mini Batch

for val in var_vals:

    # Variable to alter
    alpha = val

    # SPIRIT
    res_sp, all_weights = SPIRIT(streams, [e_low, e_high], alpha)
    res_sp["Alg"] = "My SPIRIT with alpha = " + str(val)

    pltSummary(res_sp, streams)

    # My version of Frahst
    res_fr = FRAHST_V3_1(
        streams, alpha=alpha, e_low=e_low, e_high=e_high, holdOffTime=holdOFF, fix_init_Q=1, r=1, evalMetrics="F"
    )

    res_fr["Alg"] = "My FRAHST with alpha = " + str(val)

    # metric_me, sets_me, anom_det_tab_me = analysis(res_me, AbileneMat['P_g_truth_tab'], n)

    pltSummary(res_fr, streams)
Example #6
0
# Run mini Batch     
run_spirit_me = 0
run_spirit_original = 1
    
for val in var_vals :     
    
    # Variable to alter    
    alpha = val
    if run_spirit_me == 1:
        # SPIRIT
        res_spme, all_weights = SPIRIT(streams, [e_low, e_high], alpha, evalMetrics = 'T') 
        res_spme['Alg'] = 'My SPIRIT with alpha = ' + str(val)    
        
#        data = res_spme
        pltSummary(res_spme, streams)                 
                 
    if run_spirit_original == 1:
    
        # My version of Frahst 
        res_spor = SPIRIT2(streams, alpha, [e_low, e_high], k0 = 1, holdOffTime = 10,                            
                         reorthog = False, evalMetrics = 'T')
        
        res_spor['Alg'] = 'Original FRAHST with alpha = ' + str(val)
    
        #plot_31(res_fr['RSRE'], res_fr['e_ratio'], res_fr['orthog_error'],
        #        ['RSRE','Energy Ratio','Orthogonality\nError (dB)'], 'Time Steps', 
        #         'Error Analysis of FRAHST' )    
    
        # metric_me, sets_me, anom_det_tab_me = analysis(res_me, AbileneMat['P_g_truth_tab'], n)
Example #7
0
    e_low = 0.95
    alpha = 0.96

    holdOFF = 0

    energyThresh = [0.96, 0.98]
    alpha = 0.96
    # rr = 4

    # Pedros Original Version
    res_ped_orig = frahst_pedro_original(data,
                                         r=1,
                                         alpha=alpha,
                                         e_low=e_low,
                                         e_high=e_high,
                                         holdOffTime=holdOFF,
                                         evalMetrics='F')
    res_ped_orig['Alg'] = 'Pedros Original Implimentation of FRAUST'
    pltSummary(res_ped_orig, data)

    # Pedros Version Fixed by me
    res_ped_fix = frahst_pedro_fixed(data,
                                     r=1,
                                     alpha=alpha,
                                     e_low=e_low,
                                     e_high=e_high,
                                     holdOffTime=holdOFF,
                                     evalMetrics='F')
    res_ped_fix['Alg'] = 'Pedros Version (Fixed) of FRAUST'
    pltSummary(res_ped_fix, data)
Example #8
0
            bot = bot + (norm(data_vec) ** 2)
            res['RSRE'] = vstack((res['RSRE'], top / bot))        
            res['e_ratio'] = vstack((res['e_ratio'], E_x / E_y))    
            res['hidden'] = vstack((res['hidden'], hidden)) 
            res['r_hist'] = vstack((res['r_hist'], r))
            res['E_x'] = vstack((res['E_x'], E_x)) 
            res['E_y'] = vstack((res['E_y'], E_y)) 
            res['recon'] = vstack((res['recon'], recon.T))
            if anomaly : 
                res['anomalies'].append(t)
            
            t += 1        
            
        res['Alg'] = 'My Incremetal FrahstNode Implimentation of FRAUST'
    
        pltSummary(res, packet_data)    
        
    #######################    
    if test_FrahstNode_OD:
    
        # Load OD network dataset from folder.
        os.chdir('/Users/Main/DataSets/Python/Network_ODs')
    
        # The Link flows vector
        with open('Y_t_data.pk', 'r') as data_file :
            Y_t = pk.load(data_file)     

        packet_data_iter = iter(Y_t)
        
        # Create Frahst node object  (alpha, e_high, e_low)
        F1 = FrahstNode(0.96, 0.98, 0.96, evalMetrics = True)
Example #9
0
            bot = bot + (norm(data_vec)**2)
            res['RSRE'] = vstack((res['RSRE'], top / bot))
            res['e_ratio'] = vstack((res['e_ratio'], E_x / E_y))
            res['hidden'] = vstack((res['hidden'], hidden))
            res['r_hist'] = vstack((res['r_hist'], r))
            res['E_x'] = vstack((res['E_x'], E_x))
            res['E_y'] = vstack((res['E_y'], E_y))
            res['recon'] = vstack((res['recon'], recon.T))
            if anomaly:
                res['anomalies'].append(t)

            t += 1

        res['Alg'] = 'My Incremetal FrahstNode Implimentation of FRAUST'

        pltSummary(res, packet_data)

    #######################
    if test_FrahstNode_OD:

        # Load OD network dataset from folder.
        os.chdir('/Users/Main/DataSets/Python/Network_ODs')

        # The Link flows vector
        with open('Y_t_data.pk', 'r') as data_file:
            Y_t = pk.load(data_file)

        packet_data_iter = iter(Y_t)

        # Create Frahst node object  (alpha, e_high, e_low)
        F1 = FrahstNode(0.96, 0.98, 0.96, evalMetrics=True)
Example #10
0
                
        top = top + (norm(data_vec - recon) ** 2 )
        bot = bot + (norm(data_vec) ** 2)
        res['RSRE'] = vstack((res['RSRE'], top / bot))        
        res['e_ratio'] = vstack((res['e_ratio'], E_x / E_y))    
        res['hidden'] = vstack((res['hidden'], hidden)) 
        res['r_hist'] = vstack((res['r_hist'], param['r']))
        res['E_x'] = vstack((res['E_x'], E_x)) 
        res['E_y'] = vstack((res['E_y'], E_y)) 
        res['recon'] = vstack((res['recon'], recon.T)) 
        if anomaly : 
            res['anomalies'].append(param['t'])
            
    res['Alg'] = 'My Incremetal Implimentation of FRAUST'

    pltSummary(res, data)
    
    #################### End of incremental version of Frahst #############
    
    # My Original version 
    res_me1 = FRAHST_V3(data, r = 1, 
                        alpha = param['alpha'], 
                        e_low = param['e_low'], 
                        e_high = param['e_high'],
                        holdOffTime=param['holdOffTime'],
                        fix_init_Q = 1, 
                        sci = 1,
                        evalMetrics = 'F') 

    res_me1['Alg'] = 'My First Implimentation of FRAUST sci = 1'