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

RangeFeatGenerator : Generate features for a time range with value signal (for example drug) More...

#include <FeatureGenerator.h>

Inheritance diagram for RangeFeatGenerator:
FeatureGenerator SerializableObject

Public Member Functions

void set (string &_signalName, RangeFeatureTypes _type)
 
void set (string &_signalName, RangeFeatureTypes _type, int _time_win_from, int _time_win_to)
 
void set_names ()
 
void get_required_signal_categories (unordered_map< string, vector< string > > &signal_categories_in_use) const
 returns for each used signal it's used categories
 
int init (map< string, string > &mapper)
 The parsed fields from init command.
 
void init_defaults ()
 
RangeFeatureTypes name_to_type (const string &name)
 please reffer to RangeFeatureTypes to understand the options
 
void init_tables (MedDictionarySections &dict)
 
virtual void copy (FeatureGenerator *generator)
 
int _learn (MedPidRepository &rep, const MedSamples &samples, vector< RepProcessor * > processors)
 
int _generate (PidDynamicRec &rec, MedFeatures &features, int index, int num, vector< float * > &_p_data)
 
float get_value (PidDynamicRec &rec, int index, int date)
 
void set_signal_ids (MedSignals &sigs)
 
- Public Member Functions inherited from FeatureGenerator
virtual void prepare (MedFeatures &features, MedPidRepository &rep, MedSamples &samples)
 
virtual void get_p_data (MedFeatures &features, vector< float * > &_p_data)
 
void get_p_data (MedFeatures &features)
 
virtual void clear ()
 
void get_required_signal_names (unordered_set< string > &signalNames)
 
virtual void set_required_signal_ids (MedDictionarySections &dict)
 
void get_required_signal_ids (unordered_set< int > &signalIds)
 
virtual void get_generated_features (unordered_set< string > &names_list)
 
virtual void fit_for_repository (MedPidRepository &rep)
 Prepartion and adjustment for model based on repository.
 
int learn (MedPidRepository &rep, const MedSamples &samples, vector< RepProcessor * > processors)
 
int learn (MedPidRepository &rep, const MedSamples &samples)
 
int _generate (PidDynamicRec &in_rep, MedFeatures &features, int index, int num)
 
int generate (PidDynamicRec &in_rep, MedFeatures &features, int index, int num)
 
int generate (PidDynamicRec &in_rep, MedFeatures &features)
 
int generate (MedPidRepository &rep, int id, MedFeatures &features)
 
int generate (MedPidRepository &rep, int id, MedFeatures &features, int index, int num)
 
virtual int _generate (MedFeatures &features)
 
int generate (MedFeatures &features)
 
virtual int init (void *generator_params)
 
virtual int nfeatures ()
 
virtual int filter_features (unordered_set< string > &validFeatures)
 summary> prints summary of generator job.
 
virtual void make_summary ()
 
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_generator_size ()
 
size_t generator_serialize (unsigned char *blob)
 
virtual void print ()
 
virtual void dprint (const string &pref, int fg_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 signalName
 Signal to consider.
 
int signalId
 
vector< string > sets
 FTR_RANGE_EVER checks if the signal ever was in one of these sets/defs from the respective dict.
 
RangeFeatureTypes type
 Type of comorbidity index to generate.
 
int win_from = 0
 time window for feature: from is the minimal time before prediciton time
 
int win_to = 360000
 time window for feature: to is the maximal time before prediciton time
 
int time_unit_win = MedTime::Undefined
 the time unit in which the windows are given. Default: Undefined
 
int time_unit_sig = MedTime::Undefined
 the time init in which the signal is given. (set correctly from Repository in learn and Generate)
 
int val_channel = 0
 n >= 0 : use val channel n , default : 0.
 
int check_first = 1
 if 1 choose first occurance of check_val otherwise choose last
 
float div_factor = 1.0f
 
vector< char > lut
 dividing by this number in time_covered option
 
int recurrence_delta = 30 * 24 * 60
 maximum time for a subsequent range signal to be considered a recurrence in in window time units
 
int min_range_time = -1
 if different from -1, the minimum length for a range to be considered valid in window time units (else not checked)
 
int N_th = 0
 the index of the N-th range in order to consider in the last_nth_time_len option
 
int zero_missing = 0
 in some cases we may want to get 0 instead of missing values
 
int strict_times = 0
 if on , will ignore cases in which the second time channel is after the prediction time
 
int conditional_channel = -1
 in some cases (currently last_nth_len, and time_covered) we allow doing the calculation only on ranges passing the condition of being included in sets in this channel
 
bool regex_on_sets = false
 if on , regex is applied on .*sets[i].* and aggregated.
 
int first_evidence_time_channel = 1
 sometimes we have a different time channel stating WHEN the range started. We are strict and use the default of last time in range, but sometimes it is not like that and this can allow calculating if we are now IN the range, and how LONG since the start.
 
string timeRangeSignalName = ""
 
int timeRangeSignalId
 
TimeRangeTypes timeRangeType = TIME_RANGE_CURRENT
 
int time_unit_range_sig = MedTime::Undefined
 the time unit in which the range signal is given. (set correctly from Repository in learn and _generate)
 
- Data Fields inherited from FeatureGenerator
FeatureGeneratorTypes generator_type = FTR_GEN_LAST
 Type.
 
vector< string > names
 Feature name.
 
int learn_nthreads = 16
 
int pred_nthreads = 16
 
float missing_val = (float)MED_MAT_MISSING_VALUE
 Missing value.
 
vector< string > tags
 Tags - for defining labels or groups. may be used later for filtering for example.
 
int iGenerateWeights = 0
 Feature/Weights generator.
 
vector< float * > p_data
 
vector< string > req_signals
 
vector< int > req_signal_ids
 
int serial_id
 

Additional Inherited Members

- Static Public Member Functions inherited from FeatureGenerator
static FeatureGeneratormake_generator (string name)
 
static FeatureGeneratormake_generator (string name, string params)
 
static FeatureGeneratormake_generator (FeatureGeneratorTypes type)
 
static FeatureGeneratormake_generator (FeatureGeneratorTypes type, string params)
 
static FeatureGeneratorcreate_generator (string &params)
 

Detailed Description

RangeFeatGenerator : Generate features for a time range with value signal (for example drug)

Member Function Documentation

◆ _generate()

int RangeFeatGenerator::_generate ( PidDynamicRec rec,
MedFeatures features,
int  index,
int  num,
vector< float * > &  _p_data 
)
virtual

Reimplemented from FeatureGenerator.

◆ _learn()

int RangeFeatGenerator::_learn ( MedPidRepository rep,
const MedSamples samples,
vector< RepProcessor * >  processors 
)
inlinevirtual

Reimplemented from FeatureGenerator.

◆ copy()

virtual void RangeFeatGenerator::copy ( FeatureGenerator generator)
inlinevirtual

Reimplemented from FeatureGenerator.

◆ get_required_signal_categories()

void RangeFeatGenerator::get_required_signal_categories ( unordered_map< string, vector< string > > &  signal_categories_in_use) const
virtual

returns for each used signal it's used categories

Reimplemented from FeatureGenerator.

◆ init()

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

The parsed fields from init command.

if (field == "type") { type = name_to_type(entry.second); }
else if (field == "win_from") win_from = med_stoi(entry.second);
else if (field == "win_to") win_to = med_stoi(entry.second);
else if (field == "signalName" || field == "signal") signalName = entry.second;
else if (field == "time_unit" || field == "win_time_unit") time_unit_win = med_time_converter.string_to_type(entry.second);
else if (field == "val_channel") val_channel = med_stoi(entry.second);
else if (field == "sets") boost::split(sets, entry.second, boost::is_any_of(","));
else if (field == "tags") boost::split(tags, entry.second, boost::is_any_of(","));
else if (field == "weights_generator") iGenerateWeights = med_stoi(entry.second);
else if (field == "check_first") check_first = med_stoi(entry.second);
else if (field == "time_range_signal") timeRangeSignalName = entry.second;
else if (field == "time_range_signal_type") timeRangeType = time_range_name_to_type(entry.second);
else if (field == "recurrence_delta") recurrence_delta = med_stoi(entry.second);
else if (field == "min_range_time") min_range_time = med_stoi(entry.second);
else if (field == "div_factor") div_factor = med_stof(entry.second);
else if (field == "Nth" || field == "nth") N_th = med_stoi(entry.second);
else if (field == "zero_missing") zero_missing = med_stoi(entry.second);
else if (field == "strict_times") strict_times = med_stoi(entry.second);
else if (field == "conditional_channel") conditional_channel = med_stoi(entry.second);
else if (field == "first_evidence_time_channel") first_evidence_time_channel = med_stoi(entry.second);
else if (field == "regex_on_sets") regex_on_sets = (bool)med_stoi(entry.second);
else if (field != "fg_type")
MLOG("Unknown parameter \'%s\' for RangeFeatGenerator\n", field.c_str());
TimeRangeTypes time_range_name_to_type(const string &name)
Conversion between time-range type and name.
Definition FeatureGenerator.cpp:2585
#define MLOG(fmt,...)
MLOG() - use LOCAL_SECTION and LOCAL_LEVEL.
Definition Logger.h:145
int iGenerateWeights
Feature/Weights generator.
Definition FeatureGenerator.h:72
vector< string > tags
Tags - for defining labels or groups. may be used later for filtering for example.
Definition FeatureGenerator.h:69
int string_to_type(const string &str)
Convert string to type.
Definition MedTime.cpp:358
bool regex_on_sets
if on , regex is applied on .*sets[i].* and aggregated.
Definition FeatureGenerator.h:691
int time_unit_win
the time unit in which the windows are given. Default: Undefined
Definition FeatureGenerator.h:678
int check_first
if 1 choose first occurance of check_val otherwise choose last
Definition FeatureGenerator.h:681
int win_from
time window for feature: from is the minimal time before prediciton time
Definition FeatureGenerator.h:676
int val_channel
n >= 0 : use val channel n , default : 0.
Definition FeatureGenerator.h:680
int min_range_time
if different from -1, the minimum length for a range to be considered valid in window time units (els...
Definition FeatureGenerator.h:686
int conditional_channel
in some cases (currently last_nth_len, and time_covered) we allow doing the calculation only on range...
Definition FeatureGenerator.h:690
string signalName
Signal to consider.
Definition FeatureGenerator.h:672
RangeFeatureTypes type
Type of comorbidity index to generate.
Definition FeatureGenerator.h:675
int N_th
the index of the N-th range in order to consider in the last_nth_time_len option
Definition FeatureGenerator.h:687
int strict_times
if on , will ignore cases in which the second time channel is after the prediction time
Definition FeatureGenerator.h:689
vector< string > sets
FTR_RANGE_EVER checks if the signal ever was in one of these sets/defs from the respective dict.
Definition FeatureGenerator.h:674
int win_to
time window for feature: to is the maximal time before prediciton time
Definition FeatureGenerator.h:677
int recurrence_delta
maximum time for a subsequent range signal to be considered a recurrence in in window time units
Definition FeatureGenerator.h:685
RangeFeatureTypes name_to_type(const string &name)
please reffer to RangeFeatureTypes to understand the options
Definition FeatureGenerator.cpp:1128
int zero_missing
in some cases we may want to get 0 instead of missing values
Definition FeatureGenerator.h:688
int first_evidence_time_channel
sometimes we have a different time channel stating WHEN the range started. We are strict and use the ...
Definition FeatureGenerator.h:693

[RangeFeatGenerator::init]

[RangeFeatGenerator::init]

Reimplemented from FeatureGenerator.

◆ init_defaults()

void RangeFeatGenerator::init_defaults ( )
virtual

Reimplemented from FeatureGenerator.

◆ init_tables()

void RangeFeatGenerator::init_tables ( MedDictionarySections dict)
virtual

Reimplemented from FeatureGenerator.

◆ set_names()

void RangeFeatGenerator::set_names ( )
virtual

Reimplemented from FeatureGenerator.

◆ set_signal_ids()

void RangeFeatGenerator::set_signal_ids ( MedSignals sigs)
inlinevirtual

Reimplemented from FeatureGenerator.

Field Documentation

◆ lut

vector<char> RangeFeatGenerator::lut

dividing by this number in time_covered option

to be used when generating FTR_RANGE_EVER


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