pyhealth.models.sequence package¶
Submodules¶
pyhealth.models.sequence.dipole module¶
- class pyhealth.models.sequence.dipole.ConcatenationAttention(hidden_size, attention_dim=16, device=None)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class pyhealth.models.sequence.dipole.Dipole(expmodel_id='test.new', n_epoch=100, n_batchsize=5, learn_ratio=0.0001, weight_decay=0.0001, n_epoch_saved=1, attention_type='location_based', attention_dim=8, embed_size=16, hidden_size=8, output_size=8, bias=True, dropout=0.5, batch_first=True, loss_name='L1LossSigmoid', target_repl=False, target_repl_coef=0.0, aggregate='sum', optimizer_name='adam', use_gpu=False, gpu_ids='0')[source]¶
Bases:
BaseControler
- fit(train_data, valid_data, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
- assign_task_type: str (default = None)
predifine task type to model mapping <feature, label> current support [‘binary’,’multiclass’,’multilabel’,’regression’]
Returns
self : object
Fitted estimator.
- class pyhealth.models.sequence.dipole.GeneralAttention(hidden_size, device)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class pyhealth.models.sequence.dipole.LocationAttention(hidden_size, device)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class pyhealth.models.sequence.dipole.callPredictor(input_size=None, embed_size=16, hidden_size=8, output_size=10, bias=True, dropout=0.5, batch_first=True, label_size=1, attention_type='location_based', attention_dim=8, device=None)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Parameters
‘M’: shape (batchsize, n_timestep) ‘cur_M’: shape (batchsize, n_timestep) ‘T’: shape (batchsize, n_timestep)
}
Return
all_output, shape (batchsize, n_timestep, n_labels)
predict output of each time step
cur_output, shape (batchsize, n_labels)
predict output of last time step
pyhealth.models.sequence.embedgru module¶
- class pyhealth.models.sequence.embedgru.EmbedGRU(expmodel_id='test.new', n_epoch=100, n_batchsize=5, learn_ratio=0.0001, weight_decay=0.0001, n_epoch_saved=1, embed_size=16, layer_hidden_sizes=[10, 20, 15], bias=True, dropout=0.5, bidirectional=True, batch_first=True, loss_name='L1LossSigmoid', target_repl=False, target_repl_coef=0.0, aggregate='sum', optimizer_name='adam', use_gpu=False, gpu_ids='0')[source]¶
Bases:
BaseControler
- fit(train_data, valid_data, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
- assign_task_type: str (default = None)
predifine task type to model mapping <feature, label> current support [‘binary’,’multiclass’,’multilabel’,’regression’]
Returns
self : object
Fitted estimator.
- class pyhealth.models.sequence.embedgru.callPredictor(input_size=None, embed_size=16, layer_hidden_sizes=[10, 20, 15], num_layers=3, bias=True, dropout=0.5, bidirectional=True, batch_first=True, label_size=1)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Parameters
‘M’: shape (batchsize, n_timestep) ‘cur_M’: shape (batchsize, n_timestep) ‘T’: shape (batchsize, n_timestep)
}
Return
all_output, shape (batchsize, n_timestep, n_labels)
predict output of each time step
cur_output, shape (batchsize, n_labels)
predict output of last time step
pyhealth.models.sequence.gru module¶
- class pyhealth.models.sequence.gru.GRU(expmodel_id='test.new', n_epoch=100, n_batchsize=5, learn_ratio=0.0001, weight_decay=0.0001, n_epoch_saved=1, layer_hidden_sizes=[10, 20, 15], bias=True, dropout=0.5, bidirectional=True, batch_first=True, loss_name='L1LossSigmoid', target_repl=False, target_repl_coef=0.0, aggregate='sum', optimizer_name='adam', use_gpu=False, gpu_ids='0')[source]¶
Bases:
BaseControler
- fit(train_data, valid_data, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
- assign_task_type: str (default = None)
predifine task type to model mapping <feature, label> current support [‘binary’,’multiclass’,’multilabel’,’regression’]
Returns
self : object
Fitted estimator.
- class pyhealth.models.sequence.gru.callPredictor(input_size=None, layer_hidden_sizes=[10, 20, 15], num_layers=3, bias=True, dropout=0.5, bidirectional=True, batch_first=True, label_size=1)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Parameters
‘M’: shape (batchsize, n_timestep) ‘cur_M’: shape (batchsize, n_timestep) ‘T’: shape (batchsize, n_timestep)
}
Return
all_output, shape (batchsize, n_timestep, n_labels)
predict output of each time step
cur_output, shape (batchsize, n_labels)
predict output of last time step
pyhealth.models.sequence.lstm module¶
- class pyhealth.models.sequence.lstm.LSTM(expmodel_id='test.new', n_epoch=100, n_batchsize=5, learn_ratio=0.0001, weight_decay=0.0001, n_epoch_saved=1, layer_hidden_sizes=[10, 20, 15], bias=True, dropout=0.5, bidirectional=True, batch_first=True, loss_name='L1LossSigmoid', target_repl=False, target_repl_coef=0.0, aggregate='sum', optimizer_name='adam', use_gpu=False, gpu_ids='0')[source]¶
Bases:
BaseControler
- fit(train_data, valid_data, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
- assign_task_type: str (default = None)
predifine task type to model mapping <feature, label> current support [‘binary’,’multiclass’,’multilabel’,’regression’]
Returns
self : object
Fitted estimator.
- class pyhealth.models.sequence.lstm.callPredictor(input_size=None, layer_hidden_sizes=[10, 20, 15], num_layers=3, bias=True, dropout=0.5, bidirectional=True, batch_first=True, label_size=1)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Parameters
‘M’: shape (batchsize, n_timestep) ‘cur_M’: shape (batchsize, n_timestep) ‘T’: shape (batchsize, n_timestep)
}
Return
all_output, shape (batchsize, n_timestep, n_labels)
predict output of each time step
cur_output, shape (batchsize, n_labels)
predict output of last time step
pyhealth.models.sequence.raim module¶
- class pyhealth.models.sequence.raim.RAIM(expmodel_id='test.new', n_epoch=100, n_batchsize=5, learn_ratio=0.0001, weight_decay=0.0001, n_epoch_saved=1, window_size=3, hidden_size=8, output_size=8, bias=True, dropout=0.5, batch_first=True, loss_name='L1LossSigmoid', target_repl=False, target_repl_coef=0.0, aggregate='sum', optimizer_name='adam', use_gpu=False, gpu_ids='0')[source]¶
Bases:
BaseControler
Recurrent Attentive and Intensive Model(RAIM) for jointly analyzing continuous monitoring data and discrete clinical events
- fit(train_data, valid_data, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
- assign_task_type: str (default = None)
predifine task type to model mapping <feature, label> current support [‘binary’,’multiclass’,’multilabel’,’regression’]
Returns
self : object
Fitted estimator.
- class pyhealth.models.sequence.raim.RaimExtract(input_size, window_size, hidden_size)[source]¶
Bases:
Module
- forward(input_data, h_t_1)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class pyhealth.models.sequence.raim.callPredictor(input_size=None, window_size=3, hidden_size=16, output_size=8, batch_first=True, dropout=0.5, label_size=1, device=None)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Parameters
‘M’: shape (batchsize, n_timestep) ‘cur_M’: shape (batchsize, n_timestep) ‘T’: shape (batchsize, n_timestep)
}
Return
all_output, shape (batchsize, n_timestep, n_labels)
predict output of each time step
cur_output, shape (batchsize, n_labels)
predict output of last time step
pyhealth.models.sequence.retain module¶
- class pyhealth.models.sequence.retain.Retain(expmodel_id='test.new', n_epoch=100, n_batchsize=5, learn_ratio=0.0001, weight_decay=0.0001, n_epoch_saved=1, embed_size=16, hidden_size=8, bias=True, dropout=0.5, batch_first=True, loss_name='L1LossSigmoid', target_repl=False, target_repl_coef=0.0, aggregate='sum', optimizer_name='adam', use_gpu=False, gpu_ids='0')[source]¶
Bases:
BaseControler
- fit(train_data, valid_data, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
- assign_task_type: str (default = None)
predifine task type to model mapping <feature, label> current support [‘binary’,’multiclass’,’multilabel’,’regression’]
Returns
self : object
Fitted estimator.
- class pyhealth.models.sequence.retain.RetainAttention(embed_size, hidden_size, device)[source]¶
Bases:
Module
- forward(data_alpha, data_beta, data_embed, data_mask)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class pyhealth.models.sequence.retain.callPredictor(input_size=None, embed_size=16, hidden_size=8, bias=True, dropout=0.5, batch_first=True, label_size=1, device=None)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Parameters
‘M’: shape (batchsize, n_timestep) ‘cur_M’: shape (batchsize, n_timestep) ‘T’: shape (batchsize, n_timestep)
}
Return
all_output, shape (batchsize, n_timestep, n_labels)
predict output of each time step
cur_output, shape (batchsize, n_labels)
predict output of last time step
pyhealth.models.sequence.rf module¶
- class pyhealth.models.sequence.rf.RandomForest(expmodel_id='test.new', n_estimators=100, criterion='gini', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features='auto', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None, ccp_alpha=0.0, max_samples=None)[source]¶
Bases:
object
- fit(data_dict, X=None, y=None, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
Returns
self : object
Fitted estimator.
pyhealth.models.sequence.stagenet module¶
StageNet model. Adapted and modified from
https://github.com/v1xerunt/StageNet
- class pyhealth.models.sequence.stagenet.StageNet(expmodel_id='test.new', n_epoch=100, n_batchsize=5, learn_ratio=0.0001, weight_decay=0.0001, n_epoch_saved=1, hidden_size=384, conv_size=10, levels=3, dropconnect=0.3, dropout=0.3, dropres=0.3, batch_first=True, loss_name='L1LossSigmoid', target_repl=False, target_repl_coef=0.0, aggregate='sum', optimizer_name='adam', use_gpu=False, gpu_ids='0')[source]¶
Bases:
BaseControler
StageNet: Stage-Aware Neural Networks for Health Risk Prediction.
- fit(train_data, valid_data, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
- assign_task_type: str (default = None)
predifine task type to model mapping <feature, label> current support [‘binary’,’multiclass’,’multilabel’,’regression’]
Returns
self : object
Fitted estimator.
- class pyhealth.models.sequence.stagenet.callPredictor(input_dim=None, hidden_dim=384, conv_size=10, levels=3, dropconnect=0.3, dropout=0.3, dropres=0.3, label_size=None, device=None)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Parameters
‘M’: shape (batchsize, n_timestep) ‘cur_M’: shape (batchsize, n_timestep) ‘T’: shape (batchsize, n_timestep)
}
Return
all_output, shape (batchsize, n_timestep, n_labels)
predict output of each time step
cur_output, shape (batchsize, n_labels)
predict output of last time step
pyhealth.models.sequence.tlstm module¶
- class pyhealth.models.sequence.tlstm.callPredictor(input_size=None, hidden_size=16, output_size=8, batch_first=True, dropout=0.5, label_size=1, device=None)[source]¶
Bases:
Module
- forward(input_data)[source]¶
Parameters
‘M’: shape (batchsize, n_timestep) ‘cur_M’: shape (batchsize, n_timestep) ‘T’: shape (batchsize, n_timestep)
}
Return
all_output, shape (batchsize, n_timestep, n_labels)
predict output of each time step
cur_output, shape (batchsize, n_labels)
predict output of last time step
- class pyhealth.models.sequence.tlstm.tLSTM(expmodel_id='test.new', n_epoch=100, n_batchsize=5, learn_ratio=0.0001, weight_decay=0.0001, n_epoch_saved=1, hidden_size=8, output_size=8, bias=True, dropout=0.5, batch_first=True, loss_name='L1LossSigmoid', target_repl=False, target_repl_coef=0.0, aggregate='sum', optimizer_name='adam', use_gpu=False, gpu_ids='0')[source]¶
Bases:
BaseControler
- Time-Aware LSTM (T-LSTM), A kind of time-aware RNN neural network;
Used to handle irregular time intervals in longitudinal patient records.
- fit(train_data, valid_data, assign_task_type=None)[source]¶
Parameters
- train_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input train samples dict.
- valid_data{
‘x’:list[episode_file_path], ‘y’:list[label], ‘l’:list[seq_len], ‘feat_n’: n of feature space, ‘label_n’: n of label space }
The input valid samples dict.
- assign_task_type: str (default = None)
predifine task type to model mapping <feature, label> current support [‘binary’,’multiclass’,’multilabel’,’regression’]
Returns
self : object
Fitted estimator.
- class pyhealth.models.sequence.tlstm.tLSTMCell(input_size, hidden_size)[source]¶
Bases:
Module
- forward(data_x, data_t, h_t_1, c_t_1)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.