Soothsayer.Model (Soothsayer v0.6.1)
View SourceDefines the structure and operations for the Soothsayer forecasting model.
Summary
Functions
Builds the neural network for the Soothsayer model based on the given configuration.
Returns a display-friendly version of the network that outputs a single tensor.
Fits the Soothsayer model to the provided data.
Creates a new Soothsayer.Model struct with the given configuration.
Makes predictions using a fitted Soothsayer model.
Types
Functions
Builds the neural network for the Soothsayer model based on the given configuration.
Parameters
config- A map containing the model configuration.
Returns
An Axon neural network structure.
Examples
iex> config = %{trend: %{enabled: true}, seasonality: %{yearly: %{enabled: true, fourier_terms: 6}}}
iex> network = Soothsayer.Model.build_network(config)
#Axon.Node<...>
Returns a display-friendly version of the network that outputs a single tensor.
This version can be used with Axon.Display.as_graph/2 since it doesn't use
Axon.container with a map output.
Examples
iex> model = Soothsayer.new(config)
iex> input = %{"trend" => Nx.template({1, 1}, :f32), ...}
iex> Axon.Display.as_graph(Soothsayer.Model.display_network(model.config), input)
@spec fit( t(), %{required(String.t()) => Nx.Tensor.t()}, Nx.Tensor.t(), non_neg_integer() ) :: t()
Fits the Soothsayer model to the provided data.
Parameters
model- ASoothsayer.Modelstruct.x- A map of input tensors.y- A tensor of target values.epochs- The number of training epochs.
Returns
An updated Soothsayer.Model struct with fitted parameters.
Examples
iex> model = Soothsayer.Model.new(config)
iex> x = %{"trend" => trend_tensor, "yearly" => yearly_tensor, "weekly" => weekly_tensor}
iex> y = target_tensor
iex> fitted_model = Soothsayer.Model.fit(model, x, y, 100)
%Soothsayer.Model{...}
Creates a new Soothsayer.Model struct with the given configuration.
Parameters
config- A map containing the model configuration.
Returns
A new Soothsayer.Model struct.
Examples
iex> config = %{trend: %{enabled: true}, seasonality: %{yearly: %{enabled: true, fourier_terms: 6}}}
iex> Soothsayer.Model.new(config)
%Soothsayer.Model{network: ..., params: nil, config: ^config}
@spec predict(t(), %{required(String.t()) => Nx.Tensor.t()}) :: %{ combined: Nx.Tensor.t(), trend: Nx.Tensor.t(), yearly_seasonality: Nx.Tensor.t(), weekly_seasonality: Nx.Tensor.t() }
Makes predictions using a fitted Soothsayer model.
Parameters
model- A fittedSoothsayer.Modelstruct.x- A map of input tensors.
Returns
A map containing the predicted values for each component and the combined prediction.
Examples
iex> fitted_model = Soothsayer.Model.fit(model, training_x, training_y, 100)
iex> x = %{"trend" => future_trend_tensor, "yearly" => future_yearly_tensor, "weekly" => future_weekly_tensor}
iex> predictions = Soothsayer.Model.predict(fitted_model, x)
%{
combined: #Nx.Tensor<...>,
trend: #Nx.Tensor<...>,
yearly_seasonality: #Nx.Tensor<...>,
weekly_seasonality: #Nx.Tensor<...>
}