PLSA.qcal package

Submodules

PLSA.qcal.func module

Module for quick calling

The function of this Module is served for quick calling functions, and functions of other modules will be called by it.

PLSA.qcal.func.div_three_groups(data, pred_col, duration_col, event_col, cutoffs=None, methods='youden', pt=None, **kws)

Divide data into three groups using methods and summarize result.

Parameters:
  • data (pandas.DataFame) – Full survival data.
  • pred_col (str) – Name of column to reference for dividing groups.
  • duration_col (str) – Name of column indicating time.
  • event_col (str) – Name of column indicating event.
  • cutoffs (default None or tuple) – Given cutoffs for risk groups. If cutoffs is not None, then methods will not be called.
  • methods (str) – Methods for selecting cutoffs, default “youden”.
  • pt (int) – Predicted time.
Returns:

Print summary of result and plot KM-curve of each groups.

Return type:

None

Examples

>>> # Youden index to give cutoffs
>>> div_three_groups(data, "X", "T", "E")
>>> # Give cutoffs explicitly
>>> div_three_groups(data, "X", "T", "E", cutoffs=(20, 50))
PLSA.qcal.func.surv_calibration(data, duration_col, event_col, pred_proba, pt=None, n_bins=10, xlabel='Predicted Risk Probability', ylabel='Observed Risk Probability', title='Model Performance', save_fig_as='')

Evaluate calibration of predicted survival probability at time pt.

Parameters:
  • data (pandas.DataFame) – Full survival data.
  • duration_col (str) – Name of column indicating time.
  • event_col (str) – Name of column indicating event.
  • pred_proba (np.array) – Predicted survival probability at time pt.
  • pt (int) – Predicted time.
Returns:

Print summary of result and plot curve of calibration.

Return type:

None

Examples

>>> surv_calibration(data, "T", "E", surv_function[10], pt=10)
PLSA.qcal.func.surv_coxph(data_train, x_cols, duration_col, event_col, data_test=None, pt=None, show_extra=True)

Integrate functions that include modeling using Cox Regression and evaluating

Parameters:
  • data_train (pandas.DataFame) – Full survival data for train.
  • x_cols (list of str) – Name of column indicating variables.
  • duration_col (str) – Name of column indicating time.
  • event_col (str) – Name of column indicating event.
  • data_test (pandas.DataFame) – Full survival data for test, default None.
  • pt (float) – Predicted time for AUC.
Returns:

Object of cox model in lifelines.CoxPHFitter.

Return type:

object

Examples

>>> surv_coxph(train_data, ['x1', 'x2'], 'T', 'E', test_data, pt=5*12)
PLSA.qcal.func.surv_time_auc(data_train, data_test, pred_col, duration_col, event_col, pt=[], labels=['Train', 'Validation'], **kws)

Plot curve of auc at some predicted time.

Parameters:
  • data_train (pandas.DataFame) – Full survival data for train.
  • data_test (pandas.DataFame) – Full survival data for test.
  • pred_col (str) – Name of column indicating target value.
  • duration_col (str) – Name of column indicating time.
  • event_col (str) – Name of column indicating event.
  • pt (list(int)) – Predicted time indicating list of watching.
Returns:

Print summary of result and plot curve of auc with time.

Return type:

None

Examples

>>> surv_time_auc(train_data, test_data, 'X', 'T', 'E', pt=[1, 3, 5, 10])

Module contents