-
Notifications
You must be signed in to change notification settings - Fork 1
/
Metric.h
65 lines (49 loc) · 1.24 KB
/
Metric.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Metric.h
*
* Created on: Mar 17, 2015
* Author: mszhang
*/
#ifndef SRC_METRIC_H_
#define SRC_METRIC_H_
using namespace std;
class Metric {
public:
int overall_label_count;
int correct_label_count;
int correct_uas_count;
public:
Metric() {
overall_label_count = 0;
correct_label_count = 0;
correct_uas_count = 0;
}
~Metric() {
}
void reset() {
overall_label_count = 0;
correct_label_count = 0;
correct_uas_count = 0;
}
bool bIdentical() {
if (overall_label_count == correct_label_count) {
return true;
}
return false;
}
double getAccuracy() {
return correct_label_count * 1.0 / overall_label_count;
}
void print() {
if(correct_uas_count > 0)
{
std::cout << "UAS :\tP=" << correct_uas_count << "/" << overall_label_count << "=" << correct_uas_count * 1.0 / overall_label_count
<< " LAS :\tP=" << correct_label_count << "/" << overall_label_count << "=" << correct_label_count * 1.0 / overall_label_count << std::endl;
}
else
{
std::cout << "Accuracy :\tP=" << correct_label_count << "/" << overall_label_count << "=" << correct_label_count * 1.0 / overall_label_count << std::endl;
}
}
};
#endif /* SRC_EXAMPLE_H_ */