forked from Yiqing-Gu/Pidentify
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodelState.cpp
More file actions
42 lines (37 loc) · 1.02 KB
/
modelState.cpp
File metadata and controls
42 lines (37 loc) · 1.02 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
#include <iostream>
#include <numeric>
#include <thread>
#include "modelState.h"
void ModelState::setDatasetSize() {
datasetSize = std::accumulate(numInstancesPerClass.begin(), numInstancesPerClass.end(), 0,
[](size_t a, const std::pair<std::string, double>& b) {return a + b.second; });
}
void ModelState::setWeightExp(const std::string& weightScheme) {
if (weightScheme == "squared") {
weightExp = 2;
}
else if (weightScheme == "linear") {
weightExp = 1;
}
else if (weightScheme == "unweighted") {
weightExp = 0;
}
else if (weightScheme == "cube root") {
weightExp = 1.0 / 3.0;
}
else {
std::cerr << "ERROR: Weight scheme must be one of: \"squared\", \"linear\", \"unweighted\", \"cube root\"\n";
std::exit(0);
}
}
void ModelState::clearTemporaries() {
zeroStdDeviation.clear();
classMap.clear();
if (!preexistingBestfit) {
bestFit.clear();
}
}
// Initialize number of threads to use concurrently
void setThreads() {
NUM_THREADS = std::max(static_cast<int>(std::thread::hardware_concurrency()), 4);
}