Medial Code Documentation
Loading...
Searching...
No Matches
AlgoMarkerInternal.h
1#pragma once
2
3#include <string>
4#include <InfraMed/InfraMed/InfraMed.h>
5#include <InfraMed/InfraMed/MedPidRepository.h>
8#include <MedStat/MedStat/MedBootstrap.h>
9#include "InputTesters.h"
10#include "AlgoMarkerErr.h"
11#include <cmath>
12
13#define LOCAL_SECTION LOG_APP
14#define LOCAL_LEVEL LOG_DEF_LEVEL
15
17public:
19 string signal_name = "";
20 int max_count = 1;
22 int time_channel = 0;
24 int val_channel = 0;
25 vector<string> sets;
26
27 // Not to be initialized:
28 vector<char> lut;
29 int init(map<string, string>& mapper) {
30 for (auto &it : mapper)
31 {
32 if (it.first == "contributer_group_name")
33 contributer_group_name = it.second;
34 else if (it.first == "signal_name")
35 signal_name = it.second;
36 else if (it.first == "max_count")
37 max_count = med_stoi(it.second);
38 else if (it.first == "max_time_window")
39 max_time_window = med_stoi(it.second);
40 else if (it.first == "time_channel")
41 time_channel = med_stoi(it.second);
42 else if (it.first == "val_channel")
43 val_channel = med_stoi(it.second);
44 else if (it.first == "time_unit")
45 time_unit = med_time_converter.string_to_type(it.second);
46 else if (it.first == "sets")
47 boost::split(sets, it.second, boost::is_any_of(","));
48 else
49 HMTHROW_AND_ERR("Error in Explainer_record_config::init - unknown parameter \"%s\"\n",
50 it.first.c_str());
51 }
52 if (contributer_group_name.empty())
53 HMTHROW_AND_ERR("Error in Explainer_record_config::init - contributer_group_name must be given\n");
54 if (signal_name.empty())
55 HMTHROW_AND_ERR("Error in Explainer_record_config::init - signal_name must be given\n");
56 return 0;
57 }
58
59 ADD_CLASS_NAME(Explainer_record_config)
61};
62
64public:
65 map<string, Explainer_record_config> records;
66
67 void read_cfg_file(const string &file);
68
69 int init(map<string, string>& mapper) {
70 for (auto &it : mapper)
71 {
72 if (it.first == "records")
73 read_cfg_file(it.second);
74 else
75 HMTHROW_AND_ERR("Error in Explainer_description_config::init - unknown parameter \"%s\"\n",
76 it.first.c_str());
77 }
78 return 0;
79 }
80
81 ADD_CLASS_NAME(Explainer_description_config)
83};
84
86public:
87 float max_threshold = 0;
88 int num_groups = 3;
89 bool use_perc = false;
91 unordered_set<string> ignore_groups_list;
95 float threshold_abs = -1;
97 vector<string> static_features_info;
98
99 // to be init before:
100 string base_dir = "";
101
102 int init(map<string, string>& mapper) {
103 for (auto &it : mapper)
104 {
105 if (it.first == "max_threshold")
106 max_threshold = med_stof(it.second);
107 else if (it.first == "num_groups")
108 num_groups = med_stoi(it.second);
109 else if (it.first == "total_max_reasons")
110 total_max_reasons = med_stoi(it.second);
111 else if (it.first == "total_max_pos_reasons")
112 total_max_pos_reasons = med_stoi(it.second);
113 else if (it.first == "total_max_neg_reasons")
114 total_max_neg_reasons = med_stoi(it.second);
115 else if (it.first == "threshold_abs")
116 threshold_abs = med_stof(it.second);
117 else if (it.first == "threshold_percentage")
118 threshold_percentage = med_stof(it.second);
119 else if (it.first == "use_perc")
120 use_perc = med_stoi(it.second) > 0;
121 else if (it.first == "static_features_info")
122 boost::split(static_features_info, it.second, boost::is_any_of(","));
123 else if (it.first == "ignore_groups_list") {
124 vector<string> tokens;
125 boost::split(tokens, it.second, boost::is_any_of(","));
126 ignore_groups_list.insert(tokens.begin(), tokens.end());
127 }
128 else if (it.first == "cfg") {
129 if (it.second != "" && it.second[0] != '/' && it.second[0] != '\\' && !base_dir.empty())
130 cfg.read_cfg_file(base_dir + path_sep() + it.second);
131 else
132 cfg.read_cfg_file(it.second);
133 }
134 else
135 HMTHROW_AND_ERR("Error in Explainer_parameters::init - unknown parameter \"%s\"\n",
136 it.first.c_str());
137 }
138 if (max_threshold < 0)
139 HMTHROW_AND_ERR("Error in Explainer_parameters::init - max_threshold should be positive\n");
140
141 return 0;
142 }
143
144 ADD_CLASS_NAME(Explainer_parameters)
146};
147
148//===============================================================================
149// MedAlgoMarkerInternal - a mid-way API class : hiding all details of
150// implementation that are specific to the base classes (MedRepository, MedSamples, MedModel)
151// that we use today.
152// All functions assume c style to allow for easy export to C#/.NET
153//===============================================================================
155private:
156 // we force working ONLY using the API
157
159 MedModel model;
160 MedSamples samples;
161 unordered_map<int, unordered_map<string, unordered_set<string>>> unknown_codes;
162 Explainer_parameters explainer_params;
163 //InputSanityTester ist;
164 map<string, map<string, float>> mbr;
165 string default_threshold = "";
166
167 string name;
168 string model_fname;
169 string rep_fname;
170 vector<int> pids;
171 int model_end_stage = MED_MDL_END;
172 bool model_init_done = false;
173 bool model_rep_done = false;
174public:
175
176 MedPidRepository & get_rep() { return rep; }
177 //========================================================
178 // Initializations
179 //========================================================
180
181 // init name
182 void set_name(const char *_name) { name = string(_name); }
183 void set_model_end_stage(int _model_end_stage) { model_end_stage = _model_end_stage; };
184
185 // init repository config
186 int init_rep_config(const char *config_fname) {
187 rep.switch_to_in_mem_mode();
188 if (rep.MedRepository::init(string(config_fname)) < 0) return -1;
189
190 return 0;
191 }
192
193 // set time_unit env for repositories and models
194 int set_time_unit_env(int time_unit) {
195 global_default_time_unit = time_unit;
196 return 0;
197 }
198
199 // init pids
200 void set_pids(int *_pids, int npids) { pids.clear(); pids.assign(_pids, _pids + npids); }
201
202 // init rep , model , samples
203 int init_rep_with_file_data(const char *_rep_fname) {
204 rep.clear();
205 rep_fname = string(_rep_fname);
206 vector<string> sigs = {};
207 return (rep.read_all(rep_fname, pids, sigs));
208 }
209
210 // init model
211 int init_model_from_file(const char *_model_fname) { model.clear(); model.verbosity = 0; return (model.read_from_file(string(_model_fname))); }
212 int model_check_required_signals() {
213 int ret = 0;
214 vector<string> req_sigs;
215 model.get_required_signal_names(req_sigs);
216 for (const auto& s : req_sigs)
217 if (0 == rep.sigs.Name2Sid.count(s)) {
218 ret = -1;
219 fprintf(stderr, "ERROR: AM model requires signal '%s' but signal does not exist in AM repository .signals file\n", s.c_str());
220 }
221 return ret;
222 }
223
224 // init model for apply
225 int init_model_for_apply() {
226 global_logger.log(LOG_APP, LOG_DEF_LEVEL, "Init MedModel for Apply\n");
227 model_init_done = true;
228 return model.init_model_for_apply(rep, MED_MDL_APPLY_FTR_GENERATORS, MED_MDL_END);
229 }
230
231 void fit_model_to_rep() {
232 model.fit_for_repository(rep);
233 }
234
235 int init_model_for_rep() {
236 //global_logger.log(LOG_APP, LOG_DEF_LEVEL, "Init MedModel for Rep\n");
237 if (!model_rep_done) {
238 model_rep_done = true;
239 return model.init_model_for_apply(rep, MED_MDL_APPLY_FTR_GENERATORS, MED_MDL_APPLY_FTR_PROCESSORS);
240 }
241 return 0;
242 }
243
244 unordered_map<string, unordered_set<string>> *get_unknown_codes(int pid) {
245 return &unknown_codes[pid];
246 }
247 // init samples
248 int init_samples(int *pids, int *times, int n_samples) { clear_samples(); int rc = insert_samples(pids, times, n_samples); samples.normalize(); return rc; }
249 int init_samples(int pid, int time) { return init_samples(&pid, &time, 1); } // single prediction point initiation
250
251 // init input_tester
252 //int init_input_tester(const char *_fname) { return ist.read_config(string(_fname)); }
253
254 void add_json_dict(json &js) { rep.dict.add_json(js); }
255
256 bool model_initiated() { return model_init_done; }
257
258 //========================================================
259 // Loading data to rep
260 //========================================================
261
262 // init loading : actions that must be taken BEFORE any loading starts
263 int data_load_init() { unknown_codes.clear(); rep.switch_to_in_mem_mode(); return 0; }
264
265 // load n_elems for a pid,sig
266 int data_load_pid_sig(int pid, const char *sig_name, int *times, float *vals, int n_elems) {
267 int sid = rep.sigs.Name2Sid[string(sig_name)];
268 if (sid < 0) return -1; // no such signal
269 int n_times = n_elems * rep.sigs.Sid2Info[sid].n_time_channels, n_vals = n_elems * rep.sigs.Sid2Info[sid].n_val_channels;
270 if (times == NULL) n_times = 0;
271 if (vals == NULL) n_vals = 0;
272 return rep.in_mem_rep.insertData(pid, sid, times, vals, n_times, n_vals);
273 }
274
275 // load pid,sig with vectors of times and vals
276 int data_load_pid_sig(int pid, const char *sig_name, int *times, int n_times, float *vals, int n_vals,
277 map<pair<int, int>, pair<int, vector<char>>> *data = NULL) {
278 int sid = rep.sigs.Name2Sid[string(sig_name)];
279 if (sid < 0) return -1; // no such signal
280 if (data == NULL)
281 data = &rep.in_mem_rep.data;
282 return rep.in_mem_rep.insertData_to_buffer(pid, sid, times, vals, n_times, n_vals, rep.sigs, *data);
283 }
284
285 // load a single element for a pid,sig
286 int data_load_pid_sig(int pid, const char *sig_name, int *times, float *vals) { return data_load_pid_sig(pid, sig_name, times, vals, 1); }
287
288 // end loading : actions that must be taken AFTER all loading was done, and BEFORE we calculate the predictions
289 int data_load_end() { return rep.in_mem_rep.sortData(); }
290
291 void get_rep_signals(unordered_set<string> &sigs)
292 {
293 for (auto &sig : rep.sigs.signals_names)
294 {
295 sigs.insert(sig);
296 }
297 }
298 // returns the available signals
299
300 //========================================================
301 // Samples
302 //========================================================
303
304 // clear prediction points BEFORE a new set of predictions is done using the same instance
305 void clear_samples() { samples.clear(); }
306
307 // insert prediction points
308 int insert_samples(int *pids, int *times, int n_samples) {
309 for (int i = 0; i < n_samples; i++)
310 samples.insertRec(pids[i], times[i]);
311 return 0;
312 }
313
314 int insert_sample(int pid, int time) { return insert_samples(&pid, &time, 1); }
315
316 //MedSample *get_sample(int idx) { if (idx>=0 && idx<samples.get_size()) return & }
317
318 // normalize samples must be called after finishing inserting all samples.
319 int normalize_samples() { samples.normalize(); return 0; }
320
321 MedSamples *get_samples_ptr() { return &samples; }
322
323 //========================================================
324 // Calculate predictions
325 //========================================================
326 // note that if (_pids,times) are not sorted, they will be changed and sorted.
327 int get_preds(int *_pids, int *times, float *preds, int n_samples) {
328
329 // init_samples
330 init_samples(_pids, times, n_samples);
331
332 return get_raw_preds(_pids, times, preds);
333 }
334
335 int get_preds(int *_pids, int *times, float *preds, int n_samples,
336 const vector<Effected_Field> &requested_fields, MedPidRepository *_rep=NULL) {
337
338 // init_samples
339 init_samples(_pids, times, n_samples);
340 if (_rep == NULL)
341 _rep = &this->rep;
342 return get_raw_preds(_pids, times, preds, requested_fields, _rep);
343 }
344
345 int get_raw_preds(int *_pids, int *times, float *preds,
346 const vector<Effected_Field> &requested_fields, MedPidRepository *_rep) {
347
348 try {
349
350 try {
351 // run model to calculate predictions
352 if (!samples.idSamples.empty())
353 model.no_init_apply_partial(*_rep, samples, requested_fields);
354 }
355 catch (...) {
356 fprintf(stderr, "Caught an exception in no_init_apply_partial\n");
357 return -1;
358 }
359
360 // export pids, times and preds to c arrays
361 int j = 0;
362 if (preds != NULL) {
363 for (auto& idSample : samples.idSamples)
364 for (auto& sample : idSample.samples) {
365 _pids[j] = sample.id;
366 times[j] = sample.time;
367 preds[j] = sample.prediction.size() > 0 ? sample.prediction[0] : (float)AM_UNDEFINED_VALUE; // This is Naive - but works for simple predictors giving the Raw score.
368 j++;
369 }
370 }
371
372 return 0;
373 }
374 catch (int &exception_code) {
375 fprintf(stderr, "Caught an exception code: %d\n", exception_code);
376 return -1; // exception_code;
377 }
378 catch (...) {
379 fprintf(stderr, "Caught Something...\n");
380 return -1;
381 }
382 }
383
384
385 int get_raw_preds(int *_pids, int *times, float *preds) {
386
387 try {
388
389 try {
390 // run model to calculate predictions
391 if (!samples.idSamples.empty())
392 if (model.no_init_apply(rep, samples, (MedModelStage)0, (MedModelStage)model_end_stage) < 0) {
393 fprintf(stderr, "ERROR: MedAlgoMarkerInternal::get_preds FAILED.");
394 return -1;
395 }
396 }
397 catch (...) {
398 fprintf(stderr, "Caught an exception in no_init_apply\n");
399 return -1;
400 }
401
402 // export pids, times and preds to c arrays
403 int j = 0;
404 if (preds != NULL) {
405 for (auto& idSample : samples.idSamples)
406 for (auto& sample : idSample.samples) {
407 _pids[j] = sample.id;
408 times[j] = sample.time;
409 preds[j] = sample.prediction.size() > 0 ? sample.prediction[0] : (float)AM_UNDEFINED_VALUE; // This is Naive - but works for simple predictors giving the Raw score.
410 j++;
411 }
412 }
413
414 return 0;
415 }
416 catch (int &exception_code) {
417 fprintf(stderr, "Caught an exception code: %d\n", exception_code);
418 return -1; // exception_code;
419 }
420 catch (...) {
421 fprintf(stderr, "Caught Something...\n");
422 return -1;
423 }
424 }
425
426 int get_preds(MedSamples &_samples, float *preds) {
427
428 samples = _samples;
429
430 // run model to calculate predictions
431 if (model.no_init_apply(rep, samples, (MedModelStage)0, (MedModelStage)model_end_stage) < 0) {
432 fprintf(stderr, "ERROR: MedAlgoMarkerInternal::get_preds FAILED.");
433 return -1;
434 }
435
436 // export pids, times and preds to c arrays
437 int j = 0;
438 for (auto& idSample : samples.idSamples)
439 for (auto& sample : idSample.samples) {
440 preds[j++] = sample.prediction[0]; // This is Naive - but works for simple predictors giving the Raw score.
441 }
442 return 0;
443 }
444
445 int get_pred(int *pid, int *time, float *pred) { return get_preds(pid, time, pred, 1); }
446
447
448 //========================================================
449 // Clearing - freeing mem
450 //========================================================
451 void clear() { unknown_codes.clear(); pids.clear(); model.clear(); samples.clear(); rep.in_mem_rep.clear(); rep.clear(); }
452
453 // clear_data() : leave model up, leave repository config up, but get rid of data and samples
454 void clear_data() {
455 samples.clear(); rep.in_mem_rep.clear(); unknown_codes.clear();
456 }
457
458
459 //========================================================
460 // a few more needed APIs
461 //========================================================
462 const char *get_name() { return name.c_str(); }
463
464 void write_features_mat(const string &feat_mat) { model.write_feature_matrix(feat_mat); }
465 void add_features_mat(const string &feat_mat) { model.write_feature_matrix(feat_mat, false, true); }
466
467 void get_signal_structure(string &sig, int &n_time_channels, int &n_val_channels, int* &is_categ)
468 {
469 int sid = this->rep.sigs.sid(sig);
470 if (sid <= 0) {
471 n_time_channels = 0;
472 n_val_channels = 0;
473 }
474 else {
475 n_time_channels = this->rep.sigs.Sid2Info[sid].n_time_channels;
476 n_val_channels = this->rep.sigs.Sid2Info[sid].n_val_channels;
477 is_categ = &(this->rep.sigs.Sid2Info[sid].is_categorical_per_val_channel[0]);
478 }
479 }
480
481 void model_apply_verbose(bool flag) {
482 if ((model.verbosity > 0) ^ flag) {
483 model.verbosity = int(flag);
484
485 string full_log_format = "$timestamp\t$level\t$section\t%s";
486 global_logger.init_format(LOG_APP, full_log_format);
487 global_logger.init_format(LOG_DEF, full_log_format);
488 global_logger.init_format(LOG_MED_MODEL, full_log_format);
489 global_logger.init_format(LOG_MEDALGO, full_log_format);
490 MLOG("Activated logging, Version Info:\n%s\n", medial::get_git_version().c_str());
491 }
492 }
493
494 string model_version_info() const {
495 return model.version_info;
496 }
497
498 void get_model_signals_info(vector<string> &sigs,
499 unordered_map<string, vector<string>> &res_categ) const {
500 model.get_required_signal_names(sigs);
501 model.get_required_signal_categories(res_categ);
502 }
503
504 void get_explainer_params(Explainer_parameters &out) const {
505 out = explainer_params;
506 }
507
508 void get_explainer_output_options(vector<string> &opts) {
509 vector<const PostProcessor *> flat;
510 for (const PostProcessor *pp : model.post_processors) {
511 if (pp->processor_type == PostProcessorTypes::FTR_POSTPROCESS_MULTI)
512 {
513 const MultiPostProcessor *multi = static_cast<const MultiPostProcessor *>(pp);
514 for (const PostProcessor *m_pp : multi->post_processors)
515 flat.push_back(m_pp);
516 }
517 else
518 flat.push_back(pp);
519 }
520
521 for (const PostProcessor *pp : flat)
522 {
523 const ModelExplainer *explainer_m = dynamic_cast<const ModelExplainer *>(pp);
524 if (explainer_m != NULL) {
525 for (const string &grp : explainer_m->processing.groupNames)
526 opts.push_back(grp);
527 break;
528 }
529 }
530 }
531
532 void set_explainer_params(const string &params, const string &base_dir) {
533 explainer_params.base_dir = base_dir;
534 explainer_params.init_from_string(params);
535 }
536
537 void set_threshold_leaflet(const string &init_string, const string &base_dir) {
538 map<string, string> params;
539 if (MedSerialize::init_map_from_string(init_string, params) < 0)
540 MTHROW_AND_ERR("Error Init from String %s\n", init_string.c_str());
541 string bt_file_path = "";
542 map<string, string> rename_cohorts;
543 for (const auto &it : params)
544 {
545 if (it.first == "bootstrap_file_path")
546 bt_file_path = it.second;
547 else if (it.first == "rename_cohorts") {
548 vector<string> tokens;
549 boost::split(tokens, it.second, boost::is_any_of("#"));
550 for (const string &tk : tokens)
551 {
552 vector<string> src_target;
553 boost::split(src_target, tk, boost::is_any_of("|"));
554 if (src_target.size() != 2)
555 MTHROW_AND_ERR("Error expecting 2 tokens, recieved \"%s\"\n", tk.c_str());
556 mes_trim(src_target[1]);
557 mes_trim(src_target[1]);
558 rename_cohorts[src_target[0]] = src_target[1];
559 }
560 }
561 else if (it.first == "default_threshold") {
562 default_threshold = it.second;
563 mes_trim(default_threshold);
564 }
565 else
566 MTHROW_AND_ERR("Error unknown param %s\n", it.first.c_str());
567 }
568 if (bt_file_path.empty())
569 MTHROW_AND_ERR("Error must provide bootstrap_file_path in THRESHOLD_LEAFLET\n");
570
571 if (bt_file_path != "" && bt_file_path[0] != '/' && bt_file_path[0] != '\\' && !base_dir.empty())
572 bt_file_path = base_dir + path_sep() + bt_file_path;
573
574 if (default_threshold.empty())
575 MTHROW_AND_ERR("Error - must have default_threshold\n");
576
577 map<string, map<string, float>> mbr_before;
578 read_pivot_bootstrap_results(bt_file_path, mbr_before);
579
580 //commit rename:
581 for (auto &it : mbr_before)
582 {
583 string cohort = it.first;
584 if (rename_cohorts.find(cohort) != rename_cohorts.end())
585 cohort = rename_cohorts[cohort];
586 //Filter to take only "SCORE@" prefix - and SKIP missing values
587 map<string, float> &filt = mbr[cohort];
588 for (const auto &jt : it.second)
589 if (boost::starts_with(jt.first, "SCORE@") && boost::ends_with(jt.first, "_Mean") && jt.second != MED_MAT_MISSING_VALUE)
590 filt[jt.first.substr(6, jt.first.length() - 11)] = jt.second;
591 }
592
593 //Test default is OK:
594 string err_c;
595 fetch_threshold(default_threshold, err_c);
596 if (!err_c.empty()) {
597 vector<string> opts;
598 fetch_all_thresholds(opts);
599 for (const string & s : opts)
600 MLOG("Option: \"%s\"\n", s.c_str());
601 MTHROW_AND_ERR("Error default_threshold is invalid - please select one in format as COHORT$MEASURE_NUMERIC\n");
602 }
603 }
604
605 bool has_threshold_settings() const {
606 return !mbr.empty();
607 }
608
609 string get_default_threshold() const { return default_threshold; }
610
611 void fetch_all_thresholds(vector<string> &opts) const {
612 for (const auto &it : mbr)
613 {
614 for (const auto &jt : it.second)
615 {
616 string res = it.first + "$" + jt.first;
617 opts.push_back(res);
618 }
619 }
620 }
621
622 float fetch_threshold(const string &threshold, string &err_msg) const {
623 vector<string> tokens;
624 err_msg = "";
625 boost::split(tokens, threshold, boost::is_any_of("$"));
626 if (tokens.size() != 2) {
627 err_msg = "(" + to_string(AM_THRESHOLD_ERROR_NON_FATAL) + ")Error flag_threshold should contain $";
628 return MED_MAT_MISSING_VALUE;
629 }
630 mes_trim(tokens[0]);
631 mes_trim(tokens[1]);
632 if (mbr.find(tokens[0]) == mbr.end()) {
633 err_msg = "(" + to_string(AM_THRESHOLD_ERROR_NON_FATAL) + ")Error flag_threshold doesn't contain threshold settings for " + tokens[0];
634 return MED_MAT_MISSING_VALUE;
635 }
636 const map<string, float> &fnd = mbr.at(tokens[0]);
637 //Search numericly:
638 vector<string> meas_tokens;
639 boost::split(meas_tokens, tokens[1], boost::is_any_of("_"));
640 if (meas_tokens.size() != 2) {
641 err_msg = "(" + to_string(AM_THRESHOLD_ERROR_NON_FATAL) + ")Error flag_threshold doesn't should contain _ in the cutoff setting part";
642 return MED_MAT_MISSING_VALUE;
643 }
644 float num_val;
645 try {
646 num_val = stof(meas_tokens[1]);
647 }
648 catch (...) {
649 err_msg = "(" + to_string(AM_THRESHOLD_ERROR_NON_FATAL) + ")Error flag_threshold search cutoff isn't numeric";
650 return MED_MAT_MISSING_VALUE;
651 }
652
653 float res = MED_MAT_MISSING_VALUE;
654 for (const auto &jt : fnd)
655 {
656 string cand = jt.first;
657 vector<string> cand_tokens;
658 boost::split(cand_tokens, cand, boost::is_any_of("_"));
659 if (cand_tokens.size() != 2)
660 continue;
661 if (cand_tokens[0] != meas_tokens[0])
662 continue;
663 //Need to compare numericaly: cand_tokens[1] == meas_tokens[1]
664 float num_val_cmp;
665 try {
666 num_val_cmp = stof(cand_tokens[1]);
667 }
668 catch (...) {
669 continue;
670 }
671 if (abs(num_val_cmp - num_val) <= 1e-6) {
672 res = jt.second;
673 break; //found
674 }
675 }
676
677 if (res == MED_MAT_MISSING_VALUE)
678 err_msg = "(" + to_string(AM_THRESHOLD_ERROR_NON_FATAL) + ")Error flag_threshold doesn't contain threshold for " + tokens[1];
679 return res;
680 }
681};
682
#define LOG_DEF
general default section
Definition Logger.h:36
#define LOG_APP
user apps section
Definition Logger.h:34
#define MLOG(fmt,...)
MLOG() - use LOCAL_SECTION and LOCAL_LEVEL.
Definition Logger.h:145
MedModelStage
MedModel learn/apply stages.
Definition MedModel.h:22
@ MED_MDL_APPLY_FTR_PROCESSORS
Start from apply feature processors (already learned)
Definition MedModel.h:27
@ MED_MDL_APPLY_FTR_GENERATORS
Start from apply feature generators (already learned)
Definition MedModel.h:25
@ MED_MDL_END
All Done.
Definition MedModel.h:33
@ FTR_POSTPROCESS_MULTI
"multi_processor" or "multi" to create MultiPostProcessor
Definition PostProcessor.h:15
#define ADD_SERIALIZATION_FUNCS(...)
Definition SerializableObject.h:122
#define MEDSERIALIZE_SUPPORT(Type)
Definition SerializableObject.h:108
Definition AlgoMarkerInternal.h:63
int init(map< string, string > &mapper)
Virtual to init object from parsed fields.
Definition AlgoMarkerInternal.h:69
Definition AlgoMarkerInternal.h:85
bool use_perc
control if binning on absolute value or on percentage
Definition AlgoMarkerInternal.h:89
Explainer_description_config cfg
file to configure fetching signal to present
Definition AlgoMarkerInternal.h:90
unordered_set< string > ignore_groups_list
name list of groups to alwaya ignore
Definition AlgoMarkerInternal.h:91
int num_groups
control how much binning to present
Definition AlgoMarkerInternal.h:88
int total_max_reasons
if bigger than zero max limit for all reasons
Definition AlgoMarkerInternal.h:92
float threshold_percentage
percentage thershold if bigger than 0
Definition AlgoMarkerInternal.h:96
int init(map< string, string > &mapper)
Virtual to init object from parsed fields.
Definition AlgoMarkerInternal.h:102
float max_threshold
control max threshold
Definition AlgoMarkerInternal.h:87
int total_max_neg_reasons
if bigger than zero max limit for neg reasons
Definition AlgoMarkerInternal.h:94
float threshold_abs
absolute thershold if bigger than 0
Definition AlgoMarkerInternal.h:95
vector< string > static_features_info
config of information to fetch for every patient.
Definition AlgoMarkerInternal.h:97
int total_max_pos_reasons
if bigger than zero max limit for pos reasons
Definition AlgoMarkerInternal.h:93
Definition AlgoMarkerInternal.h:16
int max_count
limit of maximal last values
Definition AlgoMarkerInternal.h:20
int time_channel
time channel to filter
Definition AlgoMarkerInternal.h:22
int init(map< string, string > &mapper)
Virtual to init object from parsed fields.
Definition AlgoMarkerInternal.h:29
string signal_name
name of signal to fetch
Definition AlgoMarkerInternal.h:19
int val_channel
val channel to filter sets
Definition AlgoMarkerInternal.h:24
string contributer_group_name
name of explainer group
Definition AlgoMarkerInternal.h:18
int time_unit
time unit for max_time_window
Definition AlgoMarkerInternal.h:23
int max_time_window
limit on maximal time before prediction
Definition AlgoMarkerInternal.h:21
vector< string > sets
sets to filter categorical signal
Definition AlgoMarkerInternal.h:25
Definition AlgoMarkerInternal.h:154
void init_format(int section, const string &new_format)
sets log format.
Definition Logger.cpp:270
A model = repCleaner + featureGenerator + featureProcessor + MedPredictor.
Definition MedModel.h:56
Definition MedPidRepository.h:87
MedSamples represent a collection of samples per different id The data is conatined in a vector of ...
Definition MedSamples.h:129
static const int Days
days since 1900/01/01
Definition MedTime.h:28
int string_to_type(const string &str)
Convert string to type.
Definition MedTime.cpp:358
An abstract class API for explainer.
Definition ExplainWrapper.h:106
ExplainProcessings processing
processing of results, like groupings, COV
Definition ExplainWrapper.h:115
A wrapper for parallel call to post_processors group.
Definition PostProcessor.h:81
An Abstract PostProcessor class.
Definition PostProcessor.h:39
Definition SerializableObject.h:32
int init_from_string(string init_string)
Init from string.
Definition SerializableObject.cpp:121
string get_git_version()
general print to string woth format
Definition MedUtils.cpp:551