indiv_outcome.sequence.SequenceIndivBase

class pytrial.tasks.indiv_outcome.sequence.base.SequenceIndivBase(experiment_id='test', mode=None, output_dim=None)[source]
Abstract class for all individual outcome predictions

based on sequential patient data.

Parameters

experiment_id (str, optional (default = 'test')) – The name of current experiment.

eval(mode=False)[source]

Swith the model to the validation mode. Work samely as model.eval() in pytorch.

Parameters

mode (bool, optional (default = False)) – If False, switch to the validation mode.

abstract fit(train_data, valid_data)[source]

Fit function needs to be implemented after subclass.

Parameters
  • train_data (Any) – Training data.

  • valid_data (Any) – Validation data.

abstract load_model(checkpoint)[source]

Load the pretrained model from disk, needs to be implemented after subclass.

Parameters

checkpoint (str) – The path to the checkpoint file.

abstract predict(test_data)[source]

Prediction function needs to be implemented after subclass.

Parameters

test_data (Any) – Testing data.

abstract save_model(output_dir)[source]

Save the model to disk, needs to be implemented after subclass.

Parameters

output_dir (str) – The path to the output directory.

train(mode=True)[source]

Swith the model to the training mode. Work samely as model.train() in pytorch.

Parameters

mode (bool, optional (default = True)) – If True, switch to the training mode.