Brian Head
10/04/2023, 7:07 PMforecast_fitted_values
. It works as expected when there is no transformation (I've used the built-in LocalStarndardScaler
and also logged the y (which I can exponentiate later). Both of those approaches also work fine with cross_validation
. However, when I do the below...
import pandas as pd
from datasetsforecast.m3 import M3
import mlforecast
from mlforecast import MLForecast
from mlforecast.target_transforms import Differences, LocalStandardScaler
from mlforecast.utils import PredictionIntervals
import numpy as np
from numba import njit
import lightgbm as lgb
import xgboost as xgb
from window_ops.expanding import expanding_mean
from window_ops.ewm import ewm_mean
from window_ops.rolling import rolling_mean, seasonal_rolling_mean,rolling_min, rolling_max, rolling_std
Y_df, *_ = M3.load('./data', group='Yearly')
Y_df['y'] = np.log(Y_df['y']) #toggle on/off depending on which option I'm using
ML_models = [
lgb.LGBMRegressor(n_jobs=6, random_state=0, verbosity=-1),
xgb.XGBRegressor(n_jobs=6, random_state=0, eta=0.35)
]
mlf = MLForecast(
models = ML_models,
freq = 'M',
lags=range(1, 3),
date_features=['year','month','quarter','days_in_month'],
target_transforms=[Differences([1,3])], LocalStandardScaler(), #toggle between having standardscaler and not depending on if I log y myself
num_threads=6
)
forecasts_ml_df = mlf.fit(df=Y_df, fitted=True)
forecasts_ml_df_fits = forecasts_ml_df.forecast_fitted_values()
the resulting predictions appear to still be scaled. Interestingly, when log the y myself (removing the LocalStandardScaler) I still get odd values that look scaled somehow.
If I don't use the localStandardScaler or logging the values make sense (don't look scaled).
Any ideas what might be causing this?