No BSD License  

Highlights from
Finding the Similar Entries: A Quantitative Approach based on CPU Runtime Behavior

image thumbnail

Finding the Similar Entries: A Quantitative Approach based on CPU Runtime Behavior

by

 

08 Apr 2009 (Updated )

Entry to Matlab contest Spring 2009

prepareData
function [s,p,leaders] = prepareData

load contest_data.mat d
s = d';

% Rename some fields.
[s(:).date] = deal(s.timestamp);
s = rmfield(s,'timestamp');
[s(:).based_on] = deal(s.parent);
s = rmfield(s,'parent');
[s(:).codeLength] = deal(s.charCount);
s = rmfield(s,'charCount');
[s(:).rawScore] = deal(s.result);
s = rmfield(s,'result');

% Add isLeader.
smallest = Inf;
for i = 1:length(s)
    if s(i).passed
        if (s(i).score < smallest)
            s(i).isLeader = true;
            smallest = s(i).score;
        else
            s(i).isLeader = false;
        end
    else
        s(i).isLeader = false;
    end
end

% Find only those which passed.
p = s([s.passed]);

% Separate from the pack.
leaders = p([p.isLeader]);

% Time in front.
for i = 1:length(leaders)-1
    leaders(i).timeInFront = leaders(i+1).date-leaders(i).date;
end
leaders(end).timeInFront = now-leaders(end).date;

% Absolute improvement
leaders(1).improvement = Inf;
for i = 2:length(leaders)
    prev = leaders(i-1).score;
    curr = leaders(i).score;
    leaders(i).improvement = abs(curr-prev);
end

% Percent improvement.
leaders(1).percentImprovement = Inf;
for n = 2:length(leaders)
    curr = leaders(n).score;
    prev = leaders(n-1).score;
    leaders(n).percentImprovement = 100*abs((curr-prev)/prev);
end

Contact us