seq_models

class EncoderDecoderVectorRegressionModel(cuda: bool, history_sequence_column_name: str, history_sequence_vectoriser: sensai.vectoriser.SequenceVectoriser, history_sequence_variable_length: bool, target_sequence_column_name: str, target_sequence_vectoriser: sensai.vectoriser.SequenceVectoriser, latent_dim: int, encoder_factory: sensai.torch.torch_models.seq.seq_modules.EncoderFactory, decoder_factory: sensai.torch.torch_models.seq.seq_modules.DecoderFactory, nn_optimiser_params: Optional[sensai.torch.torch_opt.NNOptimiserParams] = None)[source]

Bases: sensai.torch.torch_base.TorchVectorRegressionModel

A highly general encoder-decoder sequence model, which encodes a sequence of history items and uses the encoding to make predictions for one or more target sequence items. History and target sequences are converted to vectors via vectorisers.

__init__(cuda: bool, history_sequence_column_name: str, history_sequence_vectoriser: sensai.vectoriser.SequenceVectoriser, history_sequence_variable_length: bool, target_sequence_column_name: str, target_sequence_vectoriser: sensai.vectoriser.SequenceVectoriser, latent_dim: int, encoder_factory: sensai.torch.torch_models.seq.seq_modules.EncoderFactory, decoder_factory: sensai.torch.torch_models.seq.seq_modules.DecoderFactory, nn_optimiser_params: Optional[sensai.torch.torch_opt.NNOptimiserParams] = None)
Parameters
  • cuda – whether to use a CUDA device

  • history_sequence_column_name – the name of the data frame input column which contains the history sequences to be encoded. The column must contain a sequence of items that can be converted to vectors via the history_sequence_vectorizer

  • history_sequence_vectoriser – a vectorizer which converts history sequence items to vectors

  • history_sequence_variable_length – whether history sequences can be of variable length

  • target_sequence_column_name – the column containing the target item sequence; Note that the column must contain sequences even if there is but a single target item for which predictions shall be made. In such cases, simply use a column that contains lists with a single item each.

  • target_sequence_vectoriser – the vectoriser for the generation of feature vectors for the target items.

  • latent_dim – the number of latent dimensions to be used by the encoder

  • encoder_factory – a factory for the creation of the encoder, which takes sequence items from the history and encodes them into vectors of dimension latent_dim

  • decoder_factory – a factory for the creation of the decoder component, which takes a latent vector produced by the encoder and (a sequence of) target features to make predictions

  • nn_optimiser_params – the optimiser parameters

class InputTensoriser(history_sequence_column_name: str, history_sequence_vectoriser: sensai.vectoriser.SequenceVectoriser, target_sequence_column_name: str, target_sequence_vectoriser: sensai.vectoriser.SequenceVectoriser)

Bases: sensai.torch.torch_data.Tensoriser

__init__(history_sequence_column_name: str, history_sequence_vectoriser: sensai.vectoriser.SequenceVectoriser, target_sequence_column_name: str, target_sequence_vectoriser: sensai.vectoriser.SequenceVectoriser)
fit(df: pandas.core.frame.DataFrame, model=None)
Parameters
  • df – the data frame with which to fit this tensoriser

  • model – the model in the context of which the fitting takes place (if any). The fitting process may set parameters within the model that can only be determined from the (pre-tensorised) data.

class EncoderDecoderModel(parent: sensai.torch.torch_models.seq.seq_models.EncoderDecoderVectorRegressionModel)

Bases: sensai.torch.torch_base.TorchModel

__init__(parent: sensai.torch.torch_models.seq.seq_models.EncoderDecoderVectorRegressionModel)
create_torch_module() torch.nn.Module