o3-2025-04-16· OpenAI
LMArena Human Preference 140K
Untitled conversation
- User
import pandas as pd import matplotlib.pyplot as plt import numpy as np # Load the TSV file df = pd.read_csv('average_deltas_by_box-50-5percentile-positive.tsv', sep='\t') # Get the delta columns delta_cols = [col for col in df.columns if col.startswith('delta')] # Extract delta values from column names (e.g., 'delta10' -> 10) delta_values = [] for col in delta_cols: delta_val = float(col.replace('delta', '')) delta_values.append(delta_val) # Prepare for plotting plt.figure(figsize=(12, 8)) # Generate colors for each box using 'gist_rainbow' # Adjust linspace slightly to avoid extreme ends if necessary, though 'gist_rainbow' is less sensitive num_boxes = len(df) colors = plt.cm.get_cmap('gist_rainbow', num_boxes) # Use get_cmap for specific colormaps, directly provide num_colors # Plot each box as a line for i, row in df.iterrows(): # Use f-string to create a clear label for the legend box_label = f"Box [{row['box_start']:.2f}, {row['box_end']:.2f})" y_values = [row[col] for col in delta_cols] plt.plot(delta_values, y_values, label=box_label, color=colors(i), marker='o', markersize=4, linestyle='-') # Added markersize # Add labels, title, and grid plt.xlabel('Delta') plt.ylabel('Average Value') plt.title('Average Values by Delta for Each Box') plt.grid(True) # Position the legend outside the plot on the right side with 2 columns # Adjust bbox_to_anchor and right margin slightly if needed based on the number of labels plt.legend(bbox_to_anchor=(1.02, 0.5), loc='center left', ncol=2, fontsize='small') # Adjust layout to make room for the legend plt.tight_layout() plt.subplots_adjust(right=0.75) # This value might need slight tweaking depending on the number of boxes/labels # Save the plot plt.savefig('boxes_as_lines_plot_improved_colors.png', bbox_inches='tight') plt.show() print(f"Plot saved as 'boxes_as_lines_plot_improved_colors.png' with {len(df)} box lines and improved color distinction.")When delta0 occurs before delta-10 it draws weird lines. Make it so it sorts it before plotting.
- Assistant
Sure thing—just sort the “delta-columns” numerically once, then reuse that same, sorted ordering everywhere (x-axis ticks and y-values).
Drop-in replacement below:import pandas as pd import matplotlib.pyplot as plt import numpy as np import re # <-- tiny helper # --- Load -------------------------------------------------------------------- df = pd.read_csv('average_deltas_by_box-50-5percentile-positive.tsv', sep='\t') # --- Collect and sort the delta columns -------------------------------------- # Grab every column that starts with 'delta' delta_cols = [c for c in df.columns if c.startswith('delta')] # Build (numeric_delta, column_name) pairs and sort them by the numeric part delta_pairs = sorted( [(float(re.sub(r'^delta', '', c)), c) for c in delta_cols], key=lambda x: x[0] ) # Split them back apart delta_values = [d for d, _ in delta_pairs] # x-axis, already sorted delta_cols_sorted = [c for _, c in delta_pairs] # column names in that same order # --- Plot -------------------------------------------------------------------- plt.figure(figsize=(12, 8)) num_boxes = len(df) colors = plt.cm.get_cmap('gist_rainbow', num_boxes) for i, row in df.iterrows(): box_label = f"Box [{row['box_start']:.2f}, {row['box_end']:.2f})" y_values = row[delta_cols_sorted].values # values follow the same order plt.plot(delta_values, y_values, label=box_label, color=colors(i), marker='o', markersize=4, linestyle='-') plt.xlabel('Delta') plt.ylabel('Average Value') plt.title('Average Values by Delta for Each Box') plt.grid(True) # Legend on the right plt.legend(bbox_to_anchor=(1.02, 0.5), loc='center left', ncol=2, fontsize='small') plt.tight_layout() plt.subplots_adjust(right=0.75) plt.savefig('boxes_as_lines_plot_improved_colors.png', bbox_inches='tight') plt.show() print(f"Plot saved as 'boxes_as_lines_plot_improved_colors.png' with {len(df)} box lines and sorted deltas.")What changed?
- We create
delta_pairs = [(numeric_value, column_name), …]. sorted(…)arranges them from most negative to most positive (-10, -5, …, 0, 5, 10, etc.).- Both
delta_values(x-axis) anddelta_cols_sorted(y data) now obey that order, so the plotted lines are drawn left-to-right correctly—no more zig-zagging across the figure.
That’s it—nice and tidy lines! 🎉
- We create
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.