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#include <array>
10
11using namespace std;
16private:
17 bool has_default_mode;
18 bool has_default_range;
19 TimeWindowMode default_modes[2];
20 pair<float, float> default_intersection_range;
21
22public:
23 unordered_map<float, std::array<TimeWindowMode,2>> interaction_mode;
24 unordered_map<float, pair<float, float>> intersection_range_condition;
25
27 has_default_mode = false;
28 has_default_range = false;
29 default_modes[0] = TimeWindowMode::All_;
30 default_modes[1] = TimeWindowMode::All_;
31 default_intersection_range.first = 0; default_intersection_range.second = 0;
32 }
33
34 TimeWindowMode *operator[] (float x) {
35 if (interaction_mode.find(x) != interaction_mode.end() || !has_default_mode)
36 return interaction_mode[x].data();
37 //has_default_mode is true and not exist
38 return default_modes;
39 }
40
41 bool find(const float x) const {
42 return has_default_mode || interaction_mode.find(x) != interaction_mode.end();
43 }
44
45 const TimeWindowMode *at(float x) const {
46 if (interaction_mode.find(x) != interaction_mode.end() || !has_default_mode)
47 return interaction_mode.at(x).data();
48 return default_modes;
49 }
50
51 void set_default(TimeWindowMode defaults_m[2]) {
52 if (has_default_mode)
53 HMTHROW_AND_ERR("Error - TimeWindowInteraction has already default\n");
54 has_default_mode = true;
55 default_modes[0] = defaults_m[0];
56 default_modes[1] = defaults_m[1];
57 }
58
59 void set_default_range(float min_range, float max_range) {
60 default_intersection_range.first = min_range;
61 default_intersection_range.second = max_range;
62 has_default_range = true;
63 }
64
65 bool get_inresection_range_cond(float x, float &min_range, float &max_range) const {
67 min_range = intersection_range_condition.at(x).first;
68 max_range = intersection_range_condition.at(x).second;
69 return true;
70 }
71 else if (has_default_range) {
72 min_range = default_intersection_range.first;
73 max_range = default_intersection_range.second;
74 return true;
75 }
76 return false;
77 }
78
79 void reset_for_init() {
80 has_default_mode = false;
81 has_default_range = false;
82 interaction_mode.clear();
84 }
85
86 void init_from_string(const string &init);
87};
88
107
108#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:92
int init(map< string, string > &map)
init function
Definition LabelParams.cpp:65
int time_to
time window to - for labeling
Definition LabelParams.h:97
TimeWindowInteraction label_interaction_mode
the label interaction definition
Definition LabelParams.h:94
int time_from
time window from - for labeling
Definition LabelParams.h:96
TimeWindowInteraction censor_interaction_mode
the label interaction definition
Definition LabelParams.h:95
int censor_time_from
time window from - for censor registry
Definition LabelParams.h:99
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:101
int censor_time_to
time window to - for censor registry
Definition LabelParams.h:100
ConflictMode conflict_method
resolving conflicts
Definition LabelParams.h:98
Definition SerializableObject.h:31
A warpper class for initializing rules for time window interaction.
Definition LabelParams.h:15
unordered_map< float, std::array< TimeWindowMode, 2 > > interaction_mode
map from label value to interaction rules
Definition LabelParams.h:23
unordered_map< float, pair< float, float > > intersection_range_condition
intersection rate range with registry condition
Definition LabelParams.h:24
Definition BFloat16.h:88