View Source Soothsayer (soothsayer v0.3.1)

The main module for the Soothsayer library, providing functions for creating, fitting, and using time series forecasting models.

Summary

Functions

Fits the Soothsayer model to the provided data.

Creates a new Soothsayer model with the given configuration.

Makes predictions using a fitted Soothsayer model.

Makes predictions and returns the individual components (trend, seasonality) using a fitted Soothsayer model.

Functions

Fits the Soothsayer model to the provided data.

Parameters

Returns

An updated Soothsayer.Model struct with fitted parameters.

Examples

iex> model = Soothsayer.new()
iex> data = Explorer.DataFrame.new(%{"ds" => [...], "y" => [...]})
iex> fitted_model = Soothsayer.fit(model, data)
%Soothsayer.Model{config: %{}, network: %Axon.Node{}, params: %{}}
@spec new(map()) :: Soothsayer.Model.t()

Creates a new Soothsayer model with the given configuration.

Parameters

  • config - A map containing the model configuration. Defaults to an empty map.

Returns

A new Soothsayer.Model struct.

Examples

iex> Soothsayer.new()
%Soothsayer.Model{config: %{trend: %{enabled: true}, seasonality: %{yearly: %{enabled: true, fourier_terms: 6}, weekly: %{enabled: true, fourier_terms: 3}}, epochs: 100, learning_rate: 0.01}, network: %Axon.Node{}, params: nil}

iex> Soothsayer.new(%{epochs: 200, learning_rate: 0.005})
%Soothsayer.Model{config: %{trend: %{enabled: true}, seasonality: %{yearly: %{enabled: true, fourier_terms: 6}, weekly: %{enabled: true, fourier_terms: 3}}, epochs: 200, learning_rate: 0.005}, network: %Axon.Node{}, params: nil}

Makes predictions using a fitted Soothsayer model.

Parameters

Returns

An Nx.Tensor containing the predicted values.

Examples

iex> fitted_model = Soothsayer.fit(model, training_data)
iex> future_dates = Explorer.Series.from_list([~D[2023-01-01], ~D[2023-01-02], ~D[2023-01-03]])
iex> predictions = Soothsayer.predict(fitted_model, future_dates)
#Nx.Tensor<
  f32[3][1]
  [
    [1.5],
    [2.3],
    [3.1]
  ]
>
Link to this function

predict_components(model, x)

View Source
@spec predict_components(Soothsayer.Model.t(), Explorer.Series.t()) :: %{
  combined: Nx.Tensor.t(),
  trend: Nx.Tensor.t(),
  yearly_seasonality: Nx.Tensor.t(),
  weekly_seasonality: Nx.Tensor.t()
}

Makes predictions and returns the individual components (trend, seasonality) using a fitted Soothsayer model.

Parameters

Returns

A map containing the predicted values for each component (trend, yearly seasonality, weekly seasonality) and the combined prediction.

Examples

iex> fitted_model = Soothsayer.fit(model, training_data)
iex> future_dates = Explorer.Series.from_list([~D[2023-01-01], ~D[2023-01-02], ~D[2023-01-03]])
iex> predictions = Soothsayer.predict_components(fitted_model, future_dates)
%{
  combined: #Nx.Tensor<...>,
  trend: #Nx.Tensor<...>,
  yearly_seasonality: #Nx.Tensor<...>,
  weekly_seasonality: #Nx.Tensor<...>
}