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
Datasetthat contains:data variables from
X(all non-coordinate columns),the target variable from
yunderself.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
Xeither by position (same length) or via a MultiIndex that includes(self.date_column, *dims present in X).
- X
- Returns:
xr.DatasetDataset indexed by
(self.date_column, *dims present in X)with the feature variables and a target variable namedself.output_var.
- Raises:
ValueErrorIf
self.date_columnis missing inX.If
yis anp.ndarrayand its length does not matchX.If
ycannot be aligned toXby index or position.
RuntimeErrorIf 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)