sky-uk/anticipy

In model functions, cache costly, redundant operations

capelastegui opened this issue · 0 comments

While profiling performance, we found that some slow model functions have costly operations that depend only on the input data (as opposed to the model parameters), and are unnecessarily repeated in the fitting loop. We can use a cache to avoid this.

Example:

    def f_dummy_calendar(a_x, a_date, **kwargs):
        list_check_date = calendar.holidays(a_date.min(), a_date.max())
        return np.isin(a_date, list_check_date).astype(float)

The entire f_dummy_calendar (and other dummy functions) could be replaced by such a cache.