Improve result display.

This commit is contained in:
2017-10-09 15:48:37 +02:00
parent 02e8337b38
commit 66851a11f8
2 changed files with 18 additions and 2 deletions

View File

@@ -22,8 +22,10 @@ int main(int argc, char *const argv[]) {
cout << "Result for " << image << ":" << endl;
auto res = simulator.simulate(image);
if (!labels.empty()) {
for (unsigned int i = 0; i < res.size(); ++i) {
cout << res[i] << " " << labels[i] << endl;
auto scores = combine(res, labels);
sort(scores.begin(), scores.end(), greater<>());
for (unsigned int i = 0; i < scores.size() && i < 5; ++i) {
cout << scores[i].first << " " << scores[i].second << endl;
}
} else {
cout << "Best result: " << *(max_element(res.begin(), res.end())) << endl;

View File

@@ -4,6 +4,7 @@
#include <fstream>
#include <vector>
#include <string>
#include <utility>
namespace fmri
{
@@ -40,4 +41,17 @@ namespace fmri
return res;
}
template<class T, class U>
std::vector<std::pair<T, U>> combine(const std::vector<T>& a, const std::vector<U>& b)
{
assert(a.size() == b.size());
std::vector<std::pair<T, U>> res;
for (size_t i = 0; i < a.size(); ++i) {
res.emplace_back(a[i], b[i]);
}
return res;
}
}