MainFile

                Never    
clc
clear
close all
t=0;
ts=[];
global callingTimesA  callingTimesG timeTableA timeTableG counterG
seed = 1;
rng(seed);

%% Read dataset
% datasetName = 'KDDcup99_Norm';
% path = [fileparts(fileparts(pwd)) '\CEDAS\Datasets\big data\' datasetName];
datasetName = 'DS2_Class';
path = [fileparts(fileparts(pwd)) '\CEDAS\Datasets\' datasetName];

sampleSpeed = 10;  % sampe/time unit
load(path)
dataset = data; 
numberOfClasses = max(dataset(:,end));

%% CEDAS parameters
radius = 0.05;    % CEDAS microC radius
decay = 1000;      % number of data samples to consider 'recent data'
fade = 1/decay;
minThreshold = 4; % Min microC threshold

%% Initialization

cmcs.Centre = []; % Create Micro-Cluster Structure 
                  % defines the location of the micro-cluster in data space
cmcs.Count = [];  % stores the total number of data samples that have been
                  % allocated to the micro-cluster
cmcs.Life = [];   %
cmcs.pointsIndices = []; %
outliers = cmcs;
cmcsGraph = graph();

%% Run the algorithm
counter = 0;
time = 0;

datalogSpeed = 25;
numberOfSubgraph =[];
% Assign variable
callingTimesA =  zeros(size(dataset,1),1); % Store number of caling times Within Assign
callingTimesAMean = zeros(ceil(size(dataset,1)/sampleSpeed),1);
timeTableA =  zeros(size(dataset,1),1);    % Store Elapsed time to calculate distance Within Assign
timeTableAMean = zeros(ceil(size(dataset,1)/sampleSpeed),1);
% Update Graph variable
counterG = 0;
callingTimesG =  []; % Store number of caling times Within Update Graph
timeTableG =  [];    % Store Elapsed time to calculate distance Within Update Graph

while counter<size(dataset,1)
    tic;
    time = time +1;
     for i = 1:sampleSpeed 

        if counter<size(dataset,1)
        counter = counter+1;
        dataPoint = dataset(counter,1:end-1);
        [cmcs,cmcsGraph,outliers] = ...
            Assign(cmcs,outliers,dataPoint,radius,minThreshold,cmcsGraph,counter);
        end

     end
    callingTimesAMean(time) = mean(callingTimesA(counter-sampleSpeed+1:counter));
    timeTableAMean(time) = mean(timeTableA(counter-sampleSpeed+1:counter));
    [cmcs,outliers,cmcsGraph] = Kill(cmcs,outliers,fade,cmcsGraph);
    
    if mod(time,datalogSpeed)==0
        dataLogged(time/datalogSpeed).graph = cmcsGraph;
        dataLogged(time/datalogSpeed).cmcs = cmcs;
        dataLogged(time/datalogSpeed).outliers = outliers;
        
        [targets,outputs] = ExtractPointOutputsTargets(dataLogged,time/datalogSpeed,dataset);
        dataLogged(time/datalogSpeed).targets = targets;
        dataLogged(time/datalogSpeed).outputs = outputs;
    end
    t=toc;
    ts=[ts t];
end
    
pause(0.01)


save([datasetName '_UpdateResults'],'dataLogged','radius','decay','minThreshold','sampleSpeed',...
    'callingTimesA','callingTimesG','timeTableA','timeTableG','callingTimesAMean','timeTableAMean','-v7.3');

Raw Text