MLPRegressor

class MLPRegressor(**kwargs)[source]

Bases: RegressorNN

A class used to represent a Multilayer Perceptron (MLP) for regression tasks. This class inherits from the RegressorNN class.

model_type

A string that represents the type of the model (default is “ffnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • dropout (float) – The dropout probability (default is 0.2).

__init__(self, **kwargs)[source]

Initializes the MLPRegressor object with given or default parameters.

_init_model(self)[source]

Initializes the layers of the neural network based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the neural network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the neural network. :param x: The input tensor. :returns: The output tensor, corresponding to the predicted target variable(s).

model_type = 'ffnn'
training: bool

CNNRegressor

class CNNRegressor(**kwargs)[source]

Bases: RegressorNN

A class used to represent a Convolutional Neural Network (CNN) for regression tasks. This class inherits from the RegressorNN class.

model_type

A string that represents the type of the model (default is “cnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_filters (int) – The number of filters in the convolutional layer.

  • kernel_size (int) – The size of the kernel in the convolutional layer.

  • pool_size (int) – The size of the pooling layer.

__init__(self, **kwargs)[source]

Initializes the CNNRegressor object with given or default parameters.

_init_model(self)[source]

Initializes the convolutional and fully connected layers of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the CNN.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the CNN. :param x: The input tensor. :returns: The output tensor, corresponding to the predicted target variable(s).

model_type = 'cnn'
training: bool

LSTMRegressor

class LSTMRegressor(**kwargs)[source]

Bases: RegressorNN

A class used to represent a Long Short-Term Memory (LSTM) network for regression tasks. This class inherits from the RegressorNN class.

model_type

A string that represents the type of the model (default is “rnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_layers (int) – The number of recurrent layers (default is 1).

__init__(self, **kwargs)[source]

Initializes the LSTMRegressor object with given or default parameters.

_init_model(self)[source]

Initializes the LSTM and fully connected layers of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the LSTM network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the LSTM network. :param x: The input tensor. :returns: The output tensor, corresponding to the predicted target variable(s).

model_type = 'rnn'
training: bool

GRURegressor

class GRURegressor(**kwargs)[source]

Bases: RegressorNN

A class used to represent a Gated Recurrent Unit (GRU) network for regression tasks. This class inherits from the RegressorNN class.

model_type

A string that represents the type of the model (default is “rnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_layers (int) – The number of recurrent layers (default is 1).

__init__(self, **kwargs)[source]

Initializes the GRURegressor object with given or default parameters.

_init_model(self)[source]

Initializes the GRU and fully connected layers of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the GRU network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the GRU network. :param x: The input tensor. :returns: The output tensor, corresponding to the predicted target variable(s).

model_type = 'rnn'
training: bool

BiGRURegressor

class BiGRURegressor(**kwargs)[source]

Bases: RegressorNN

A class used to represent a Bidirectional Gated Recurrent Unit (BiGRU) network for classification tasks. This class inherits from the ClassifierNN class.

model_type

A string that represents the type of the model (default is “rnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_layers (int) – The number of recurrent layers (default is 1).

__init__(self, **kwargs)[source]

Initializes the BiGRURegressor object with given or default parameters.

_init_model(self)[source]

Initializes the BiGRU layers and fully connected layer of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the BiGRU network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the BiGRU network.

Parameters:

x (torch.Tensor) – The input tensor.

Returns:

The output tensor.

Return type:

torch.Tensor

Raises:

RuntimeError – If the model has not been initialized by calling the fit method before calling predict.

model_type = 'rnn'
training: bool

BiLSTMRegressor

class BiLSTMRegressor(**kwargs)[source]

Bases: RegressorNN

A class used to represent a Bidirectional Long Short-Term Memory (BiLSTM) network for regression tasks. This class inherits from the RegressorNN class.

model_type

A string that represents the type of the model (default is “rnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_layers (int) – The number of recurrent layers (default is 1).

__init__(self, **kwargs)[source]

Initializes the BiLSTMRegressor object with given or default parameters.

_init_model(self)[source]

Initializes the BiLSTM layers and fully connected layer of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the BiLSTM network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the BiLSTM network.

Parameters:

x (torch.Tensor) – The input tensor.

Returns:

The output tensor.

Return type:

torch.Tensor

Raises:

RuntimeError – If the model has not been initialized by calling the fit method before calling predict.

model_type = 'rnn'
training: bool

BNNRegressor

class BNNRegressor(**kwargs)[source]

Bases: RegressorProb

A class used to represent a Bayesian Neural Network (BNN) for regression tasks. This class inherits from the ClassifierProb class.

hidden_size

A list of integers representing the number of nodes in each hidden layer or a single integer representing the number of nodes in a single hidden layer.

Type:

list[int] or int

dropout

The dropout rate for the dropout layers (default is 0.2).

Type:

float

model_type

A string representing the type of the model (default is “ffnn”).

Type:

str

__init__(self, **kwargs)[source]

Initializes the BayesianNNRegressor object with given or default parameters.

_init_model(self)[source]

Initializes the Bayesian Neural Network layers of the model based on configuration.

forward(self, x_data

torch.Tensor, y_data: torch.Tensor=None) -> torch.Tensor: Defines the forward pass of the Bayesian Neural Network.

_initSVI(self) pyro.infer.svi.SVI[source]

Initializes Stochastic Variational Inference (SVI) for Bayesian Inference with an AutoNormal guide.

forward(x_data: Tensor, y_data: Optional[Tensor] = None) Tensor[source]

Defines the forward pass of the Bayesian Neural Network.

Parameters:
Returns:

The output tensor of the model.

Return type:

torch.Tensor

model_type = 'ffnn'
training: bool

BCNNRegressor

class BCNNRegressor(**kwargs)[source]

Bases: RegressorProb

A class used to represent a Bayesian Convolutional Neural Network (CNN) for probabilistic regression tasks. This class inherits from the ClassifierProb class.

Parameters:
  • hidden_size – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_filters – The number of filters in the convolutional layer.

  • kernel_size – The size of the kernel in the convolutional layer.

  • pool_size – The size of the pooling layer.

  • dropout – The dropout rate for regularization.

model_type

A string that represents the type of the model (default is “cnn”).

__init__(self, **kwargs)[source]

Initializes the BayesianCNNRegressor object with given or default parameters.

_init_model(self)[source]

Initializes the Convolutional layers and fully connected layers of the model based on configuration. This model uses PyroModule wrappers for the layers to enable Bayesian inference.

forward(self, x_data

torch.Tensor, y_data: torch.Tensor=None) -> torch.Tensor: Defines the forward pass of the Bayesian CNN, and optionally observes the output if ground truth y_data is provided.

_initSVI(self) pyro.infer.svi.SVI[source]

Initializes Stochastic Variational Inference (SVI) for the model. Defines the guide function to be a Normal distribution that learns to approximate the posterior, and uses Mean Field ELBO as the variational loss.

forward(x_data: Tensor, y_data: Optional[Tensor] = None) Tensor[source]
model_type = 'cnn'
training: bool

DeepMarkovRegressor

class DeepMarkovRegressor(**kwargs)[source]

Bases: RegressorProb

A class used to represent a Deep Markov Model (DMM) for regression tasks. This class inherits from the RegressorProb class.

rnn_dim

The dimension of the hidden state of the RNN.

Type:

int

z_dim

The dimension of the latent random variable z.

Type:

int

emission_dim

The dimension of the hidden state of the emission model.

Type:

int

transition_dim

The dimension of the hidden state of the transition model.

Type:

int

variance

The variance of the observation noise.

Type:

float

model_type

A string representing the type of the model (default is “rnn”).

Type:

str

__init__(self, **kwargs)[source]

Initializes the DeepMarkovModelRegressor object with given or default parameters.

_init_model(self)[source]

Initializes the DMM modules (emitter, transition, combiner, rnn) and some trainable parameters.

model(self, x_data

torch.Tensor, y_data: Optional[torch.Tensor] = None, annealing_factor: float = 1.0) -> torch.Tensor: Defines the generative model which describes the process of generating the data.

guide(self, x_data

torch.Tensor, y_data: Optional[torch.Tensor] = None, annealing_factor: float = 1.0) -> torch.Tensor: Defines the variational guide (approximate posterior) that is used for inference.

forward()[source]
guide(x_data: Tensor, y_data: Optional[Tensor] = None, annealing_factor: float = 1.0) Tensor[source]

Defines the guide (also called the inference model or variational distribution) q(z|x,y) which is an approximation to the posterior p(z|x,y). It also handles the computation of the parameters of this guide.

Parameters:
  • x_data (torch.Tensor) – Input tensor for the guide.

  • y_data (Optional[torch.Tensor]) – Optional observed output tensor for the guide.

  • annealing_factor (float, optional) – Annealing factor used in poutine.scale to handle KL annealing.

Returns:

The sampled latent variable z from the last time step of the guide.

Return type:

torch.Tensor

model(x_data: Tensor, y_data: Optional[Tensor] = None, annealing_factor: float = 1.0) Tensor[source]

Defines the generative model p(y,z|x) which includes the observation model p(y|z) and transition model p(z_t | z_{t-1}). It also handles the computation of the parameters of these models.

Parameters:
  • x_data (torch.Tensor) – Input tensor for the model.

  • y_data (Optional[torch.Tensor]) – Optional observed output tensor for the model.

  • annealing_factor (float, optional) – Annealing factor used in poutine.scale to handle KL annealing.

Returns:

The sampled latent variable z from the last time step of the model.

Return type:

torch.Tensor

model_type = 'rnn'
training: bool

GHMMRegressor

class GHMMRegressor(**kwargs)[source]

Bases: RegressorProb

A class used to represent a Gaussian Hidden Markov Model (GHMM) for regression tasks. This class inherits from the RegressorProb class.

rnn_dim

The dimension of the hidden state of the RNN.

Type:

int

z_dim

The dimension of the latent random variable z.

Type:

int

emission_dim

The dimension of the hidden state of the emission model.

Type:

int

transition_dim

The dimension of the hidden state of the transition model.

Type:

int

variance

The variance of the observation noise.

Type:

float

model_type

A string representing the type of the model (default is “rnn”).

Type:

str

__init__(self, **kwargs)[source]

Initializes the GaussianHMMRegressor object with given or default parameters.

_init_model(self)[source]

Initializes the GHMM modules (emitter, transition) and some trainable parameters.

model(self, x_data

torch.Tensor, y_data: Optional[torch.Tensor] = None, annealing_factor: float = 1.0) -> torch.Tensor: Defines the generative model which describes the process of generating the data.

guide(self, x_data

torch.Tensor, y_data: Optional[torch.Tensor] = None, annealing_factor: float = 1.0) -> torch.Tensor: Defines the variational guide (approximate posterior) that is used for inference.

forward()[source]
guide(x_data: Tensor, y_data: Optional[Tensor] = None, annealing_factor: float = 1.0) Tensor[source]

Implements the guide (also called the inference model or variational distribution) q(z|x,y) which is an approximation to the posterior p(z|x,y). It also handles the computation of the parameters of this guide.

Parameters:
  • x_data (torch.Tensor) – Input tensor for the guide.

  • y_data (Optional[torch.Tensor]) – Optional observed output tensor for the guide.

  • annealing_factor (float, optional) – Annealing factor used in poutine.scale to handle KL annealing.

Returns:

The sampled latent variable z from the last time step of the guide.

Return type:

torch.Tensor

model(x_data: Tensor, y_data: Optional[Tensor] = None, annealing_factor: float = 1.0) Tensor[source]

Implements the generative model p(y,z|x) which includes the observation model p(y|z) and transition model p(z_t | z_{t-1}). It also handles the computation of the parameters of these models.

Parameters:
  • x_data (torch.Tensor) – Input tensor for the model.

  • y_data (Optional[torch.Tensor]) – Optional observed output tensor for the model.

  • annealing_factor (float, optional) – Annealing factor used in poutine.scale to handle KL annealing.

Returns:

The sampled latent variable z from the last time step of the model.

Return type:

torch.Tensor

model_type = 'rnn'
training: bool