function [loss, win, tie] = myPred25(actuals,predictions,algorithms,datasetName)

% MRE = abs(actual - predicted)/actual and MMRE is the mean of all MREs

% define a variable to keep the MMRE results for each algorithm
MREResults = -1 * ones(size(algorithms,1),size(actuals,1));

% define a variable to keep the pred25 results for each algorithm
pred25Results = -1 * ones(size(algorithms,1),1);

% process each algorithm's results
for i = 1:size(algorithms,1)
   MREResults(i,:) = abs(actuals' - predictions(i,:))./actuals';
   pred25Results(i) = (size(find(MREResults(i,:)<=0.25),2)*100)/size(MREResults(i,:),2);
end

% define win tie loss variables
win = zeros(size(algorithms,1),1);
tie = zeros(size(algorithms,1),1);
loss = zeros(size(algorithms,1),1);

% start calculating win tie loss values
for i = 1:size(algorithms,1)
    for j = (i+1):size(algorithms,1)
        if i ~= j   % if i and j are different
            eval(['[P,H] = ranksum(MREResults(',num2str(i),',:),MREResults(',num2str(j),',:));']);
            if H == 0   % if they are the same
                eval(['tie(',num2str(i),') = tie(',num2str(i),') +1;']);
                eval(['tie(',num2str(j),') = tie(',num2str(j),') +1;']);
            else
                % calculate pred values
                eval(['pred25i = size(find(MREResults(',num2str(i),',:)<=0.25),2) / size(MREResults(',num2str(i),',:),2);']);
                eval(['pred25j = size(find(MREResults(',num2str(j),',:)<=0.25),2) / size(MREResults(',num2str(j),',:),2);']);
                if pred25i > pred25j
                    eval(['win(',num2str(i),') = win(',num2str(i),') +1;']);
                    eval(['loss(',num2str(j),') = loss(',num2str(j),') +1;']);
                else
                    eval(['win(',num2str(j),') = win(',num2str(j),') +1;']);
                    eval(['loss(',num2str(i),') = loss(',num2str(i),') +1;']);
                end
            end
        end
    end
end

% and write the pred(25) values to mdmre file
pred25ValuesFile=fopen('pred25Values.txt','a' );
fprintf(pred25ValuesFile, char(datasetName),'%s');
for i = 1:size(algorithms,1)
    fprintf(pred25ValuesFile, [',' num2str(pred25Results(i))]);
end
fprintf(pred25ValuesFile, '\n');    % append a new line at the end of the line
% close file
fclose(pred25ValuesFile);

end