trial_outcome.LogisticRegression

class pytrial.tasks.trial_outcome.logistic_regression.LogisticRegression(C=1.0, dual=False, solver='lbfgs', max_iter=100)[source]

Implement Logistic Regression model for clinical trial outcome prediction.

Parameters
  • C (float) – Regularization strength for l2 norm; must be a positive float. Like in support vector machines, smaller values specify weaker regularization.

  • dual (bool) – Dual or primal formulation. Dual formulation is only implemented for l2 penalty with liblinear solver. Prefer dual=False when n_samples > n_features.

  • solver ({'newton-cg','lbfgs','liblinear','sag','saga'}) – Algorithm to use in the optimization problem. default=’lbfgs’.

  • max_iter (int (default=100)) – Maximum number of iterations taken for the solvers to converge.

fit(train_data, valid_data)[source]

Train logistic regression model to predict clinical trial outcomes.

Parameters
  • train_data (TrialOutcomeDatasetBase) – Training data, should be a TrialOutcomeDatasetBase object.

  • valid_data (TrialOutcomeDatasetBase) – Validation data, should be a TrialOutcomeDatasetBase object. Ignored for logistic regression model. Keep this parameter for compatibility with other models.

load_model(checkpoint=None)[source]

Load the learned model from the disk.

Parameters

checkpoint (str) – The checkpoint folder to load the learned model. The checkpoint under this folder should be model.ckpt.

predict(test_data)[source]

Make clinical trial outcome predictions.

Parameters

test_data (TrialOutcomeDatasetBase) – Testing data, should be a TrialOutcomeDatasetBase object.

save_model(output_dir=None)[source]

Save the learned logistic regression model to the disk.

Parameters

output_dir (str or None) – The output folder to save the learned model. If set None, will save model to save_model/model.ckpt.