Medial Code Documentation
Loading...
Searching...
No Matches
PostProcessor.h
Go to the documentation of this file.
1
2#ifndef __POST_PROCESSOR_H__
3#define __POST_PROCESSOR_H__
4
5#include <vector>
7#include "MedSamples.h"
8#include "MedModel.h"
9#include "Effected_Field.h"
10
29
30using namespace std;
31
32class MedModel;
33
34
35
40public:
41 PostProcessorTypes processor_type = PostProcessorTypes::FTR_POSTPROCESS_LAST;
42
43 // The following variables are used for enabling model to put aside a subset of the learning
44 // set for post-processor learning. Either use_split (put aside all ids within a given split)
45 // or use_p (put aside a proportion 0 < p < 1 of the ids) can be given. but not both
46 int use_split = -1;
47 float use_p = 0.0;
48
50 virtual void get_input_fields(vector<Effected_Field> &fields) const {};
53 virtual void get_output_fields(vector<Effected_Field> &fields) const {};
54
55 virtual void init_post_processor(MedModel& mdl) {};
56 virtual void Learn(const MedFeatures &matrix);
57 virtual void Apply(MedFeatures &matrix);
58
59 void *new_polymorphic(string dname);
60
61 static PostProcessor *make_processor(const string &processor_name, const string &params = "");
62 static PostProcessor *make_processor(PostProcessorTypes type, const string &params = "");
63
64 static PostProcessor *create_processor(string &params);
65
66 virtual void dprint(const string &pref) const;
67
68 virtual ~PostProcessor() {};
69
70 virtual float get_use_p() { return use_p; }
71 virtual int get_use_split() { return use_split; }
72
73 ADD_CLASS_NAME(PostProcessor)
74 ADD_SERIALIZATION_FUNCS(processor_type)
75};
76PostProcessorTypes post_processor_name_to_type(const string& post_processor);
77
82public:
83 vector<PostProcessor *> post_processors;
84 bool call_parallel_learn = false;
85 bool call_parallel_apply = false;
86
88
89 void Learn(const MedFeatures &matrix);
90 void Apply(MedFeatures &matrix);
91
92 void get_input_fields(vector<Effected_Field> &fields) const;
93 void get_output_fields(vector<Effected_Field> &fields) const;
94
95 void init_post_processor(MedModel& mdl);
96
97 void dprint(const string &pref) const;
98
100
101 float get_use_p();
102 int get_use_split();
103
104 ADD_CLASS_NAME(MultiPostProcessor)
105 ADD_SERIALIZATION_FUNCS(post_processors)
106};
107
110
111#endif
PostProcessorTypes
Definition PostProcessor.h:14
@ FTR_POSTPROCESS_FAIRNESS
"fairness_adjust" to adjust model calibrated predictions according to priors. Creates ProbAdjustPostP...
Definition PostProcessor.h:26
@ FTR_POSTPROCESS_ITERATIVE_SET
"iterative_set" to create IterativeSetExplainer - model agnostic iterative explainer for model....
Definition PostProcessor.h:23
@ FTR_POSTPROCESS_LINEAR
"linear" to create LinearExplainer to explain linear model - importance is score change when putting ...
Definition PostProcessor.h:22
@ FTR_POSTPROCESS_LIME_SHAP
"lime_shap" to create LimeExplainer - model agnostic shapley algorithm with lime on shap values sampl...
Definition PostProcessor.h:20
@ FTR_POSTPROCESS_AGGREGATE_PREDS
"aggregate_preds" to create AggregatePredsPostProcessor - averaging model predictions after resamplin...
Definition PostProcessor.h:24
@ FTR_POSTPROCESS_MULTI
"multi_processor" or "multi" to create MultiPostProcessor
Definition PostProcessor.h:15
@ FTR_POSTPROCESS_SHAPLEY
"shapley" to create ShapleyExplainer - model agnostic shapley explainer for model....
Definition PostProcessor.h:18
@ FTR_POSTPROCESS_KNN_EXPLAIN
"knn" Explainer built on knn principles KNN_Explainer
Definition PostProcessor.h:21
@ FTR_POSTPROCESS_ADJUST
"adjust_probs" to adjust model calibrated predictions according to priors. Creates ProbAdjustPostProc...
Definition PostProcessor.h:25
@ FTR_POSTPROCESS_TREE_SHAP
"tree_shap" to create TreeExplainer to explain tree mode or mimic generic model with trees model
Definition PostProcessor.h:17
@ FTR_POSTPROCESS_MISSING_SHAP
"missing_shap" to create MissingShapExplainer - model agnostic shapley algorithm on trained model to ...
Definition PostProcessor.h:19
@ FTR_POSTPROCESS_CALIBRATOR
"calibrator" to create Calibrator
Definition PostProcessor.h:16
An Abstract class that can be serialized and written/read from file.
#define ADD_SERIALIZATION_FUNCS(...)
Definition SerializableObject.h:122
#define MEDSERIALIZE_SUPPORT(Type)
Definition SerializableObject.h:108
A class for holding features data as a virtual matrix
Definition MedFeatures.h:47
A model = repCleaner + featureGenerator + featureProcessor + MedPredictor.
Definition MedModel.h:56
A wrapper for parallel call to post_processors group.
Definition PostProcessor.h:81
void get_input_fields(vector< Effected_Field > &fields) const
List of fields that are used by this post_processor.
Definition PostProcessor.cpp:119
void get_output_fields(vector< Effected_Field > &fields) const
List of fields that are being effected by this post_processor.
Definition PostProcessor.cpp:128
An Abstract PostProcessor class.
Definition PostProcessor.h:39
virtual void get_output_fields(vector< Effected_Field > &fields) const
List of fields that are being effected by this post_processor.
Definition PostProcessor.h:53
virtual void get_input_fields(vector< Effected_Field > &fields) const
List of fields that are used by this post_processor.
Definition PostProcessor.h:50
void * new_polymorphic(string dname)
for polymorphic classes that want to be able to serialize/deserialize a pointer * to the derived clas...
Definition PostProcessor.cpp:101
Definition SerializableObject.h:32
Definition StdDeque.h:58