https://github.com/nixtla logo
#mlforecast
Title
# mlforecast
i

Isaac

08/08/2023, 8:30 PM
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

José Morales

08/08/2023, 9:17 PM
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

Isaac

08/09/2023, 3:48 PM
Gotcha. That makes sense. Shouldn't there be an option to dropna or fillna built into predict like it is in fit?
j

José Morales

08/09/2023, 3:51 PM
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

Isaac

08/09/2023, 3:54 PM
Ah. I guess it makes sense to just fill NA instead of dropping.