MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / apply_time_decay

Function apply_time_decay

skills/profile-updater/scripts/update_profile.py:780–808  ·  view source on GitHub ↗

Apply exponential time decay to scalar weights. Args: weights: Weight mapping days_inactive: Inactive days decay_rate: Daily decay rate minimum_weight: Floor Returns: Decayed mapping

(
    weights: Dict[str, float],
    days_inactive: int,
    decay_rate: float = 0.01,
    minimum_weight: float = 0.1,
)

Source from the content-addressed store, hash-verified

778
779
780def apply_time_decay(
781 weights: Dict[str, float],
782 days_inactive: int,
783 decay_rate: float = 0.01,
784 minimum_weight: float = 0.1,
785) -> Dict[str, float]:
786 """
787 Apply exponential time decay to scalar weights.
788
789 Args:
790 weights: Weight mapping
791 days_inactive: Inactive days
792 decay_rate: Daily decay rate
793 minimum_weight: Floor
794
795 Returns:
796 Decayed mapping
797 """
798 if days_inactive <= 0:
799 return {
800 topic: float(weight)
801 for topic, weight in weights.items()
802 }
803
804 decayed: Dict[str, float] = {}
805 for topic, weight in weights.items():
806 value = float(weight) * ((1 - decay_rate) ** days_inactive)
807 decayed[topic] = max(minimum_weight, value)
808 return decayed
809
810
811def _apply_selective_decay(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected