

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Probabilistic forecasting for univariate time series

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L17"
target="_blank" style="float:right; font-size:smaller">source</a>

### prob_forecasts

``` python

def prob_forecasts(
    model, # Any model with ``.target_col``, ``.fit(df)``, and ``.forecast(H, exog)`` attributes.
    H:int, # Forecast horizon.
    n_calibration:Union[int, None]=None, # Number of calibration windows for cross-validated residual estimation. If None, in sample residuals are used without cross-validation (Horizon-specific uncalibrated intervals may be too narrow in this case. This is recommended when data size is small as the model may not have enough data to fit well in each calibration fold).
    step_size:int=1, # Step size between consecutive calibration windows.
    random_state:int=42, # Seed for all internal random-number generators.
    n_iter:Union[int, None]=None, # Number of EM iterations during each calibration window.  Only relevant for Markov-switching Autoregressive model ([`ms_arr`](https://mustafaslanCoto.github.io/peshbeen/modules/02_models/ms_arr.html#ms_arr)). A smaller value than the model's default speeds up calibration at the cost of convergence quality per fold — typically a value of 3–10 is sufficient for calibration windows where the model is already close to the solution.
    verbose:bool=False, # Print progress during calibration.
):

```

*Probabilistic forecasting wrapper for any point-forecasting model.*

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>model</td>
<td></td>
<td></td>
<td>Any model with <code>.target_col</code>, <code>.fit(df)</code>, and
<code>.forecast(H, exog)</code> attributes.</td>
</tr>
<tr>
<td>H</td>
<td>int</td>
<td></td>
<td>Forecast horizon.</td>
</tr>
<tr>
<td>n_calibration</td>
<td>Union[int, None]</td>
<td>None</td>
<td>Number of calibration windows for cross-validated residual
estimation. If None, in sample residuals are used without
cross-validation (Horizon-specific uncalibrated intervals may be too
narrow in this case. This is recommended when data size is small as the
model may not have enough data to fit well in each calibration
fold).</td>
</tr>
<tr>
<td>step_size</td>
<td>int</td>
<td>1</td>
<td>Step size between consecutive calibration windows.</td>
</tr>
<tr>
<td>random_state</td>
<td>int</td>
<td>42</td>
<td>Seed for all internal random-number generators.</td>
</tr>
<tr>
<td>n_iter</td>
<td>Union[int, None]</td>
<td>None</td>
<td>Number of EM iterations during each calibration window. Only
relevant for Markov-switching Autoregressive model (<a
href="https://mustafaslanCoto.github.io/peshbeen/modules/02_models/ms_arr.html#ms_arr"><code>ms_arr</code></a>).
A smaller value than the model’s default speeds up calibration at the
cost of convergence quality per fold — typically a value of 3–10 is
sufficient for calibration windows where the model is already close to
the solution.</td>
</tr>
<tr>
<td>verbose</td>
<td>bool</td>
<td>False</td>
<td>Print progress during calibration.</td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L152"
target="_blank" style="float:right; font-size:smaller">source</a>

### prob_forecasts.calibrate

``` python

def calibrate(
    df:pd.DataFrame, # Calibration dataset.
    delta:Union[float, List[float]]=0.5, # Coverage level(s).  A single float produces one symmetric interval; a list produces one interval per level.  For example,``delta=0.9`` produces a 90 % prediction interval.
)->'prob_forecasts': # The fitted object, with ``self.q_hat`` set to the calibrated

```

*Calibrate the conformal predictor.*

Runs rolling-window cross-validation (if not already done) to collect
non-conformity scores, then computes the per-horizon conformal quantile
`q_hat` for each requested `delta` level.

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>df</td>
<td>pd.DataFrame</td>
<td></td>
<td>Calibration dataset.</td>
</tr>
<tr>
<td>delta</td>
<td>Union[float, List[float]]</td>
<td>0.5</td>
<td>Coverage level(s). A single float produces one symmetric interval; a
list produces one interval per level. For example,<code>delta=0.9</code>
produces a 90 % prediction interval.</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>‘prob_forecasts’</strong></td>
<td></td>
<td><strong>The fitted object, with <code>self.q_hat</code> set to the
calibrated</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L286"
target="_blank" style="float:right; font-size:smaller">source</a>

### prob_forecasts.sample

``` python

def sample(
    df:pd.DataFrame, # Training data.  Residuals are computed via cross-validation if not yet available.
    n_samples:int=1000, # Number of sample paths to draw.
    method:str='empirical', # Sampling strategy (see above).
    future_exog:Union[pd.DataFrame, None]=None, # Future exogenous variables passed to ``forecast``.
)->'prob_forecasts':

```

*Draw sample paths from the predictive distribution.*

Three methods are available:

- `"empirical"` — residuals are resampled with replacement independently
  at each horizon.
- `"kde"` — a Gaussian KDE is fitted to each horizon’s residuals;
  samples are drawn from the smoothed distribution.
- `"correlated"` — a multivariate normal is fitted to the full
  `H`-dimensional residual vectors, preserving cross-horizon
  correlation. Samples are drawn jointly.

Results are stored on `self`:

- `self.sample_paths` — `(n_samples, H)` array of sampled trajectories
  centred on the point forecast.
- `self.point_forecast` — `(H,)` point forecast array.
- `self.sample_paths_df` — the same data as a DataFrame with columns
  `h_1, …, h_H`.

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>df</td>
<td>pd.DataFrame</td>
<td></td>
<td>Training data. Residuals are computed via cross-validation if not
yet available.</td>
</tr>
<tr>
<td>n_samples</td>
<td>int</td>
<td>1000</td>
<td>Number of sample paths to draw.</td>
</tr>
<tr>
<td>method</td>
<td>str</td>
<td>empirical</td>
<td>Sampling strategy (see above).</td>
</tr>
<tr>
<td>future_exog</td>
<td>Union[pd.DataFrame, None]</td>
<td>None</td>
<td>Future exogenous variables passed to <code>forecast</code>.</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>‘prob_forecasts’</strong></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L396"
target="_blank" style="float:right; font-size:smaller">source</a>

### prob_forecasts.sample_quantiles

``` python

def sample_quantiles(
    quantiles:Union[float, List[float]], # Desired quantile levels (e.g. ``[0.1, 0.5, 0.9]``).
)->pd.DataFrame: # Columns: ``point_forecast``, ``q_<level>`` for each level.

```

*Compute quantiles from the sample paths generated by `sample`.*

Works identically regardless of which `method` was passed to `sample`.

<table>
<colgroup>
<col style="width: 9%" />
<col style="width: 38%" />
<col style="width: 52%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>quantiles</td>
<td>Union[float, List[float]]</td>
<td>Desired quantile levels (e.g. <code>[0.1, 0.5, 0.9]</code>).</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>pd.DataFrame</strong></td>
<td><strong>Columns: <code>point_forecast</code>,
<code>q_&lt;level&gt;</code> for each level.</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L244"
target="_blank" style="float:right; font-size:smaller">source</a>

### prob_forecasts.conformal_quantiles

``` python

def conformal_quantiles(
    df:pd.DataFrame, # Training data for the final model fit.
    quantiles:Union[float, List[float]], # Desired quantile levels (e.g. ``[0.1, 0.5, 0.9]``).
    future_exog:Union[pd.DataFrame, None]=None, # Future exogenous variables.
)->pd.DataFrame: # Columns: ``point_forecast``, ``q_<level>`` for each level.

```

*Generate conformal prediction quantiles.*

Requires `calibrate` to have been called first.

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>df</td>
<td>pd.DataFrame</td>
<td></td>
<td>Training data for the final model fit.</td>
</tr>
<tr>
<td>quantiles</td>
<td>Union[float, List[float]]</td>
<td></td>
<td>Desired quantile levels (e.g. <code>[0.1, 0.5, 0.9]</code>).</td>
</tr>
<tr>
<td>future_exog</td>
<td>Union[pd.DataFrame, None]</td>
<td>None</td>
<td>Future exogenous variables.</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>pd.DataFrame</strong></td>
<td></td>
<td><strong>Columns: <code>point_forecast</code>,
<code>q_&lt;level&gt;</code> for each level.</strong></td>
</tr>
</tbody>
</table>

## Probabilistic forecasting for multivariate time series

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L438"
target="_blank" style="float:right; font-size:smaller">source</a>

### mv_prob_forecasts

``` python

def mv_prob_forecasts(
    model, # Any model with ``.target_col``, ``.fit(df)``, and ``.forecast(H, exog)`` attributes.
    target_col:str, # Name of the target variable column in the input DataFrames.
    H:int, # Forecast horizon.
    n_calibration:Union[int, None]=None, # Number of calibration windows for cross-validated residual estimation. If None, in sample residuals are used without cross-validation (Horizon-specific uncalibrated intervals may be too narrow in this case. This is recommended when data size is small as the model may not have enough data to fit well in each calibration fold).
    step_size:int=1, # Step size between consecutive calibration windows.
    random_state:int=42, # Seed for all internal random-number generators.
    n_iter:Union[int, None]=None, # Number of EM iterations during each calibration window.  Only relevant for Markov-switching Autoregressive model ([`ms_arr`](https://mustafaslanCoto.github.io/peshbeen/modules/02_models/ms_arr.html#ms_arr)). A smaller value than the model's default speeds up calibration at the cost of convergence quality per fold — typically a value of 3–10 is sufficient for calibration windows where the model is already close to the solution.
    verbose:bool=False, # Print progress during calibration.
):

```

*Probabilistic forecasting wrapper for any point-forecasting model.*

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>model</td>
<td></td>
<td></td>
<td>Any model with <code>.target_col</code>, <code>.fit(df)</code>, and
<code>.forecast(H, exog)</code> attributes.</td>
</tr>
<tr>
<td>target_col</td>
<td>str</td>
<td></td>
<td>Name of the target variable column in the input DataFrames.</td>
</tr>
<tr>
<td>H</td>
<td>int</td>
<td></td>
<td>Forecast horizon.</td>
</tr>
<tr>
<td>n_calibration</td>
<td>Union[int, None]</td>
<td>None</td>
<td>Number of calibration windows for cross-validated residual
estimation. If None, in sample residuals are used without
cross-validation (Horizon-specific uncalibrated intervals may be too
narrow in this case. This is recommended when data size is small as the
model may not have enough data to fit well in each calibration
fold).</td>
</tr>
<tr>
<td>step_size</td>
<td>int</td>
<td>1</td>
<td>Step size between consecutive calibration windows.</td>
</tr>
<tr>
<td>random_state</td>
<td>int</td>
<td>42</td>
<td>Seed for all internal random-number generators.</td>
</tr>
<tr>
<td>n_iter</td>
<td>Union[int, None]</td>
<td>None</td>
<td>Number of EM iterations during each calibration window. Only
relevant for Markov-switching Autoregressive model (<a
href="https://mustafaslanCoto.github.io/peshbeen/modules/02_models/ms_arr.html#ms_arr"><code>ms_arr</code></a>).
A smaller value than the model’s default speeds up calibration at the
cost of convergence quality per fold — typically a value of 3–10 is
sufficient for calibration windows where the model is already close to
the solution.</td>
</tr>
<tr>
<td>verbose</td>
<td>bool</td>
<td>False</td>
<td>Print progress during calibration.</td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L567"
target="_blank" style="float:right; font-size:smaller">source</a>

### mv_prob_forecasts.calibrate

``` python

def calibrate(
    df:pd.DataFrame, # Calibration dataset.
    delta:Union[float, List[float]]=0.5, # Coverage level(s).  A single float produces one symmetric interval; a list produces one interval per level.  For example,``delta=0.9`` produces a 90 % prediction interval.
)->'prob_forecasts': # The fitted object, with ``self.q_hat`` set to the calibrated

```

*Calibrate the conformal predictor.*

Runs rolling-window cross-validation (if not already done) to collect
non-conformity scores, then computes the per-horizon conformal quantile
`q_hat` for each requested `delta` level.

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>df</td>
<td>pd.DataFrame</td>
<td></td>
<td>Calibration dataset.</td>
</tr>
<tr>
<td>delta</td>
<td>Union[float, List[float]]</td>
<td>0.5</td>
<td>Coverage level(s). A single float produces one symmetric interval; a
list produces one interval per level. For example,<code>delta=0.9</code>
produces a 90 % prediction interval.</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>‘prob_forecasts’</strong></td>
<td></td>
<td><strong>The fitted object, with <code>self.q_hat</code> set to the
calibrated</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L700"
target="_blank" style="float:right; font-size:smaller">source</a>

### mv_prob_forecasts.sample

``` python

def sample(
    df:pd.DataFrame, # Training data.  Residuals are computed via cross-validation if not yet available.
    n_samples:int=1000, # Number of sample paths to draw.
    method:str='empirical', # Sampling strategy (see above).
    future_exog:Union[pd.DataFrame, None]=None, # Future exogenous variables passed to ``forecast``.
)->'prob_forecasts':

```

*Draw sample paths from the predictive distribution.*

Three methods are available:

- `"empirical"` — residuals are resampled with replacement independently
  at each horizon.
- `"kde"` — a Gaussian KDE is fitted to each horizon’s residuals;
  samples are drawn from the smoothed distribution.
- `"correlated"` — a multivariate normal is fitted to the full
  `H`-dimensional residual vectors, preserving cross-horizon
  correlation. Samples are drawn jointly.

Results are stored on `self`:

- `self.sample_paths` — `(n_samples, H)` array of sampled trajectories
  centred on the point forecast.
- `self.point_forecast` — `(H,)` point forecast array.
- `self.sample_paths_df` — the same data as a DataFrame with columns
  `h_1, …, h_H`.

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>df</td>
<td>pd.DataFrame</td>
<td></td>
<td>Training data. Residuals are computed via cross-validation if not
yet available.</td>
</tr>
<tr>
<td>n_samples</td>
<td>int</td>
<td>1000</td>
<td>Number of sample paths to draw.</td>
</tr>
<tr>
<td>method</td>
<td>str</td>
<td>empirical</td>
<td>Sampling strategy (see above).</td>
</tr>
<tr>
<td>future_exog</td>
<td>Union[pd.DataFrame, None]</td>
<td>None</td>
<td>Future exogenous variables passed to <code>forecast</code>.</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>‘prob_forecasts’</strong></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L813"
target="_blank" style="float:right; font-size:smaller">source</a>

### mv_prob_forecasts.sample_quantiles

``` python

def sample_quantiles(
    quantiles:Union[float, List[float]], # Desired quantile levels (e.g. ``[0.1, 0.5, 0.9]``).
)->pd.DataFrame: # Columns: ``point_forecast``, ``q_<level>`` for each level.

```

*Compute quantiles from the sample paths generated by `sample`.*

Works identically regardless of which `method` was passed to `sample`.

<table>
<colgroup>
<col style="width: 9%" />
<col style="width: 38%" />
<col style="width: 52%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>quantiles</td>
<td>Union[float, List[float]]</td>
<td>Desired quantile levels (e.g. <code>[0.1, 0.5, 0.9]</code>).</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>pd.DataFrame</strong></td>
<td><strong>Columns: <code>point_forecast</code>,
<code>q_&lt;level&gt;</code> for each level.</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/mustafaslanCoto/peshbeen/blob/main/peshbeen/probabilistic_forecasting.py#L658"
target="_blank" style="float:right; font-size:smaller">source</a>

### mv_prob_forecasts.conformal_quantiles

``` python

def conformal_quantiles(
    df:pd.DataFrame, # Training data for the final model fit.
    quantiles:Union[float, List[float]], # Desired quantile levels (e.g. ``[0.1, 0.5, 0.9]``).
    future_exog:Union[pd.DataFrame, None]=None, # Future exogenous variables.
)->pd.DataFrame: # Columns: ``point_forecast``, ``q_<level>`` for each level.

```

*Generate conformal prediction quantiles.*

Requires `calibrate` to have been called first.

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>df</td>
<td>pd.DataFrame</td>
<td></td>
<td>Training data for the final model fit.</td>
</tr>
<tr>
<td>quantiles</td>
<td>Union[float, List[float]]</td>
<td></td>
<td>Desired quantile levels (e.g. <code>[0.1, 0.5, 0.9]</code>).</td>
</tr>
<tr>
<td>future_exog</td>
<td>Union[pd.DataFrame, None]</td>
<td>None</td>
<td>Future exogenous variables.</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>pd.DataFrame</strong></td>
<td></td>
<td><strong>Columns: <code>point_forecast</code>,
<code>q_&lt;level&gt;</code> for each level.</strong></td>
</tr>
</tbody>
</table>
