Jelajahi Sumber

Initial commit

zhusc 5 bulan lalu
induk
melakukan
53d895f264

+ 1 - 1
user_events/analyze/DetectAnomalies.py

@@ -22,7 +22,7 @@ class AnomalyDetector:
 
         anomalies = []
         for user, count in user_behavior_count.items():
-            if count > 20:  # 假设行为次数超过20为异常
+            if count > 4:  # 假设行为次数超过4为异常
                 anomalies.append(user)
 
         return anomalies

+ 1 - 1
user_events/analyze/SegmentUsers.py

@@ -22,7 +22,7 @@ class UserSegmentation:
 
         segments = {'高活跃用户': [], '低活跃用户': []}
         for user, count in user_behavior_count.items():
-            if count > 5:
+            if count > 3:
                 segments['高活跃用户'].append(user)
             else:
                 segments['低活跃用户'].append(user)

+ 1 - 1
user_events/main.py

@@ -49,7 +49,7 @@ def main():
 
     # 实时监控
     monitor = Monitor.RealTimeMonitor(processed_data)
-    print("\nStarting real-time monitoring...")
+    print("\n开始实时监控...")
     monitor.monitor()
 
 

+ 12 - 11
user_events/monitor/GenerateReport.py

@@ -35,24 +35,25 @@ class ReportGenerator:
         }
 
         # 打印报告摘要
-        print("Report Summary:")
-        print(f"Total Users: {report['total_users']}")
-        print(f"Total Actions: {report['total_actions']}")
-        print(f"Anomalies: {report['anomalies']}")
-        print(f"User Segments: {report['user_segments']}")
+        print("报告摘要:")
+        print(f"总客户数: {report['total_users']}")
+        print(f"总行为次数: {report['total_actions']}")
+        print(f"异常客户: {report['anomalies']}")
+        print(f"客户分群-高活跃用户: {report['user_segments']['高活跃用户']},")
+        print(f"客户分群-低活跃用户: {report['user_segments']['低活跃用户']},")
 
         # 展示每个流程的行为次数漏斗图
         for process, actions in self.process_stats.items():
-            self.plot_bar(actions, f"{process} Funnel")
+            self.plot_bar(actions, f"{process} 漏斗图")
 
         # 展示行为统计图表
-        self.plot_stats(self.action_stats, "Action Statistics")
+        self.plot_stats(self.action_stats, "行为次数统计")
 
         # 展示产品统计图表
-        self.plot_stats(self.product_stats, "Product Statistics")
+        self.plot_stats(self.product_stats, "分产品统计")
 
         # 展示渠道统计图表
-        self.plot_stats(self.channel_stats, "Channel Statistics")
+        self.plot_stats(self.channel_stats, "分渠道统计")
 
         return report
 
@@ -90,8 +91,8 @@ class ReportGenerator:
         # 设置横坐标和纵坐标
         ax.set_yticks(positions)
         ax.set_yticklabels(labels)
-        ax.set_xlabel('Number of Actions')
-        ax.set_ylabel('Behavior')
+        ax.set_xlabel('行为次数')
+        ax.set_ylabel('')
 
         ax.set_title(title)
 

+ 1 - 1
user_events/monitor/Monitor.py

@@ -19,4 +19,4 @@ class RealTimeMonitor:
             actions = user_actions['actions']
             product = user_actions['product']
             channel = user_actions['channel']
-            print(f"User: {user}, Process: {process}, Product: {product}, Channel: {channel}, Actions: {actions}")
+            print(f"用户: {user}, 流程类型: {process}, 产品: {product}, 渠道: {channel}, 行为序列: {actions}")