Spaces:
Sleeping
Sleeping
gauravlochab
commited on
Commit
·
bc42514
1
Parent(s):
ba83473
fix: set fixed y-axis range and filter out agent with high APR values
Browse files
app.py
CHANGED
|
@@ -593,9 +593,14 @@ def create_combined_time_series_graph(df):
|
|
| 593 |
# Create Plotly figure in a clean state
|
| 594 |
fig = go.Figure()
|
| 595 |
|
| 596 |
-
#
|
| 597 |
-
|
| 598 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 599 |
|
| 600 |
# Add background shapes for APR and Performance regions
|
| 601 |
min_time = df['timestamp'].min()
|
|
@@ -630,9 +635,21 @@ def create_combined_time_series_graph(df):
|
|
| 630 |
)
|
| 631 |
|
| 632 |
# MODIFIED: Calculate average APR values across all agents for each timestamp
|
| 633 |
-
# Filter for APR data only
|
| 634 |
apr_data = df[df['metric_type'] == 'APR'].copy()
|
| 635 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 636 |
# Group by timestamp and calculate mean APR
|
| 637 |
avg_apr_data = apr_data.groupby('timestamp')['apr'].mean().reset_index()
|
| 638 |
|
|
@@ -823,15 +840,17 @@ def create_combined_time_series_graph(df):
|
|
| 823 |
align="center"
|
| 824 |
)
|
| 825 |
|
| 826 |
-
#
|
|
|
|
|
|
|
| 827 |
fig.update_yaxes(
|
| 828 |
showgrid=True,
|
| 829 |
gridwidth=1,
|
| 830 |
gridcolor='rgba(0,0,0,0.1)',
|
| 831 |
-
range=[min_apr, max_apr], # Updated range
|
| 832 |
tickmode='linear',
|
| 833 |
tick0=0,
|
| 834 |
-
dtick=
|
| 835 |
)
|
| 836 |
|
| 837 |
# Update x-axis
|
|
@@ -979,12 +998,17 @@ def create_combined_time_series_graph(df):
|
|
| 979 |
)
|
| 980 |
)
|
| 981 |
|
| 982 |
-
# Simplified layout
|
| 983 |
simple_fig.update_layout(
|
| 984 |
title="Average APR Values Across All Agents",
|
| 985 |
xaxis_title="Time",
|
| 986 |
yaxis_title="Value",
|
| 987 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 988 |
height=600,
|
| 989 |
width=1000
|
| 990 |
)
|
|
|
|
| 593 |
# Create Plotly figure in a clean state
|
| 594 |
fig = go.Figure()
|
| 595 |
|
| 596 |
+
# FORCE FIXED Y-AXIS RANGE based on the known data range
|
| 597 |
+
# Set explicit fixed values that will show the data clearly
|
| 598 |
+
min_apr = -40 # Bottom of the range
|
| 599 |
+
max_apr = -10 # Top of the range
|
| 600 |
+
|
| 601 |
+
logger.info(f"Using fixed y-axis range: [{min_apr}, {max_apr}]")
|
| 602 |
+
|
| 603 |
+
logger.info(f"Setting y-axis range to [{min_apr:.2f}, {max_apr:.2f}] based on filtered data")
|
| 604 |
|
| 605 |
# Add background shapes for APR and Performance regions
|
| 606 |
min_time = df['timestamp'].min()
|
|
|
|
| 635 |
)
|
| 636 |
|
| 637 |
# MODIFIED: Calculate average APR values across all agents for each timestamp
|
| 638 |
+
# Filter for APR data only and exclude the problematic agent
|
| 639 |
apr_data = df[df['metric_type'] == 'APR'].copy()
|
| 640 |
|
| 641 |
+
# Filter out the agent with abnormally high APR values
|
| 642 |
+
agent_to_exclude = "rimyi-kilus56"
|
| 643 |
+
apr_data_filtered = apr_data[apr_data['agent_name'] != agent_to_exclude].copy()
|
| 644 |
+
|
| 645 |
+
# Log the filtering
|
| 646 |
+
if len(apr_data) != len(apr_data_filtered):
|
| 647 |
+
excluded_count = len(apr_data) - len(apr_data_filtered)
|
| 648 |
+
logger.info(f"Excluded {excluded_count} data points from agent '{agent_to_exclude}' due to abnormally high APR values")
|
| 649 |
+
|
| 650 |
+
# Use the filtered data for all subsequent operations
|
| 651 |
+
apr_data = apr_data_filtered
|
| 652 |
+
|
| 653 |
# Group by timestamp and calculate mean APR
|
| 654 |
avg_apr_data = apr_data.groupby('timestamp')['apr'].mean().reset_index()
|
| 655 |
|
|
|
|
| 840 |
align="center"
|
| 841 |
)
|
| 842 |
|
| 843 |
+
# Use fixed tick spacing for clarity
|
| 844 |
+
dtick = 5 # 5-unit ticks for better readability
|
| 845 |
+
|
| 846 |
fig.update_yaxes(
|
| 847 |
showgrid=True,
|
| 848 |
gridwidth=1,
|
| 849 |
gridcolor='rgba(0,0,0,0.1)',
|
| 850 |
+
range=[min_apr, max_apr], # Updated range based on filtered data
|
| 851 |
tickmode='linear',
|
| 852 |
tick0=0,
|
| 853 |
+
dtick=dtick
|
| 854 |
)
|
| 855 |
|
| 856 |
# Update x-axis
|
|
|
|
| 998 |
)
|
| 999 |
)
|
| 1000 |
|
| 1001 |
+
# Simplified layout with adjusted y-axis range
|
| 1002 |
simple_fig.update_layout(
|
| 1003 |
title="Average APR Values Across All Agents",
|
| 1004 |
xaxis_title="Time",
|
| 1005 |
yaxis_title="Value",
|
| 1006 |
+
yaxis=dict(
|
| 1007 |
+
range=[-40, -10], # Fixed range to match the main graph
|
| 1008 |
+
tickmode='linear',
|
| 1009 |
+
tick0=0,
|
| 1010 |
+
dtick=5
|
| 1011 |
+
),
|
| 1012 |
height=600,
|
| 1013 |
width=1000
|
| 1014 |
)
|