function accuracy = hComputeTop_5(predictionScores, net, dataStore)
%% hComputeAccuracy test helper function computes model level accuracy statistics

% Copyright 2019-2020 The MathWorks, Inc.
    
    classes = net.SortedLayers(end).Classes; 
    
    allData = dataStore.readall; 
    groundTruth = allData.response;
    
    % Compare with predicted label with actual ground truth 
    predictionError = {};
    for idx=1:numel(groundTruth)
        [~, idy] = sort(predictionScores(idx, :), 'descend'); 
        yActual = classes(idy(1:5));
        predictionError{end+1} = ismember(groundTruth(idx), yActual); %#ok
    end
    
    % Sum all prediction errors.
    predictionError = [predictionError{:}];
    accuracy = sum(predictionError)/numel(predictionError);
end
