tempor.methods.prediction.one_off.regression.plugin_laplace_regressor module

One-off regression plugin based on “Neural Laplace: Learning diverse classes of differential equations in the Laplace domain”.

class tempor.methods.prediction.one_off.regression.plugin_laplace_regressor.LaplaceODERegressorParams(n_units_hidden: int = 100, n_layers_hidden: int = 1, nonlin: Literal[none] | Literal[elu] | Literal[relu] | Literal[leaky_relu] | Literal[selu] | Literal[tanh] | Literal[sigmoid] | Literal[softmax] | Literal[gumbel_softmax] = 'relu', dropout: float = 0, ilt_reconstruction_terms: int = 33, ilt_algorithm: Literal[fourier] | Literal[dehoog] | Literal[cme] | Literal[fixed_tablot] | Literal[stehfest] = 'fourier', lr: float = 0.001, weight_decay: float = 0.001, n_iter: int = 1000, batch_size: int = 500, n_iter_print: int = 100, random_state: int = 0, patience: int = 10, clipping_value: int = 1, train_ratio: float = 0.8, device: str | None = None, dataloader_sampler: Literal[BatchSampler] | Literal[RandomSampler] | Literal[Sampler] | Literal[SequentialSampler] | Literal[SubsetRandomSampler] | Literal[WeightedRandomSampler] | None = None)[source]

Bases: object

Initialization parameters for LaplaceODERegressor.

n_units_hidden : int = 100

Number of hidden units.

n_layers_hidden : int = 1

Number of hidden layers.

nonlin : Literal[none] | Literal[elu] | Literal[relu] | Literal[leaky_relu] | Literal[selu] | Literal[tanh] | Literal[sigmoid] | Literal[softmax] | Literal[gumbel_softmax] = 'relu'

Nonlin.

Type:

Activation for hidden layers. Available options

dropout : float = 0

Dropout value.

ilt_reconstruction_terms : int = 33

Number of ILT reconstruction terms, i.e. the number of complex \(s\) points in laplace_rep_func to reconstruct a single time point.

ilt_algorithm : Literal[fourier] | Literal[dehoog] | Literal[cme] | Literal[fixed_tablot] | Literal[stehfest] = 'fourier'

Inverse Laplace transform algorithm to use. Available are {fourier, dehoog, cme, fixed_tablot, stehfest}.

lr : float = 0.001

Learning rate for optimizer.

weight_decay : float = 0.001

l2 (ridge) penalty for the weights.

n_iter : int = 1000

Maximum number of iterations.

batch_size : int = 500

Batch size.

n_iter_print : int = 100

Number of iterations after which to print updates and check the validation loss.

random_state : int = 0

Random_state used.

patience : int = 10

Number of iterations to wait before early stopping after decrease in validation loss.

clipping_value : int = 1

Gradients clipping value.

train_ratio : float = 0.8

Train/test split ratio.

device : str | None = None

String representing PyTorch device. If None, DEVICE.

dataloader_sampler : Literal[BatchSampler] | Literal[RandomSampler] | Literal[Sampler] | Literal[SequentialSampler] | Literal[SubsetRandomSampler] | Literal[WeightedRandomSampler] | None = None

Custom data sampler for training.

class tempor.methods.prediction.one_off.regression.plugin_laplace_regressor.LaplaceODERegressor(**params: Any)[source]

Bases: BaseOneOffRegressor

Inverse Laplace Transform (ILT) algorithms implemented in PyTorch. Backpropagation through differential equation (DE) solutions in the Laplace domain is supported using the Riemann stereographic projection for better global representation of the complex Laplace domain.

Parameters:
**params : Any

Parameters and defaults as defined in LaplaceODERegressorParams.

Example

>>> from tempor import plugin_loader
>>>
>>> dataset = plugin_loader.get("prediction.one_off.google_stocks", plugin_type="datasource").load()
>>>
>>> # Load the model:
>>> model = plugin_loader.get("prediction.one_off.regression.laplace_ode_regressor", n_iter=50)
>>>
>>> # Train:
>>> model.fit(dataset)
LaplaceODERegressor(...)
>>>
>>> # Predict:
>>> assert model.predict(dataset).numpy().shape == (len(dataset), 1)

References

“Neural Laplace: Learning diverse classes of differential equations in the Laplace domain”, Holt, Samuel I and Qian, Zhaozhi and van der Schaar, Mihaela.

category : ClassVar[plugin_typing.PluginCategory] = 'prediction.one_off.regression'

Plugin category, such as 'prediction.one_off.classification'. Must be set by the plugin class using @register_plugin.

name : ClassVar[plugin_typing.PluginName] = 'laplace_ode_regressor'

Plugin name, such as 'my_nn_classifier'. Must be set by the plugin class using @register_plugin.

plugin_type : ClassVar[plugin_typing.PluginTypeArg] = 'method'

Plugin type, such as 'method'. May be optionally set by the plugin class using @register_plugin, else will set the default plugin type.

ParamsDefinition

alias of LaplaceODERegressorParams

params : LaplaceODERegressorParams
static hyperparameter_space(*args: Any, **kwargs: Any) list[Params][source]

The hyperparameter search domain, used for tuning.

Can provide variadics *args and **kwargs, these will be received from sample_hyperparameters.