

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

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

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

### ml_direct_forecaster

``` python

def ml_direct_forecaster(
    model:Any, # A regression model object (e.g. LGBMRegressor(), XGBRegressor(), LinearRegression(), etc.)
    target_col:str, # Name of the target variable column in the input DataFrame.
    H:Optional[Union[int, List[int]]], # Forecast horizon(s). If int, forecasts 1..H. If list, forecasts specified horizons.
    lags:Optional[Union[int, List[int]]]=None, # Lags to include as features. Default is None.
    lag_transform:Optional[list]=None, # Lag-transform functions to apply to the target variable. Default is None.
    difference:Optional[int]=None, # Order of ordinary differencing. Default is None.
    seasonal_diff:Optional[int]=None, # Seasonal period for seasonal differencing. Default is None.
    trend:Optional[str]=None, # Trend strategy: 'linear' or 'ets'. Default is None.
    pol_degree:int=1, # Polynomial degree for linear trend. Default is 1.
    ets_params:Optional[Dict[str, Any]]=None, # Parameters for ExponentialSmoothing when trend='ets'. Default is None.
    change_points:Optional[List[int]]=None, # Breakpoint indices for piecewise linear trend. Default is None.
    box_cox:Union[bool, float, int]=False, # Box-Cox transformation. If float/int, used as lambda. If True, lambda is estimated. Default is False.
    box_cox_biasadj:bool=False, # Bias adjustment when inverting Box-Cox. Default is False.
    cat_variables:Optional[List[str]]=None, # List of categorical feature column names. If provided, these columns will be treated as categorical variables and encoded accordingly. Default is None (no categorical variables).
    categorical_encoder:Optional[Any]=None, # Categorical encoder object (e.g. OneHotEncoder(), MeanEncoder(), etc.) to apply to the categorical variables specified in cat_variables. The encoder should have fit() and transform() methods that can be applied to the input DataFrame. Default is None (no categorical encoding) and if None, categorical variables can only be used if the model can handle them natively (e.g. LGBM or CatBoost).
)->None:

```

*Initialize the ml_direct_forecaster with the specified model and
preprocessing options.* Unlike ml_forecaster, this class uses a direct
forecasting strategy: a separate model is trained for each horizon 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>model</td>
<td>Any</td>
<td></td>
<td>A regression model object (e.g. LGBMRegressor(), XGBRegressor(),
LinearRegression(), etc.)</td>
</tr>
<tr>
<td>target_col</td>
<td>str</td>
<td></td>
<td>Name of the target variable column in the input DataFrame.</td>
</tr>
<tr>
<td>H</td>
<td>Optional[Union[int, List[int]]]</td>
<td></td>
<td>Forecast horizon(s). If int, forecasts 1..H. If list, forecasts
specified horizons.</td>
</tr>
<tr>
<td>lags</td>
<td>Optional[Union[int, List[int]]]</td>
<td>None</td>
<td>Lags to include as features. Default is None.</td>
</tr>
<tr>
<td>lag_transform</td>
<td>Optional[list]</td>
<td>None</td>
<td>Lag-transform functions to apply to the target variable. Default is
None.</td>
</tr>
<tr>
<td>difference</td>
<td>Optional[int]</td>
<td>None</td>
<td>Order of ordinary differencing. Default is None.</td>
</tr>
<tr>
<td>seasonal_diff</td>
<td>Optional[int]</td>
<td>None</td>
<td>Seasonal period for seasonal differencing. Default is None.</td>
</tr>
<tr>
<td>trend</td>
<td>Optional[str]</td>
<td>None</td>
<td>Trend strategy: ‘linear’ or ‘ets’. Default is None.</td>
</tr>
<tr>
<td>pol_degree</td>
<td>int</td>
<td>1</td>
<td>Polynomial degree for linear trend. Default is 1.</td>
</tr>
<tr>
<td>ets_params</td>
<td>Optional[Dict[str, Any]]</td>
<td>None</td>
<td>Parameters for ExponentialSmoothing when trend=‘ets’. Default is
None.</td>
</tr>
<tr>
<td>change_points</td>
<td>Optional[List[int]]</td>
<td>None</td>
<td>Breakpoint indices for piecewise linear trend. Default is None.</td>
</tr>
<tr>
<td>box_cox</td>
<td>Union[bool, float, int]</td>
<td>False</td>
<td>Box-Cox transformation. If float/int, used as lambda. If True,
lambda is estimated. Default is False.</td>
</tr>
<tr>
<td>box_cox_biasadj</td>
<td>bool</td>
<td>False</td>
<td>Bias adjustment when inverting Box-Cox. Default is False.</td>
</tr>
<tr>
<td>cat_variables</td>
<td>Optional[List[str]]</td>
<td>None</td>
<td>List of categorical feature column names. If provided, these columns
will be treated as categorical variables and encoded accordingly.
Default is None (no categorical variables).</td>
</tr>
<tr>
<td>categorical_encoder</td>
<td>Optional[Any]</td>
<td>None</td>
<td>Categorical encoder object (e.g. OneHotEncoder(), MeanEncoder(),
etc.) to apply to the categorical variables specified in cat_variables.
The encoder should have fit() and transform() methods that can be
applied to the input DataFrame. Default is None (no categorical
encoding) and if None, categorical variables can only be used if the
model can handle them natively (e.g. LGBM or CatBoost).</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>None</strong></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

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

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

### ml_direct_forecaster.fit

``` python

def fit(
    df:pd.DataFrame, # Training DataFrame containing the target and any feature columns.
)->None:

```

*Fit a separate model for each horizon h in 1..H.* For each h, the
target is shifted h steps forward so the model learns to predict the
value h steps ahead directly from the current lag features, bypassing
recursive error accumulation.

<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>df</td>
<td>pd.DataFrame</td>
<td>Training DataFrame containing the target and any feature
columns.</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>None</strong></td>
<td></td>
</tr>
</tbody>
</table>

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

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

### ml_direct_forecaster.forecast

``` python

def forecast(
    H:int, # Forecast horizon. Must be <= self.H (models are only trained up to self.H).
    exog:Optional[pd.DataFrame]=None, # Optional future exogenous variables (H rows).
)->np.ndarray: # Forecast values of length H.

```

*Generate direct multi-step forecasts. Each horizon h is predicted*
independently by its own model using the most recent lag features — no
predictions are fed back as inputs.

<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>H</td>
<td>int</td>
<td></td>
<td>Forecast horizon. Must be &lt;= self.H (models are only trained up
to self.H).</td>
</tr>
<tr>
<td>exog</td>
<td>Optional[pd.DataFrame]</td>
<td>None</td>
<td>Optional future exogenous variables (H rows).</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>np.ndarray</strong></td>
<td></td>
<td><strong>Forecast values of length H.</strong></td>
</tr>
</tbody>
</table>

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

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

### ml_direct_forecaster.cross_validate

``` python

def cross_validate(
    df:pd.DataFrame, # DataFrame containing the target and any feature columns.
    cv_split:int, # Number of cross-validation splits.
    metrics:List[Callable], # Metric functions (e.g. ``[MAE, RMSE]``) used to evaluate forecast accuracy across folds. Call ``.cv_summary()`` after cross-validation to retrieve the aggregated scores.
    step_size:int=1, # Step size to move the test window forward in each split.
    h_split_point:Optional[int]=None, # Optional index to split the test set into two parts for separate evaluation (e.g. to evaluate short-term vs long-term performance). If None, no split is done.
)->Tuple[pd.DataFrame, pd.DataFrame]: # DataFrame containing overall performance metrics averaged across splits, and a DataFrame with predictions and true values for each split.

```

*Run cross-validation using time series splits.*

<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>DataFrame containing the target and any feature columns.</td>
</tr>
<tr>
<td>cv_split</td>
<td>int</td>
<td></td>
<td>Number of cross-validation splits.</td>
</tr>
<tr>
<td>metrics</td>
<td>List[Callable]</td>
<td></td>
<td>Metric functions (e.g. <code>[MAE, RMSE]</code>) used to evaluate
forecast accuracy across folds. Call <code>.cv_summary()</code> after
cross-validation to retrieve the aggregated scores.</td>
</tr>
<tr>
<td>step_size</td>
<td>int</td>
<td>1</td>
<td>Step size to move the test window forward in each split.</td>
</tr>
<tr>
<td>h_split_point</td>
<td>Optional[int]</td>
<td>None</td>
<td>Optional index to split the test set into two parts for separate
evaluation (e.g. to evaluate short-term vs long-term performance). If
None, no split is done.</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>Tuple[pd.DataFrame, pd.DataFrame]</strong></td>
<td></td>
<td><strong>DataFrame containing overall performance metrics averaged
across splits, and a DataFrame with predictions and true values for each
split.</strong></td>
</tr>
</tbody>
</table>
