cleverly.assessment.AssessmentCache#
- class cleverly.assessment.AssessmentCache(*args: Any, **kwargs: Any)[source]#
The assessment answers a result keeps, with an optional byte budget.
A plain mapping from a key (the operation and its normalized arguments) to the answer. With no budget, the default, every answer is kept for the life of the result and saved with it, as a mapping without this class would.
Some answers can be computed again exactly from the result’s stored artifacts: the support, nuisance and score diagnostics, the stored-artifact validation, the omitted-confounder elements and bounds, the E-value and the combined reports that hold them. Only those are evictable. An answer that refits nuisance models, draws a fresh random seed, fits a learner or runs a parallel section is pinned, because computing it again could give different numbers; neither a budget nor
evict()removes it. A dropped answer is computed again, bit for bit the same, the next time it is asked for.- Parameters:
- Attributes:
Notes
The byte count walks each answer: arrays by their buffers, Python objects by their sizes. It stops at fitted learners, estimators, data containers and results, and counts an array an answer shares with the fitted result, so it can exceed what dropping the answer frees; the budget then drops answers early rather than keep more than it says.
clear(),delandpopremove pinned answers too: a repeated unseeded refit then draws a new seed, as it always has after its answer is removed.
Methods#
- AssessmentCache.copy() AssessmentCache[source]#
Return a copy with the same entries, budget and evictable keys.
- Returns:
AssessmentCacheThe copy, sharing the answers and no bookkeeping.
- AssessmentCache.evict() int[source]#
Drop every evictable answer, whatever the budget.
- Returns:
intThe counted bytes of the dropped answers.
- AssessmentCache.info() tuple[CacheEntry, ...][source]#
Describe each filed answer, in the order the answers were filed.
- Returns:
tupleofCacheEntryOne record per answer: its key, operation, counted bytes and whether a budget may drop it.
Attributes#
- AssessmentCache.max_bytes#
The budget on the whole cache, in bytes, or
Nonefor no budget (the default).A positive integer bounds
nbytes, pinned answers included: after each filing, and at once when it is set, evictable answers are dropped, least recently used first, until the total fits or no evictable answer is left. Pinned answers alone can exceed it. It is not a memory guard:Nonemeans no budget, not the memory available now.
- AssessmentCache.nbytes#
The bytes the filed answers are counted at.