ECF 1.5
utility.cpp
1#include <set>
2#include "utility.h"
3namespace utility{
4 uint vectorArgmax(const std::vector<double>& v) {
5 uint argmax = 0;
6 double currentBest = v[0];
7 for(uint i = 1; i < v.size(); i++) {
8 if(v[i] > currentBest) {
9 currentBest = v[i];
10 argmax = i;
11 }
12 }
13 return argmax;
14 }
15
16 std::vector<std::vector<int> > initializeEmptyConfusionMatrix(const std::vector<int>& classes) {
17 std::set<int> diffClasses;
18 for(uint i = 0; i < classes.size(); i++) {
19 diffClasses.insert(classes[i]);
20 }
21 std::vector<int> row(diffClasses.size(),0);
22 return std::vector<std::vector<int> >(diffClasses.size(),row);
23 }
24}