I'm having somme issues using MLForecast with skle...
# mlforecast
i
I'm having somme issues using MLForecast with sklearn models. I'm using monthly data over 3 years with lags of range(1, 7) which causes NA data.
MLForecast.fit
handles dropping the NA data without issue (with the dropna param), but
MLForecast.predict
runs an error with the underlying sklearn models. Am I doing something incorrectly?
j
Hey. You have to handle these null values in some way. For example, if you want to fill them with zeros you can use the before_predict_callback argument of predict and pass a function like:
Copy code
def fill_with_zeros(df):
   return df.fillna(0)
1
Also you can avoid the nulls entirely by using less lags or removing the shorter series (you currently have at least one serie with less than 6 values)
i
Gotcha. That makes sense. Shouldn't there be an option to dropna or fillna built into predict like it is in fit?
j
If you drop the nulls in the predict you'd end up with series without predictions. If that's what you want it's probably better to drop them from the start. We're going to add an option soon to only predict a subset, that'll allow you to only predict the ones with the minimum required length and train including the shorter ones
i
Ah. I guess it makes sense to just fill NA instead of dropping.