reab5555 commited on
Commit
1d6cb38
·
verified ·
1 Parent(s): e8aec56

Update visualization.py

Browse files
Files changed (1) hide show
  1. visualization.py +1 -26
visualization.py CHANGED
@@ -70,7 +70,6 @@ def plot_mse(df, mse_values, title, color='navy', time_threshold=3, anomaly_thre
70
  ax.plot(segment_df['Seconds'], mean, color=color, linewidth=0.5)
71
  ax.fill_between(segment_df['Seconds'], mean - std, mean + std, color=color, alpha=0.1)
72
 
73
- # Rest of the function remains the same
74
  median = np.median(mse_values)
75
  ax.axhline(y=median, color='black', linestyle='--', label='Median Baseline')
76
 
@@ -88,32 +87,8 @@ def plot_mse(df, mse_values, title, color='navy', time_threshold=3, anomaly_thre
88
  mse_values[anomalies]))
89
  anomaly_data.sort(key=lambda x: x[1])
90
 
91
- grouped_anomalies = []
92
- current_group = []
93
- for timecode, sec, mse in anomaly_data:
94
- if not current_group or sec - current_group[-1][1] <= time_threshold:
95
- current_group.append((timecode, sec, mse))
96
- else:
97
- grouped_anomalies.append(current_group)
98
- current_group = [(timecode, sec, mse)]
99
- if current_group:
100
- grouped_anomalies.append(current_group)
101
-
102
- for group in grouped_anomalies:
103
- start_sec = group[0][1]
104
- end_sec = group[-1][1]
105
- rect = Rectangle((start_sec, ax.get_ylim()[0]), end_sec - start_sec, ax.get_ylim()[1] - ax.get_ylim()[0],
106
- facecolor='red', alpha=0.2, zorder=1)
107
- ax.add_patch(rect)
108
-
109
- for group in grouped_anomalies:
110
- highest_mse_anomaly = max(group, key=lambda x: x[2])
111
- timecode, sec, mse = highest_mse_anomaly
112
- ax.annotate(timecode, (sec, mse), textcoords="offset points", xytext=(0, 10),
113
- ha='center', fontsize=6, color='red')
114
-
115
  max_seconds = df['Seconds'].max()
116
- num_ticks = 100
117
  tick_locations = np.linspace(0, max_seconds, num_ticks)
118
  tick_labels = [seconds_to_timecode(int(s)) for s in tick_locations]
119
 
 
70
  ax.plot(segment_df['Seconds'], mean, color=color, linewidth=0.5)
71
  ax.fill_between(segment_df['Seconds'], mean - std, mean + std, color=color, alpha=0.1)
72
 
 
73
  median = np.median(mse_values)
74
  ax.axhline(y=median, color='black', linestyle='--', label='Median Baseline')
75
 
 
87
  mse_values[anomalies]))
88
  anomaly_data.sort(key=lambda x: x[1])
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  max_seconds = df['Seconds'].max()
91
+ num_ticks = 80
92
  tick_locations = np.linspace(0, max_seconds, num_ticks)
93
  tick_labels = [seconds_to_timecode(int(s)) for s in tick_locations]
94