skforecast
skforecast copied to clipboard
consider improve the efficiency maybe?
The functionality of the package is mostly satisfying, but with all due respect, when i compare the performance of skforecast with the model i develop by myself, i found it much slower to use the framework. Once i dive deep into the source code, it comes out that the efficiency problem needs some focus. For example, the _create_lags
function may be improved as:
def _create_lags(self, y: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
n_splits = len(y) - self.max_lag
if n_splits <= 0:
raise Exception(
"max lag must be less than the length of the series."
)
X_data = np.full(shape=(n_splits, len(self.lags)), fill_value=np.nan, dtype=float)
i = 0
for lag in self.lags:
X_data[:, i] = y[self.max_lag - lag: -lag]
i += 1
y_data = y[self.max_lag:]
return X_data, y_data
And i'm sure there is a lot to do about performance optimization, expecting a brand-new version with both satisfying features and speed!
Hi @Bennett561 thanks a lot for the suggestion. Yes, there are many potential optimizations. Could you give some more details about the benchmark you have done? Length of the serie, number of lags, regressor used and time required for training.
Thanks
Hi @Bennett561, we have refactored _create_lags_
in ForecasterAutoreg and ForecasterAutoregMultiSeries with your input. We have mentioned you in the changelog. Thank you!