MMM.create_fit_data#
- MMM.create_fit_data(X, y)[source]#
Create a fit dataset aligned on date and present dimensions.
Builds and returns an xarray
Dataset
that contains:data variables from
X
(all non-coordinate columns),the target variable from
y
underself.output_var
, andcoordinates on
(self.date_column, *dims present in X)
.
- Parameters:
- X
pd.DataFrame
|xr.Dataset
|xr.DataArray
Feature data. If an xarray object is provided, it is converted to a DataFrame via
to_dataframe().reset_index()
before processing.- y
np.ndarray
|pd.Series
|xr.DataArray
Target values. Must align with
X
either by position (same length) or via a MultiIndex that includes(self.date_column, *dims present in X)
.
- X
- Returns:
xr.Dataset
Dataset indexed by
(self.date_column, *dims present in X)
with the feature variables and a target variable namedself.output_var
.
- Raises:
ValueError
If
self.date_column
is missing inX
.If
y
is anp.ndarray
and its length does not matchX
.If
y
cannot be aligned toX
by index or position.
RuntimeError
If the target column is missing after alignment.
Notes
The original date column name is preserved (
self.date_column
).Coordinates are assigned only for dimensions present in
X
.Data is sorted by
(self.date_column, *dims present in X)
prior to conversion to xarray.
Examples
>>> ds = mmm.create_fit_data(X, y)