PLSA.vision package

Submodules

PLSA.vision.calibration module

Module for visualizing curve of calibration test

The function of this Module is served for visualizing curve of calibration test.

PLSA.vision.calibration.plot_DCalibration(y_true, pred_proba, n_bins=10, summary=True, xlabel='Predicted value', ylabel='Observed average', title='Hosmer-Lemeshow Test', save_fig_as='')

Plot calibration curve.

Parameters:
  • y_true (numpy.array) – True label.
  • y_prob (numpy.array) – Predicted label.
  • n_bins (int) – Number of groups.
Returns:

Summary table of result.

Plot figure of calibration curve.

Return type:

None

Examples

>>> plot_DCalibration(test_y, test_pred, n_bins=5)

PLSA.vision.lib module

Module for visualizing common curve

The function of this Module is served for visualizing common curve.

PLSA.vision.lib.plot_cphCoef(dfx, coef_col='coef', se_col='se(coef)', c_col='p', name_col=None, ci=0.95, error_bar='hr', xlabel='Name of variable', ylabel='', title="Variable's coefficient of CPH model", figsize=(8, 6), save_fig_as='')

Visualize variables’ coefficient in lifelines.CPH model

Parameters:
  • dfx (pandas.DataFrame) – Object equals to cph.summary.
  • coef_col (str) – Name of column indicating coefficient.
  • se_col (str) – Name of column indicating standard error.
  • c_col (str) – Name of column indicating color.
  • name_col (str) – Name of x-axis’s column.
  • ci (float) – Confidence interval, default 0.95.
  • error_bar (str) – Type of error bars, ‘hr’ for asymmetrical error bars, ‘log-hr’ for symmetrical error bars.
Returns:

Plot figure of coefficient.

Return type:

None

Examples

>>> plot_cphCoef(cph.summary, 'coef', 'se(coef)', 'p')

PLSA.vision.roc module

Module for visualizing ROC curve

The function of this Module is served for visualizing ROC curve.

PLSA.vision.roc.plot_DROC(y_true, y_pred, x_true=None, x_pred=None, **kws)

Plot ROC curve for giving data.

Parameters:
  • y_true – True label in train data.
  • y_pred – Predict label in train data.
  • x_true – True label in test data.
  • x_pred – Predict label in test data.
  • **kws – Arguments for plotting.
Returns:

Plot figure of AUC

Return type:

None

Examples

>>> plot_DROC(train_y, train_pred, test_y, test_pred)
PLSA.vision.roc.plot_ROC(data_roc, xlabel='1 - Specificity', ylabel='Sensitivity', title='Model Performance', save_fig_as='')

Plot one ROC curve in one figure.

Parameters:
  • data_roc (dict) – Python dict contains values about ‘FP’, ‘TP’, ‘AUC’.
  • save_fig_as (str) – Name of file for saving in local.

Examples

>>> plot_ROC(data_roc)
PLSA.vision.roc.plot_SROC(data_train, data_test, pred_col, duration_col, event_col, pt=None, labels=['Train', 'Validation'], **kws)

Plot Time-Dependent survival ROC curve for giving data.

Parameters:
  • data_train (pandas.DataFrame) – Train DataFrame included columns of Event, Duration, Pred.
  • data_train – Test DataFrame included columns of Event, Duration, Pred.
  • pred_col (str) – Name of column indicating predicted value.
  • duration_col (str) – Name of column indicating time.
  • event_col (str) – Name of column indicating event.
  • pt (int) – Predicte time.
  • **kws – Arguments for plotting.
Returns:

Plot figure of AUC

Return type:

None

Examples

>>> plot_SROC(data_train, data_test, "X", "T", "E", pt=5)
PLSA.vision.roc.plot_twoROC(train_roc, test_roc, labels=['Train', 'Validation'], xlabel='1 - Specificity', ylabel='Sensitivity', title='Model Performance', save_fig_as='')

Plot two ROC curve in one figure.

Parameters:
  • train_roc (dict) – Python dict contains values about ‘FP’, ‘TP’, ‘AUC’.
  • test_roc (dict) – Python dict contains values about ‘FP’, ‘TP’, ‘AUC’.
  • save_fig_as (str) – Name of file for saving in local.

Examples

>>> plot_twoROC(train_roc, test_roc)

PLSA.vision.survrisk module

Module for visualizing a kind of curves in survival analyze

The function of this Module is served for visualizing a kind of curves in survival analyze.

PLSA.vision.survrisk.plot_riskGroups(data_groups, event_col, duration_col, labels=[], plot_join=False, xlabel='Survival time (Month)', ylabel='Survival Rate', title='Survival function of Risk groups', save_fig_as='')

Plot survival curve for different risk groups.

Parameters:
  • data_groups (list(pandas.DataFame)) – list of DataFame[[‘E’, ‘T’]], risk groups from lowest to highest.
  • event_col (str) – column in DataFame indicating events.
  • duration_col (atr) – column in DataFame indicating durations.
  • labels (list(str), default []) – One text label for one group.
  • plot_join (bool, default False) – Is plotting for two adjacent risk group, default False.
  • save_fig_as (str) – Name of file for saving in local.
Returns:

Plot figure of each risk-groups.

Return type:

None

Examples

>>> plot_riskGroups(df_list, "E", "T", labels=["Low", "Mid", "High"])
PLSA.vision.survrisk.plot_rsRisk(data, x_col, y1_col, y2_col, labels=['Line-1', 'Line2'], xlabel='Risk Score', ylabel='Rate of Risk', title='Curve of risk score and rate of risk', save_fig_as='')

Plot continues function between risk score and rate of risk.

Parameters:
  • data (pandas.DataFame) – Full survival data.
  • x_col (str) – Name of column indicating risk score.
  • y1_col (str) – Name of column indicating rate of risk at t1.
  • y2_col (str) – Name of column indicating rate of risk at t2.
  • **kws – Setting of plot.
Returns:

Plot figure of RS-rate.

Return type:

None

Examples

>>> plot_rsRisk(data, 'RS', 'pred_idfs_y5', 'pred_idfs_y10', labels=['5 Year.', '10 Year.'])
PLSA.vision.survrisk.plot_timeAUC(x, y_train, y_test, labels=['Train', 'Validation'], xlabel='Time', ylabel='AUC', title='Model Performance', save_fig_as='')

Plot line chart about time and AUC.

Parameters:
  • x (list) – Time.
  • y_train (list) – AUC of train.
  • y_test (list) – AUC of test.
  • **kws – Setting of plot.
Returns:

Plot figure of auc with time.

Return type:

None

Examples

>>> plot_timeAUC([1, 3, 5, 10], train_list, test_list)

Module contents