Medial Code Documentation
Loading...
Searching...
No Matches
LabelParams.h
1#ifndef __LABEL_PARAMS_H__
2#define __LABEL_PARAMS_H__
3
4#include "MedEnums.h"
5#include <unordered_map>
6#include <map>
9
10using namespace std;
15private:
16 bool has_default_mode;
17 bool has_default_range;
18 TimeWindowMode default_modes[2];
19 pair<float, float> default_intersection_range;
20
21public:
22 unordered_map<float, TimeWindowMode[2]> interaction_mode;
23 unordered_map<float, pair<float, float>> intersection_range_condition;
24
26 has_default_mode = false;
27 has_default_range = false;
28 default_modes[0] = TimeWindowMode::All_;
29 default_modes[1] = TimeWindowMode::All_;
30 default_intersection_range.first = 0; default_intersection_range.second = 0;
31 }
32
33 TimeWindowMode *operator[] (float x) {
34 if (interaction_mode.find(x) != interaction_mode.end() || !has_default_mode)
35 return interaction_mode[x];
36 //has_default_mode is true and not exist
37 return default_modes;
38 }
39
40 bool find(const float x) const {
41 return has_default_mode || interaction_mode.find(x) != interaction_mode.end();
42 }
43
44 const TimeWindowMode *at(float x) const {
45 if (interaction_mode.find(x) != interaction_mode.end() || !has_default_mode)
46 return interaction_mode.at(x);
47 return default_modes;
48 }
49
50 void set_default(TimeWindowMode defaults_m[2]) {
51 if (has_default_mode)
52 HMTHROW_AND_ERR("Error - TimeWindowInteraction has already default\n");
53 has_default_mode = true;
54 default_modes[0] = defaults_m[0];
55 default_modes[1] = defaults_m[1];
56 }
57
58 void set_default_range(float min_range, float max_range) {
59 default_intersection_range.first = min_range;
60 default_intersection_range.second = max_range;
61 has_default_range = true;
62 }
63
64 bool get_inresection_range_cond(float x, float &min_range, float &max_range) const {
66 min_range = intersection_range_condition.at(x).first;
67 max_range = intersection_range_condition.at(x).second;
68 return true;
69 }
70 else if (has_default_range) {
71 min_range = default_intersection_range.first;
72 max_range = default_intersection_range.second;
73 return true;
74 }
75 return false;
76 }
77
78 void reset_for_init() {
79 has_default_mode = false;
80 has_default_range = false;
81 interaction_mode.clear();
83 }
84
85 void init_from_string(const string &init);
86};
87
106
107#endif
Logger.h - allowing logs with more control.
registry methods over MedRegistry Object
TimeWindowMode
Definition MedEnums.h:25
@ All_
"all" - takes all not testing for anything
ConflictMode
Definition MedEnums.h:12
An Abstract class that can be serialized and written/read from file.
Parameters for lableing strategy on MedRegistry for given time window.
Definition LabelParams.h:91
int init(map< string, string > &map)
init function
Definition LabelParams.cpp:65
int time_to
time window to - for labeling
Definition LabelParams.h:96
TimeWindowInteraction label_interaction_mode
the label interaction definition
Definition LabelParams.h:93
int time_from
time window from - for labeling
Definition LabelParams.h:95
TimeWindowInteraction censor_interaction_mode
the label interaction definition
Definition LabelParams.h:94
int censor_time_from
time window from - for censor registry
Definition LabelParams.h:98
bool treat_0_class_as_other_classes
used to define the way outcome time is set to 0 class. in case control should be false,...
Definition LabelParams.h:100
int censor_time_to
time window to - for censor registry
Definition LabelParams.h:99
ConflictMode conflict_method
resolving conflicts
Definition LabelParams.h:97
Definition SerializableObject.h:32
A warpper class for initializing rules for time window interaction.
Definition LabelParams.h:14
unordered_map< float, TimeWindowMode[2]> interaction_mode
map from label value to interaction rules
Definition LabelParams.h:22
unordered_map< float, pair< float, float > > intersection_range_condition
intersection rate range with registry condition
Definition LabelParams.h:23
Definition StdDeque.h:58