-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscore.h
More file actions
123 lines (104 loc) · 3.47 KB
/
score.h
File metadata and controls
123 lines (104 loc) · 3.47 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef __score_h__
#define __score_h__
#include <memory> // std :: unique_ptr
#include <utility> // std :: move
#include <cmath> // std :: sqrt
#include <stdint.h> // int32_t def for msvc
#include <utils.hpp> // old gcc compatibility
/**
* @class score
* @brief Abstract type representing the ensamble of usefull information to store during the
* couple evaluation.
*
* @details In particular the class includes:
* - The Matthews Correlation Coefficient values of each couple (`mcc`)
* - The first gene index of the couple (`gene_a`)
* - The second gene index of the couple (`gene_b`)
* - The total accuracy of the couple (`tot`)
* - The accuracy score for each class (`class_score`)
*
*/
struct score
{
std :: unique_ptr < float[] > mcc; ///< Matthews Correlation Correlation of the couples
std :: unique_ptr < int32_t[] > gene_a; ///< First index of the couples
std :: unique_ptr < int32_t[] > gene_b; ///< Second index of the couples
std :: unique_ptr < int32_t[] > tot; ///< Total accuracy of the couples
std :: unique_ptr < int32_t[] > class_score; ///< Accuracy score for each class
std :: unique_ptr < uint32_t[] > confusion; ///< Confusion matrix
int32_t N; ///< The number of stored results
int32_t n_class; ///< The number of classes (fixed to 2)
// Constructors
/**
* @brief Default constructor.
*
*/
score ();
/**
* @brief Constructor with number of couples and number of classes
*
* @details This is the constructor used inside the DNetPRO algorithm in which
* the number of couples can be evaluated as
*
* ```python
*number_of_combination = number_of_samples * (number_of_samples - 1) / 2
* ```
*
* @param N The number of available couples
* @param n_class The number of available classes in which the samples are divided
*
*/
score (const int32_t & N, const int32_t & n_class);
// Copy constructors
/**
* @brief Copy constructor.
*
* @details The operator doesn't perform a deep copy of the object but it just move all the buffers
* from the input object to the current one. In this way we optimize the memory management.
*
* @param s Score object
*
*/
score (score && s) noexcept = default; // o implementazione esplicita
/**
* @brief Copy operator.
*
* @details The operator doesn't perform a deep copy of the object but it just move all the buffers
* from the input object to the current one. In this way we optimize the memory management.
*
* @param s Score object
*
*/
score & operator = (score&& s) noexcept = default;
// Destructors
/**
* @brief Delete copy constructor
*
* @note This is employed to avoid accidental expensive copies
*/
score (const score &) = delete;
/**
* @brief Delete assignment operator
*
* @note This is employed to avoid accidental expensive copies
*/
score & operator = (const score &) = delete;
/**
* @brief Destructor set as default.
*
*/
~score () = default;
// Static functions
/**
* @brief Compute the Matthews correlation coefficient.
*
* @param row_sum Sum over rows of the confusion matrix.
* @param col_sum Sum over columns of the confusion matrix.
* @param K Number of classes.
* @param trace Trace of the confusion matrix.
* @param n Total number of samples.
* @return Matthews correlation coefficient.
*/
static float matthews_corrcoef (const int32_t * row_sum, const int32_t * col_sum, const int32_t & K, const int32_t & trace, const int32_t & n);
};
#endif // __score_h__