-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore.h
110 lines (92 loc) · 3 KB
/
score.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
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
#ifndef __score_h__
#define __score_h__
#include <memory> // std :: unique_ptr
#include <utility> // std :: move
#include <cmath> // std :: sqrt
#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 < std :: unique_ptr < int32_t[] >[] > class_score; ///< Accuracy score for each class
int32_t N; ///< The number of couples
int32_t n_class; ///< The number of classes
// 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);
/**
* @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);
// Destructors
/**
* @brief Destructor set as default.
*
*/
~score () = default;
// Static functions
/**
* @brief Compute the Matthews Correlation Coefficient from the class scores
*
* @param s0 True positive score
* @param m0 Total of true positive
* @param s1 False Negative score
* @param m1 Total of false negative
*
* @note This function is useful in the current implementation since we can easily manage
* the information used by the score object without recomputing new ones.
*
*/
static float matthews_corrcoef (const float & s0, const int32_t & m0, const float & s1, const int32_t & m1);
};
#endif // __score_h__