This module contains a PyTorch implementation of the Deep Recurrent Survival Analysis model, which is trained on sequence-to-sequence data with binary labels at each time step, where the event always occurs at the final time step.
DRSA
(n_features
:int
, hidden_dim
:int
, n_layers
:int
, embeddings
:List
[Embedding
], output_size
:int
=1
, LSTM_dropout
:float
=0.0
, Linear_dropout
:float
=0.0
) :: Module
Deep Recurrent Survival Analysis model.
A relatively shallow net, characterized by an LSTM layer followed by a Linear layer.
DRSA.__init__
(n_features
:int
, hidden_dim
:int
, n_layers
:int
, embeddings
:List
[Embedding
], output_size
:int
=1
, LSTM_dropout
:float
=0.0
, Linear_dropout
:float
=0.0
)
inputs:
n_features
- size of the input to the LSTM (number of features)
hidden_dim
:
- size (dimension) of the hidden state in LSTM
n_layers
:
embeddings
:
- list of nn.Embeddings for each categorical variable
- It is assumed the the 1st categorical feature corresponds with the 0th feature,
the 2nd corresponds with the 1st feature, and so on.
output_size
:
- size of the linear layer's output, which should always be 1, unless altering this model
LSTM_dropout
:
- percent of neurons in LSTM layer to apply dropout regularization to during training
Linear_dropout
:
- percent of neurons in linear layer to apply dropout regularization to during training
DRSA.forward
(X
:tensor
)
input:
X
- input features of shape (batch_size, sequence length, self.n_features)
output:
out
:
- the DRSA model's predictions at each time step, for each observation in batch
- out is of shape (batch_size, sequence_length, 1)