# -*- coding: utf-8 -*- """ @author: zsc @time: 2024/11/18 @desc: 行为分析 """ # 异常检测模块 class AnomalyDetector: def __init__(self, behavior_data): self.behavior_data = behavior_data def detect(self): # 识别异常行为 anomalies = [] for user, actions in self.behavior_data.items(): if 'purchase' in actions and actions['purchase'] > 5: anomalies.append(user) return anomalies