blob: 61bc264849ef593a276911bb84e5550aac11b820 (
plain)
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
|
#include "effectivenessobserver.h"
EffectiveInteractionEnforcer::EffectiveInteractionEnforcer(const arma::uvec &sampleIndices)
: m_sampleIndices(sampleIndices)
, m_effectiveness(arma::zeros<arma::vec>(sampleIndices.n_elem))
{
}
void EffectiveInteractionEnforcer::setSelection(const QSet<int> &selection)
{
m_selection = selection;
}
void EffectiveInteractionEnforcer::setMeasureDifference(const arma::vec &measure)
{
m_measure = measure;
if (m_selection.isEmpty()) {
return;
}
arma::uvec selectionIndices(m_selection.size());
int i = 0;
for (auto it = m_selection.cbegin(); it != m_selection.cend(); it++) {
selectionIndices[i] = m_sampleIndices[*it];
i++;
}
double diff = arma::mean(m_measure(selectionIndices));
int effectiveness;
if (diff > 0) {
effectiveness = 1;
} else if (diff < 0) {
effectiveness = -1;
} else {
effectiveness = 0;
}
for (auto it = m_selection.cbegin(); it != m_selection.cend(); it++) {
m_effectiveness[*it] = effectiveness;
}
emit effectivenessChanged(m_effectiveness);
}
|