MedPython package¶
MedPython module¶
- class med.Bootstrap(Bootstrap self) Bootstrap[source]¶
Bases:
objectProxy of C++ MPBootstrap class.
- MEDPY_SET_ROC_working_point_TOPN(Bootstrap self, IntVector MEDPY_GET_ROC_working_point_TOPN)[source]¶
- property ROC_max_diff_working_point¶
MEDPY_GET_ROC_max_diff_working_point(Bootstrap self) -> float
- property ROC_score_bins¶
MEDPY_GET_ROC_score_bins(Bootstrap self) -> int
- property ROC_score_min_samples¶
MEDPY_GET_ROC_score_min_samples(Bootstrap self) -> int
- property ROC_score_resolution¶
MEDPY_GET_ROC_score_resolution(Bootstrap self) -> float
- property ROC_use_score_working_points¶
MEDPY_GET_ROC_use_score_working_points(Bootstrap self) -> bool
- property ROC_working_point_FPR¶
MEDPY_GET_ROC_working_point_FPR(Bootstrap self) -> FloatVector
- property ROC_working_point_PR¶
MEDPY_GET_ROC_working_point_PR(Bootstrap self) -> FloatVector
- property ROC_working_point_SENS¶
MEDPY_GET_ROC_working_point_SENS(Bootstrap self) -> FloatVector
- property ROC_working_point_Score¶
MEDPY_GET_ROC_working_point_Score(Bootstrap self) -> FloatVector
- property ROC_working_point_TOPN¶
MEDPY_GET_ROC_working_point_TOPN(Bootstrap self) -> IntVector
- bootstrap_cohort(Bootstrap self, Samples samples, string const & rep_path, string const & json_model, string const & cohorts_path) StringBtResultMap[source]¶
- property nbootstrap¶
MEDPY_GET_nbootstrap(Bootstrap self) -> int
- property sample_per_pid¶
MEDPY_GET_sample_per_pid(Bootstrap self) -> int
- property thisown¶
The membership flag
- class med.CommonLib(CommonLib self) CommonLib[source]¶
Bases:
objectProxy of C++ MPCommonLib class.
- property thisown¶
The membership flag
- class med.Dictionary(Dictionary self, PidRepository rep) Dictionary[source]¶
Bases:
objectProxy of C++ MPDictionary class.
- get_members_to_all_sets(Dictionary self, int section_id, int * members_array) IntVecIntMapAdaptor[source]¶
- property thisown¶
The membership flag
- class med.FeatureAttr(FeatureAttr self) FeatureAttr[source]¶
Bases:
objectProxy of C++ MPFeatureAttr class.
- property denorm_mean¶
MEDPY_GET_denorm_mean(FeatureAttr self) -> float
- property denorm_sdv¶
MEDPY_GET_denorm_sdv(FeatureAttr self) -> float
- property imputed¶
MEDPY_GET_imputed(FeatureAttr self) -> bool
- property normalized¶
MEDPY_GET_normalized(FeatureAttr self) -> bool
- property thisown¶
The membership flag
- class med.Features(Features self) Features[source]¶
- class med.Features(Features self, int _time_unit) Features
- class med.Features(Features self, Features other) Features
Bases:
objectProxy of C++ MPFeatures class.
- MEDPY_GET_samples(Features self) SampleVectorAdaptor[source]¶
- append_samples(Features self, IdSamples in_samples)[source]¶
- append_samples(Features self, Samples in_samples)
- property attributes¶
MEDPY_GET_attributes(Features self) -> StringFeatureAttrMapAdaptor
- property data¶
MEDPY_GET_data(Features self) -> StringVecFloatMapAdaptor
- get_as_matrix(Features self, Mat mat)[source]¶
- get_as_matrix(Features self, Mat mat, StringVector names)
- get_as_matrix(Features self, Mat mat, StringVector names, int * int_in_buf)
- property global_serial_id_cnt¶
MEDPY_GET_global_serial_id_cnt() -> int
- property pid_pos_len¶
MEDPY_GET_pid_pos_len(Features self) -> IntPairIntIntMapAdaptor
- property samples¶
MEDPY_GET_samples(Features self) -> SampleVectorAdaptor
- property tags¶
MEDPY_GET_tags(Features self) -> StringUOSetStringMapAdaptor
- property thisown¶
The membership flag
- property time_unit¶
MEDPY_GET_time_unit(Features self) -> int
- property weights¶
MEDPY_GET_weights(Features self)
- class med.IdSamples(IdSamples self, int _id) IdSamples[source]¶
- class med.IdSamples(IdSamples self) IdSamples
Bases:
objectProxy of C++ MPIdSamples class.
- MEDPY_GET_samples(IdSamples self) SampleVectorAdaptor[source]¶
- property id¶
MEDPY_GET_id(IdSamples self) -> int
- property samples¶
MEDPY_GET_samples(IdSamples self) -> SampleVectorAdaptor
- property split¶
MEDPY_GET_split(IdSamples self) -> int
- property thisown¶
The membership flag
- class med.Logger(Logger self) Logger[source]¶
Bases:
objectProxy of C++ MPLogger class.
- property thisown¶
The membership flag
- class med.Mat(Mat self) Mat[source]¶
- class med.Mat(Mat self, int n_rows, int n_cols) Mat
- class med.Mat(Mat self, float * IN_ARRAY2) Mat
Bases:
objectProxy of C++ MPMat class.
- property avg¶
MEDPY_GET_avg(Mat self)
- property missing_value¶
MEDPY_GET_missing_value(Mat self) -> float
- property ncols¶
MEDPY_GET_ncols(Mat self) -> int
- normalize(Mat self, int norm_type, float * wgts)[source]¶
- normalize(Mat self, int norm_type=Normalize_Cols)
- normalize(Mat self, float * external_avg, float * external_std, int norm_type=1)
- property normalized_flag¶
MEDPY_GET_normalized_flag(Mat self) -> int
- property nrows¶
MEDPY_GET_nrows(Mat self) -> int
- property row_ids¶
MEDPY_GET_row_ids(Mat self)
- property signals¶
MEDPY_GET_signals(Mat self) -> StringVector
- property std¶
MEDPY_GET_std(Mat self)
- property thisown¶
The membership flag
- property transposed_flag¶
MEDPY_GET_transposed_flag(Mat self) -> int
- class med.MedConvert(MedConvert self) MedConvert[source]¶
Bases:
objectProxy of C++ MPMedConvert class.
- property thisown¶
The membership flag
- class med.Model(Model self) Model[source]¶
Bases:
objectProxy of C++ MPModel class.
- add_feature_generators(Model self, string & name, StringVector signals)[source]¶
- add_feature_generators(Model self, string & name, StringVector signals, string init_string)
- add_feature_generators(Model self, string & name, string & signal, string init_string)
- add_feature_processor_to_set(Model self, int i_set, int duplicate, string const & init_string)[source]¶
- add_imputers(Model self)[source]¶
- add_imputers(Model self, string init_string)
- add_imputers(Model self, StringVector features)
- add_imputers(Model self, StringVector features, string init_string)
- add_normalizers(Model self)[source]¶
- add_normalizers(Model self, string init_string)
- add_normalizers(Model self, StringVector features)
- add_normalizers(Model self, StringVector features, string init_string)
- add_process_to_set(Model self, int i_set, int duplicate, string const & init_string)[source]¶
- add_process_to_set(Model self, int i_set, string const & init_string)
- apply(Model self, PidRepository rep, Samples samples) int[source]¶
- apply(Model self, PidRepository rep, Samples samples, int start_stage, int end_stage) int
- calc_feature_contribs_conditional(Model self, Mat mat_x_in, string const & features_cond_string, float features_cond_float, Mat mat_x_out, Mat mat_contribs)[source]¶
- dprint_process(Model self, string const & pref, int rp_flag, int fg_flag, int fp_flag, bool pp_flag, bool predictor_type)[source]¶
- property features¶
MEDPY_GET_features(Model self) -> Features
- generate_all_features(Model self, PidRepository rep, Samples samples, Features features, StringVector req_feature_generators) int[source]¶
- init_from_json_file_with_alterations(Model self, std: :string const & fname, StringVector json_alt) StringVector[source]¶
- learn(Model self, PidRepository rep, Samples samples) int[source]¶
- learn(Model self, PidRepository rep, Samples samples, int start_stage, int end_stage) int
- set_predictor(Model self, Predictor _predictor)[source]¶
- set_predictor(Model self, string name, string init_string)
- property thisown¶
The membership flag
- property verbosity¶
MEDPY_GET_verbosity(Model self) -> int
- class med.ModelStage(ModelStage self) ModelStage[source]¶
Bases:
objectProxy of C++ MPModelStage class.
- property thisown¶
The membership flag
- class med.PidRepository(PidRepository self) PidRepository[source]¶
Bases:
objectProxy of C++ MPPidRepository class.
- dict_prep_sets_lookup_table(int_section_id, list_String set_names) BoolVector[source]¶
returns a look-up-table for given set names
- export_to_numpy(str_signame) SigExporter[source]¶
Returns the signal data represented as a list of numpy arrays, one for each field
- get_lut_from_regex(section_id, regex_s)[source]¶
- get get_lut_from_regex to names -> BoolVector
returns a lut - boolean vector
- get_sig(signame [, translate=True][, pids=None, float32to64=True][,regex_str = None]) Pandas DataFrame[source]¶
translate : If True, will decode categorical fields into a readable representation in Pandas pid : If list is provided, will load only pids from the given list
If ‘All’ is provided, will use all available pids
float32to64 : If True, will convert all float32 columns to float64 free_signal : If True, will free signal memory as soon as it is loaded into export arrays regex_str : string (if string, defualt column is ‘val’) or dictionary between column name (e.g, ‘val’) to regex string to filter regex_filter : string to filter categories paretns this match regex
- Parameters:
sig_name_str (str)
translate (bool)
pids (list[int] | str | None)
float32to64 (bool)
free_signal (bool)
regex_str (str | None)
regex_filter (str)
- Return type:
pd.DataFrame
- load_from_json(json_file_path)[source]¶
Loads patient data into in-mem repository. If patient exists, adds more data
- load_from_json_str(json_string)[source]¶
Loads patient data into in-mem repository. If patient exists, adds more data
- property pids¶
MEDPY_GET_pids(PidRepository self) -> IntVector
- read_all(conf_file_fname[, pids_to_take_array][, list_str_signals_to_take]) int[source]¶
returns -1 if fails reading a repository for a group of pids and signals.Empty group means all of it.read_all(conf_file_fname, [pids_to_take_array], [list_str_signals_to_take]) -> int returns -1 if fails reading a repository for a group of pids and signals.Empty group means all of it.
- read_all_i(PidRepository self, std: :string const & conf_fname, IntVector pids_to_take, IntVector signals_to_take) int[source]¶
- property thisown¶
The membership flag
- class med.Predictor(Predictor self) Predictor[source]¶
- class med.Predictor(Predictor self, string model_type, string params="") Predictor
Bases:
objectProxy of C++ MPPredictor class.
- property features_count¶
MEDPY_GET_features_count(Predictor self) -> int
- static make_predictor(string model_type) Predictor[source]¶
- static make_predictor(string model_type, string params) Predictor
- property model_features¶
MEDPY_GET_model_features(Predictor self) -> StringVector
- property normalize_for_learn¶
MEDPY_GET_normalize_for_learn(Predictor self) -> bool
- property normalize_for_predict¶
MEDPY_GET_normalize_for_predict(Predictor self) -> bool
- property normalize_y_for_learn¶
MEDPY_GET_normalize_y_for_learn(Predictor self) -> bool
- property thisown¶
The membership flag
- property transpose_for_learn¶
MEDPY_GET_transpose_for_learn(Predictor self) -> bool
- property transpose_for_predict¶
MEDPY_GET_transpose_for_predict(Predictor self) -> bool
- class med.PredictorTypes(PredictorTypes self) PredictorTypes[source]¶
Bases:
objectProxy of C++ MPPredictorTypes class.
- property thisown¶
The membership flag
- class med.Sample(Sample self) Sample[source]¶
Bases:
objectProxy of C++ MPSample class.
- property id¶
MEDPY_GET_id(Sample self) -> int
- property outcome¶
MEDPY_GET_outcome(Sample self) -> int
- property outcomeTime¶
MEDPY_GET_outcomeTime(Sample self) -> int
- property prediction¶
MEDPY_GET_prediction(Sample self)
- property split¶
MEDPY_GET_split(Sample self) -> int
- property thisown¶
The membership flag
- property time¶
MEDPY_GET_time(Sample self) -> int
- class med.SampleFilter(SampleFilter self) SampleFilter[source]¶
Bases:
objectProxy of C++ MPSampleFilter class.
- static from_name(string name) SampleFilter[source]¶
- static from_name_params(string name, string params) SampleFilter[source]¶
- static from_type(int type) SampleFilter[source]¶
- static from_type_params(int type, string params) SampleFilter[source]¶
- property thisown¶
The membership flag
- class med.SampleVectorAdaptor(SampleVectorAdaptor self) SampleVectorAdaptor[source]¶
Bases:
objectProxy of C++ MPSampleVectorAdaptor class.
- property thisown¶
The membership flag
- class med.Samples(Samples self) Samples[source]¶
Bases:
objectProxy of C++ MPSamples class.
- export_to_sample_vec(Samples self) SampleVectorAdaptor[source]¶
- property idSamples¶
MEDPY_GET_idSamples(Samples self) -> IdSamplesVectorAdaptor
- import_from_sample_vec(Samples self, SampleVectorAdaptor vec_samples, bool allow_split_inconsistency=False)[source]¶
- insertRec(Samples self, int pid, int time, float outcome, int outcomeTime)[source]¶
- insertRec(Samples self, int pid, int time, float outcome, int outcomeTime, float pred)
- insertRec(Samples self, int pid, int time)
- nSplits() int[source]¶
Return number of splits, also check mismatches between idSample and internal MedSamples and set idSamples.split if missing
- property thisown¶
The membership flag
- property time_unit¶
MEDPY_GET_time_unit(Samples self) -> int
- class med.Sig(Sig self, Sig other) Sig[source]¶
Bases:
objectProxy of C++ MPSig class.
- property thisown¶
The membership flag
- class med.Split(Split self) Split[source]¶
Bases:
objectProxy of C++ MPSplit class.
- property nsplits¶
MEDPY_GET_nsplits(Split self) -> int
- property pid2split¶
MEDPY_GET_pid2split(Split self) -> IntIntMapAdaptor
- property thisown¶
The membership flag