Skip to content

ENH: low memory cache cache_readonly #4681

Open

Description

@josef-pkt

related #2113 memory footprint

To cache or not to cache?

GenericLikelihoodModelResults caches score_obs, but score_obs could be pretty large

    @cache_readonly
    def score_obsv(self):
        """cached Jacobian of log-likelihood
        """
        return self.model.score_obs(self.params)

In general we have to decide when adding a lazy attribute whether to cache it or not, e.g. GLM caches all residual types. This has the trade-off between speed and memory, which will be different for small and large datasets.

One possibility: make caching of some intermediate results optional.
E,g. add a flag/attribute memory_low=True to reduce caching and recompute on repeated use.
Or use an attribute that allows more levels, memory_usage='low' 'medium' 'high' 'ultra-low'
(where ultra-low could be out of memory or working in patches as much as possible)
Current would be approximately medium

This would require that the cache decorator works conditional on this flag.

Activity

  1. added this to the 0.10 milestone on May 22, 2018
  2. josef-pkt commented on May 22, 2018

    @josef-pkt
    MemberAuthor

    related: public option to remove items from cache #2417

  3. jbrockmendel commented on May 22, 2018

    @jbrockmendel
    Contributor

    Related #4408 to distinguish between light and heavyweight entries (and inprove remove_data)

  4. josef-pkt commented on May 22, 2018

    @josef-pkt
    MemberAuthor

    Did you really mean 4408 on multiple testing p-value corrections?
    I don't see a connection.

  5. jbrockmendel commented on May 22, 2018

    @jbrockmendel
    Contributor

    Typing with thumbs, try #4421

  6. modified the milestones: 0.10, 0.14 on Aug 28, 2021
  7. josef-pkt commented on Aug 28, 2021

    @josef-pkt
    MemberAuthor

    bump for another look

    in betareg and similar me might want to cache distribution args and some predicted arrays that are not fittedvalues (i.e. predicted/conditional mean)
    example Weibull or other distributions where mean is not a distribution parameter. (mean or median can be computed based on get_distribution)

    caching is convenient for interactive work with small or medium sized datasets, but not for large datasets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions