# `Soothsayer.Model`
[🔗](https://github.com/georgeguimaraes/soothsayer/blob/v0.6.3/lib/soothsayer/model.ex#L1)

Defines the structure and operations for the Soothsayer forecasting model.

# `t`

```elixir
@type t() :: %Soothsayer.Model{config: map(), network: Axon.t(), params: term() | nil}
```

# `build_network`

```elixir
@spec build_network(map()) :: Axon.t()
```

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<...>

# `display_network`

```elixir
@spec display_network(map()) :: Axon.t()
```

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)

# `fit`

```elixir
@spec fit(
  t(),
  %{required(String.t()) =&gt; Nx.Tensor.t()},
  Nx.Tensor.t(),
  non_neg_integer()
) :: t()
```

Fits the Soothsayer model to the provided data.

## Parameters

  * `model` - A `Soothsayer.Model` struct.
  * `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{...}

# `new`

```elixir
@spec new(map()) :: t()
```

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}

# `predict`

```elixir
@spec predict(t(), %{required(String.t()) =&gt; 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 fitted `Soothsayer.Model` struct.
  * `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<...>
    }

---

*Consult [api-reference.md](api-reference.md) for complete listing*
