Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
IterativeFeatureSelector Class Reference

IterativeFeatureSelector - Apply bottom-up or top-down iteration for feature selection. More...

#include <FeatureProcess.h>

Inheritance diagram for IterativeFeatureSelector:
FeatureSelector FeatureProcessor SerializableObject

Public Member Functions

int init (map< string, string > &mapper)
 The parsed fields from init command.
 
virtual void init_defaults ()
 
void init_bootstrap_cohort (MedBootstrapResult &bootstrapper, string &init)
 
void init_bootstrap_params (MedBootstrapResult &bootstrapper, string &init)
 
virtual void copy (FeatureProcessor *processor)
 
void print_report (string &fileName)
 
void retrace (MedFeatures &features, unordered_set< int > &ids, vector< string > &families_order, int start, int end)
 
void retrace (MedFeatures &features, vector< string > &families_order, int start, int end)
 
ADD_SERIALIZATION_FUNCS(processor_type, predictor, predictor_params, predictor_params_vec, nfolds, folds, mode, rates_vec, cohort_params, bootstrap_params, msr_params, work_on_sets, required, ignored, numToSelect, selected, report, do_internal_cv, grouping_mode) private int _learn (MedFeatures &features, unordered_set< int > &ids)
 Find set of selected features.
 
void get_rates_vec ()
 
void read_params_vec ()
 
void get_features_families (MedFeatures &features, map< string, vector< string > > &featureFamilies)
 
void prepare_for_iterations (MedBootstrapResult &bootstrapper, MedFeatures &features, vector< int > &folds, vector< vector< int > > &trainRows, vector< vector< int > > &testRows, vector< vector< float > > &trainLabels, vector< vector< MedSample > > &testSamples, MedFeatures &bootstrapFeatures)
 
void pre_learn (MedFeatures &features, MedBootstrapResult &bootstrapper, map< string, vector< string > > &featureFamilies, vector< int > &orig_folds)
 
void doTop2BottomSelection (MedFeatures &features, map< string, vector< string > > &featureFamilies, MedBootstrapResult &bootstrapper)
 
void doBottom2TopSelection (MedFeatures &features, map< string, vector< string > > &featureFamilies, MedBootstrapResult &bootstrapper)
 
void retraceTop2BottomSelection (MedFeatures &features, map< string, vector< string > > &featureFamilies, MedBootstrapResult &bootstrapper, vector< string > &order, int start, int end)
 
void retraceBottom2TopSelection (MedFeatures &features, map< string, vector< string > > &featureFamilies, MedBootstrapResult &bootstrapper, vector< string > &order, int start, int end)
 
- Public Member Functions inherited from FeatureSelector
virtual int Learn (MedFeatures &features, unordered_set< int > &ids)
 Find set of selected features- Calls _learn function, and may be overrided directly.
 
virtual int _apply (MedFeatures &features, unordered_set< int > &ids)
 Apply selection.
 
virtual int _conditional_apply (MedFeatures &features, unordered_set< int > &ids, unordered_set< string > &out_req_features)
 
bool is_selector ()
 allows testing if this feature processor is a selector
 
bool are_features_affected (unordered_set< string > &out_req_features)
 check if a set of features is affected by the current processor
 
void update_req_features_vec (unordered_set< string > &out_req_features, unordered_set< string > &in_req_features)
 update sets of required as input according to set required as output to processor
 
- Public Member Functions inherited from FeatureProcessor
virtual string select_learn_matrix (const vector< string > &matrix_tags) const
 Will be called before learn to create new version for the matrix if needed - in parallel of existing matrix.
 
virtual void clear ()
 
void init_defaults ()
 
virtual void set_feature_name (const string &feature_name)
 
virtual string get_feature_name ()
 
virtual void get_feature_names (vector< string > &feature_names)
 
int learn (MedFeatures &features)
 PostProcess of MedFeatures - on all ids.
 
int learn (MedFeatures &features, unordered_set< int > &ids)
 
virtual int _apply (MedFeatures &features, unordered_set< int > &ids, bool learning)
 
virtual int _conditional_apply (MedFeatures &features, unordered_set< int > &ids, unordered_set< string > &req_features, bool learning)
 
int apply (MedFeatures &features, bool learning)
 PostProcess of MedFeatures - on all or a subset of the ids calls virtaul function "_apply/_conditional_apply" for the specific implementation.
 
int apply (MedFeatures &features, unordered_set< string > &req_features, bool learning)
 
int apply (MedFeatures &features, unordered_set< int > &ids, bool learning)
 
int apply (MedFeatures &features, unordered_set< int > &ids, unordered_set< string > &req_features, bool learning)
 
int apply (MedFeatures &features)
 
int apply (MedFeatures &features, unordered_set< string > &req_features)
 
int apply (MedFeatures &features, unordered_set< int > &ids)
 
int apply (MedFeatures &features, unordered_set< int > &ids, unordered_set< string > &req_features)
 
virtual int init (void *processor_params)
 
virtual int filter (unordered_set< string > &features)
 Filter according to a subset of features.
 
string resolve_feature_name (MedFeatures &features, string substr)
 Utility : get corresponding name in MedFeatures.
 
void * new_polymorphic (string derived_class_name)
 for polymorphic classes that want to be able to serialize/deserialize a pointer * to the derived class given its type one needs to implement this function to return a new to the derived class given its type (as in my_type)
 
size_t get_processor_size ()
 
size_t processor_serialize (unsigned char *blob)
 
virtual void dprint (const string &pref, int rp_flag)
 
- Public Member Functions inherited from SerializableObject
virtual int version () const
 Relevant for serializations.
 
virtual string my_class_name () const
 For better handling of serializations it is highly recommended that each SerializableObject inheriting class will implement the next method.
 
virtual void serialized_fields_name (vector< string > &field_names) const
 The names of the serialized fields.
 
virtual void pre_serialization ()
 
virtual void post_deserialization ()
 
virtual size_t get_size ()
 Gets bytes sizes for serializations.
 
virtual size_t serialize (unsigned char *blob)
 Serialiazing object to blob memory. return number ob bytes wrote to memory.
 
virtual size_t deserialize (unsigned char *blob)
 Deserialiazing blob to object. returns number of bytes read.
 
size_t serialize_vec (vector< unsigned char > &blob)
 
size_t deserialize_vec (vector< unsigned char > &blob)
 
virtual size_t serialize (vector< unsigned char > &blob)
 
virtual size_t deserialize (vector< unsigned char > &blob)
 
virtual int read_from_file (const string &fname)
 read and deserialize model
 
virtual int write_to_file (const string &fname)
 serialize model and write to file
 
virtual int read_from_file_unsafe (const string &fname)
 read and deserialize model without checking version number - unsafe read
 
int init_from_string (string init_string)
 Init from string.
 
int init_params_from_file (string init_file)
 
int init_param_from_file (string file_str, string &param)
 
int update_from_string (const string &init_string)
 
virtual int update (map< string, string > &map)
 Virtual to update object from parsed fields.
 
virtual string object_json () const
 

Data Fields

string predictor
 the predictor type - same as in the json file: qrf,lightgbm...
 
string predictor_params
 the predictor parameters
 
string predictor_params_file
 File with nFeatures-dependent predictor parameters.
 
int nfolds = 5
 number of folds for cross-validation
 
bool do_internal_cv = true
 use nfolds and create internal splits (if false, uses original samples' splits
 
vector< int > folds
 if given, perform only subset of the possible 'nfolds' folds in cross-validation
 
string mode = "top2bottom"
 'top2bottom' or 'bottom2top'
 
string rates = "50:1,100:2,500:5,5000:10"
 instruction on rate of selection - comma separated pairs : #-bound:step
 
string cohort_params
 cohort parameters for bootstrap performance evaluation (type:from,to/type:from,to/....)
 
string bootstrap_params = "sample_per_pid:1"
 parameters for bootstrapping ('/' separaters)
 
string msr_params = "AUC"
 measurements parameters for bootstrap performance evaluation
 
bool work_on_sets = false
 work on sets of features according to signals
 
bool group_to_sigs = false
 If true will group ungroupd_names to signals.
 
unordered_set< string > ungroupd_names = { "Drug","RC","ICD9" }
 features-names (NAME in FTR_####.NAME) not to be grouped even in work_on_sets mode.
 
unordered_set< string > ignored
 features to ignore in selection process
 
bool verbose
 print all feature importance
 
string progress_file_path = ""
 file path to progress file
 
string grouping_mode = "BY_SIGNAL_CATEG"
 get also provide external file with the grouping
 
vector< int > rates_vec
 
vector< string > predictor_params_vec
 
string measurement_name
 
vector< string > report
 
- Data Fields inherited from FeatureSelector
float missing_value = (float)MED_MAT_MISSING_VALUE
 Missing Value.
 
unordered_set< string > required
 Required Features.
 
vector< string > selected
 Selected Features (ordered)
 
int numToSelect = 0
 Target number to select (if 0, ignored)
 
int numToSelectDelta = 0
 Delta around numToSelect. will search to find [numToSelect - numToSelectDelta, numToSelect + numToSelectDelta].
 
- Data Fields inherited from FeatureProcessor
string feature_name = "unset_feature_name"
 Feature name ( + name as appears in MedFeatures) ;.
 
string resolved_feature_name
 
FeatureProcessorTypes processor_type = FTR_PROCESS_LAST
 
int learn_nthreads
 
int clean_nthreads
 

Additional Inherited Members

- Static Public Member Functions inherited from FeatureProcessor
static FeatureProcessormake_processor (string processor_name)
 
static FeatureProcessormake_processor (FeatureProcessorTypes type)
 
static FeatureProcessormake_processor (string processor_name, string params)
 
static FeatureProcessormake_processor (FeatureProcessorTypes type, string params)
 

Detailed Description

IterativeFeatureSelector - Apply bottom-up or top-down iteration for feature selection.

To Use this selector specify "iterative_selector" in the fp_type

Member Function Documentation

◆ _learn()

int IterativeFeatureSelector::_learn ( MedFeatures features,
unordered_set< int > &  ids 
)
virtual

Find set of selected features.

Reimplemented from FeatureSelector.

◆ copy()

virtual void IterativeFeatureSelector::copy ( FeatureProcessor processor)
inlinevirtual

Reimplemented from FeatureProcessor.

◆ init()

int IterativeFeatureSelector::init ( map< string, string > &  mapper)
virtual

The parsed fields from init command.

if (field == "missing_value") missing_value = med_stof(entry.second);
else if (field == "predictor") predictor = entry.second;
else if (field == "predictor_params") predictor_params = entry.second;
else if (field == "importance_params") importance_params = entry.second;
else if (field == "minStat") minStat = med_stof(entry.second);
else if (field == "verbose") verbose = med_stoi(entry.second) > 0;
else if (field == "numToSelect") numToSelect = med_stoi(entry.second);
else if (field != "names" && field != "fp_type" && field != "tag")
MLOG("Unknown parameter \'%s\' for ImportanceFeatureSelector\n", field.c_str());
#define MLOG(fmt,...)
MLOG() - use LOCAL_SECTION and LOCAL_LEVEL.
Definition Logger.h:145
int numToSelect
Target number to select (if 0, ignored)
Definition FeatureProcess.h:551
float missing_value
Missing Value.
Definition FeatureProcess.h:542
string predictor_params
the predictor parameters
Definition FeatureProcess.h:882
string predictor
the predictor type - same as in the json file: qrf,lightgbm...
Definition FeatureProcess.h:881
bool verbose
print all feature importance
Definition FeatureProcess.h:896

[ImportanceFeatureSelector::init]

[ImportanceFeatureSelector::init]

Reimplemented from FeatureProcessor.


The documentation for this class was generated from the following files: