Medial Code Documentation
|
Bootstrap wrapper for Medila Infrastructure objects, simplify the parameters and the input, output process. More...
#include <MedBootstrap.h>
Public Member Functions | |
void | parse_cohort_line (const string &line) |
parsing specific line. | |
void | get_cohort_from_arg (const string &single_cohort) |
A function which reads a single cohort definition from the command line and parses it. | |
void | parse_cohort_file (const string &cohorts_path) |
a function which reads cohorts file and stores it in filter_cohort. | |
MedBootstrap () | |
defualt Ctor. | |
int | init (map< string, string > &map) |
Initialization string with format "parameter_name=value;..." each paramter_name is same as the class name field. | |
void | clean_feature_name_prefix (map< string, vector< float > > &features) |
cleans the initiale "FTR_" from the feature names in MedFeatures created by the infra pipeline | |
void | prepare_bootstrap (const MedFeatures &features, vector< float > &preds, vector< float > &y, vector< int > &pids, map< string, vector< float > > &final_additional_info, vector< int > &preds_order, unordered_map< int, vector< int > > *splits_inds=NULL) |
prepares the required vectors for bootstrap from MedFeatures &features | |
void | prepare_bootstrap (MedSamples &samples, map< string, vector< float > > &additional_info, vector< float > &preds, vector< float > &y, vector< int > &pids, vector< int > &preds_order, unordered_map< int, vector< int > > *splits_inds=NULL) |
prepares the required vectors for bootstrap from samples, additional_info | |
map< string, map< string, float > > | bootstrap (const MedFeatures &features, map< int, map< string, map< string, float > > > *results_per_split=NULL, with_registry_args *registry_args=NULL) |
Will run the bootstraping process on all cohorts and measurements. | |
map< string, map< string, float > > | bootstrap (MedSamples &samples, map< string, vector< float > > &additional_info, map< int, map< string, map< string, float > > > *results_per_split=NULL, with_registry_args *registry_args=NULL) |
Will run the bootstraping process on all cohorts and measurements. | |
map< string, map< string, float > > | bootstrap (MedSamples &samples, const string &rep_path, map< int, map< string, map< string, float > > > *results_per_split=NULL, with_registry_args *registry_args=NULL) |
Will run the bootstraping process on all cohorts and measurements. | |
map< string, map< string, float > > | bootstrap (MedSamples &samples, MedPidRepository &rep, map< int, map< string, map< string, float > > > *results_per_split=NULL, with_registry_args *registry_args=NULL) |
Will run the bootstraping process on all cohorts and measurements. | |
void | apply_censor (const unordered_map< int, int > &pid_censor_dates, MedSamples &samples) |
censors samples from samples based on time_range provided in pid_censor_dates. | |
void | apply_censor (const unordered_map< int, int > &pid_censor_dates, MedFeatures &features) |
censors samples from features based on time_range provided in pid_censor_dates. | |
void | apply_censor (const vector< int > &pids, const vector< int > &censor_dates, MedFeatures &features) |
censors samples from features based on time_range provided in pids,censor_dates. | |
void | apply_censor (const vector< int > &pids, const vector< int > &censor_dates, MedSamples &samples) |
censors samples from samples based on time_range provided in pids,censor_dates. | |
void | change_sample_autosim (MedSamples &samples, int min_time, int max_time, MedSamples &new_samples) |
changing the samples to be auto-simulations - taking max score in the time window for each pid | |
void | change_sample_autosim (MedFeatures &features, int min_time, int max_time, MedFeatures &new_features) |
changing the samples to be auto-simulations - taking max score in the time window for each pid | |
MeasurmentFunctionType | measurement_function_name_to_type (const string &measurement_function_name) |
convert measurement function name to type | |
![]() | |
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 * | new_polymorphic (string derived_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) | |
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 ¶m) |
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 |
Static Public Member Functions | |
static void | filter_bootstrap_cohort (MedFeatures &features, const string &bt_cohort) |
commit bootstrap cohort filter on a given matrix | |
static void | filter_bootstrap_cohort (MedPidRepository &bt_repository, MedModel &bt_filters, MedSamples &curr_samples, const string &bt_cohort) |
commit bootstrap cohort filter on a given samples | |
static void | filter_bootstrap_cohort (const string &rep, const string &bt_json, MedSamples &curr_samples, const string &bt_cohort) |
commit bootstrap cohort filter on a given samples | |
Data Fields | |
ROC_Params | roc_Params |
Controling the roc parameters: sensitivity, specificity... | |
Regression_Params | regression_params |
params for regerssion | |
Multiclass_Params | multiclass_params |
Controling the multi class parameters: top n... | |
map< string, vector< Filter_Param > > | filter_cohort |
the cohorts definitions. name to parameters range to intersect | |
map< string, FilterCohortFunc > | additional_cohorts |
not Serializable! additional cohorts given by function | |
float | sample_ratio |
the sample ratio of the patients out of all patients in each bootstrap | |
int | sample_per_pid |
how many samples to take for each patients. 0 - means no sampling take all sample for patient | |
bool | sample_patient_label |
if true will treat patient+label as the "id" for the sampling | |
int | sample_seed |
if 0 will use random_device | |
int | loopCnt |
the bootstrap count | |
bool | is_binary_outcome |
only used for validating bootstrap input | |
bool | use_time_control_as_case |
if True will use time window condition for controls same as cases. | |
bool | simTimeWindow |
Time window simulation (in cohorts with Time-Window filtering) - instead of censoring cases out of time range , treat them as controls. | |
float | censor_time_factor |
bool | sort_preds_in_multicategory |
size_t | num_categories |
number of categories | |
vector< pair< MeasurementFunctions, Measurement_Params * > > | measurements_with_params |
not Serializable! the measurements with the params | |
Static Public Attributes | |
static unordered_map< string, MeasurmentFunctionType > | measurement_function_name_map |
Bootstrap wrapper for Medila Infrastructure objects, simplify the parameters and the input, output process.
for more control and lower level interface please refer to bootstrap.h
MedBootstrap::MedBootstrap | ( | ) |
defualt Ctor.
look for ROC_Params defaults. cohorts consists of 1 cohort called "All" with not filtering
void MedBootstrap::apply_censor | ( | const unordered_map< int, int > & | pid_censor_dates, |
MedFeatures & | features | ||
) |
censors samples from features based on time_range provided in pid_censor_dates.
the format is map from pid to max_date the after that date the sample is filtered.
void MedBootstrap::apply_censor | ( | const unordered_map< int, int > & | pid_censor_dates, |
MedSamples & | samples | ||
) |
censors samples from samples based on time_range provided in pid_censor_dates.
the format is map from pid to max_date the after that date the sample is filtered.
void MedBootstrap::apply_censor | ( | const vector< int > & | pids, |
const vector< int > & | censor_dates, | ||
MedFeatures & | features | ||
) |
censors samples from features based on time_range provided in pids,censor_dates.
pids and censor_dates are same sizes. for each pid and the coresponding date in censor_dates, filtering pid's samples after that date.
void MedBootstrap::apply_censor | ( | const vector< int > & | pids, |
const vector< int > & | censor_dates, | ||
MedSamples & | samples | ||
) |
censors samples from samples based on time_range provided in pids,censor_dates.
pids and censor_dates are same sizes. for each pid and the coresponding date in censor_dates, filtering pid's samples after that date.
map< string, map< string, float > > MedBootstrap::bootstrap | ( | const MedFeatures & | features, |
map< int, map< string, map< string, float > > > * | results_per_split = NULL , |
||
with_registry_args * | registry_args = NULL |
||
) |
Will run the bootstraping process on all cohorts and measurements.
MedFeatures need to contains also the information for the cohorts defenitions. for example: if there is Age:40-80, MedFeatures should contain Age Feature
map< string, map< string, float > > MedBootstrap::bootstrap | ( | MedSamples & | samples, |
const string & | rep_path, | ||
map< int, map< string, map< string, float > > > * | results_per_split = NULL , |
||
with_registry_args * | registry_args = NULL |
||
) |
Will run the bootstraping process on all cohorts and measurements.
the input is samples, and rep_path. The rep_path is path to the repository which adds Age,Gender signals for creating the cohorts definitions. it's simple overload for convention
map< string, map< string, float > > MedBootstrap::bootstrap | ( | MedSamples & | samples, |
map< string, vector< float > > & | additional_info, | ||
map< int, map< string, map< string, float > > > * | results_per_split = NULL , |
||
with_registry_args * | registry_args = NULL |
||
) |
Will run the bootstraping process on all cohorts and measurements.
the input is samples, additional_info. additional_info is provided for filtering and creating the cohorts. for example - Age:40-80 and Males
map< string, map< string, float > > MedBootstrap::bootstrap | ( | MedSamples & | samples, |
MedPidRepository & | rep, | ||
map< int, map< string, map< string, float > > > * | results_per_split = NULL , |
||
with_registry_args * | registry_args = NULL |
||
) |
Will run the bootstraping process on all cohorts and measurements.
the input is samples, and rep. The rep is the repository which adds Age,Gender signals for creating the cohorts definitions. it's simple overload for convention
void MedBootstrap::change_sample_autosim | ( | MedFeatures & | features, |
int | min_time, | ||
int | max_time, | ||
MedFeatures & | new_features | ||
) |
changing the samples to be auto-simulations - taking max score in the time window for each pid
void MedBootstrap::change_sample_autosim | ( | MedSamples & | samples, |
int | min_time, | ||
int | max_time, | ||
MedSamples & | new_samples | ||
) |
changing the samples to be auto-simulations - taking max score in the time window for each pid
|
static |
commit bootstrap cohort filter on a given samples
rep | - repository path |
bt_json | - the json model to generate matrix for filtering the bootstrap cohort Automatically Age,Gender are added |
curr_samples | - the samples to filter |
bt_cohort | - a single line cohort (no support for MULTI) without the cohort name. only the filter definition. no tabs in the string. |
|
static |
commit bootstrap cohort filter on a given matrix
features | - matrix |
bt_cohort | - a single line cohort (no support for MULTI) without the cohort name. only the filter definition. no tabs in the string. |
|
static |
commit bootstrap cohort filter on a given samples
bt_repository | - repository that was initialized for applying the bt_filters model to generate matrix |
bt_filters | - the model to generate matrix for filtering the bootstrap cohort |
curr_samples | - the samples to filter |
bt_cohort | - a single line cohort (no support for MULTI) without the cohort name. only the filter definition. no tabs in the string. |
void MedBootstrap::get_cohort_from_arg | ( | const string & | single_cohort | ) |
A function which reads a single cohort definition from the command line and parses it.
Please refer to parse_cohort_file for full spec.
|
virtual |
Initialization string with format "parameter_name=value;..." each paramter_name is same as the class name field.
filter_cohort is path to file roc_Params is the init string for ROC_PARAMS
Reimplemented from SerializableObject.
MeasurmentFunctionType MedBootstrap::measurement_function_name_to_type | ( | const string & | measurement_function_name | ) |
convert measurement function name to type
void MedBootstrap::parse_cohort_file | ( | const string & | cohorts_path | ) |
a function which reads cohorts file and stores it in filter_cohort.
The file format may be in 2 options:
void MedBootstrap::parse_cohort_line | ( | const string & | line | ) |
parsing specific line.
please refer to parse_cohort_file for full spec
void MedBootstrap::prepare_bootstrap | ( | const MedFeatures & | features, |
vector< float > & | preds, | ||
vector< float > & | y, | ||
vector< int > & | pids, | ||
map< string, vector< float > > & | final_additional_info, | ||
vector< int > & | preds_order, | ||
unordered_map< int, vector< int > > * | splits_inds = NULL |
||
) |
prepares the required vectors for bootstrap from MedFeatures &features
void MedBootstrap::prepare_bootstrap | ( | MedSamples & | samples, |
map< string, vector< float > > & | additional_info, | ||
vector< float > & | preds, | ||
vector< float > & | y, | ||
vector< int > & | pids, | ||
vector< int > & | preds_order, | ||
unordered_map< int, vector< int > > * | splits_inds = NULL |
||
) |
prepares the required vectors for bootstrap from samples, additional_info
|
static |