pyhealth.utils package

Submodules

pyhealth.utils.check module

pyhealth.utils.check.check_expdata_dir(expdata_id)[source]
Check whether the exp data folder exist,

If not, will create the folder

Parameters

expdata_idstr, optional (default=’init.test’)

name of current experiment data

pyhealth.utils.check.check_model_dir(expmodel_id)[source]
Check whether the checkouts/results folders of current experiment(exp_id) exist,

If not, will create both folders

Parameters

expmodel_idstr, optional (default=’init.test’)

name of current experiment

pyhealth.utils.check.label_check(y, hat_y=None, assign_task_type=None)[source]

pyhealth.utils.utility module

A set of utility functions to support outlier detection.

pyhealth.utils.utility.check_parameter(param, low=-2147483647, high=2147483647, param_name='', include_left=False, include_right=False)[source]

Check if an input is within the defined range.

Parameters
  • param (int, float) – The input parameter to check.

  • low (int, float) – The lower bound of the range.

  • high (int, float) – The higher bound of the range.

  • param_name (str, optional (default='')) – The name of the parameter.

  • include_left (bool, optional (default=False)) – Whether includes the lower bound (lower bound <=).

  • include_right (bool, optional (default=False)) – Whether includes the higher bound (<= higher bound).

Returns

within_range – Whether the parameter is within the range of (low, high)

Return type

bool or raise errors

pyhealth.utils.utility.make_dirs_if_not_exists(save_dir)[source]
pyhealth.utils.utility.read_csv_to_df(file_loc, header_lower=True, usecols=None, dtype=None, low_memory=True, encoding=None)[source]

Read in csv files with necessary processing

Parameters
  • file_loc

  • header_lower

  • low_memory

pyhealth.utils.utility.read_excel_to_df(file_loc, header_lower=True, usecols=None, dtype=None, low_memory=True, encoding=None)[source]

Read in excel files with necessary processing

Parameters
  • file_loc

  • header_lower

  • low_memory

pyhealth.utils.utility_parallel module

A set of utility functions to support parallel computation.

pyhealth.utils.utility_parallel.partition_estimators(n_estimators, n_jobs)[source]

Private function used to partition estimators between jobs.

pyhealth.utils.utility_parallel.tqdm_joblib(tqdm_object)[source]

Context manager to patch joblib to report into tqdm progress bar given as argument

pyhealth.utils.utility_parallel.unfold_parallel(lists, n_jobs)[source]

Internal function to unfold the results returned from the parallization

Parameters
  • lists (list) – The results from the parallelization operations.

  • n_jobs (optional (default=1)) – The number of jobs to run in parallel for both fit and predict. If -1, then the number of jobs is set to the number of cores.

Returns

result_list – The list of unfolded result.

Return type

list

Module contents