It doesn't work! Fix it!
- User
It doesn't work! Fix it!
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
It doesn't work! Fix it!
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
You're right! The issue is with how the bins are being created. Let me fix the code:
import pandas as pd
import numpy as np
df = pd.read_csv('deltacoverage-multi.tsv', sep='\t')
# Define percentiles: 0-85% in one box, then 85-87.5%, 87.5-90%, etc.
percentiles = [0, 85, 87.5, 90, 92.5, 95, 97.5, 100]
bins = [np.percentile(df['sliding_scores'], p) for p in percentiles]
# Make sure bins are unique (in case of ties at percentiles)
bins = sorted(list(set(bins)))
# Replace first and last with -inf and inf to catch all values
bins[0] = -np.inf
bins[-1] = np.inf
# Create labels based on the percentile ranges
labels = ['lowest_85']
for i in range(85, 100, 2):
if i < 97.5:
labels.append(f'percentile_{i}_{i+2.5}')
# Adjust labels to match the number of bins
labels = labels[:len(bins)-1]
# Apply the custom binning
df['box'] = pd.cut(df['sliding_scores'], bins=bins, labels=labels, right=False, include_lowest=True)
# Identify delta columns
delta_cols = [col for col in df.columns if col.startswith('delta')]
# Group by box and calculate mean of delta columns
grouped_df = df.groupby('box')[delta_cols].mean()
grouped_df['delta0'] = 0
# Reset index
grouped_df = grouped_df.reset_index()
# Add box boundaries
box_mapping = {label: (bins[i], bins[i+1]) for i, label in enumerate(labels)}
grouped_df['box_start'] = grouped_df['box'].apply(lambda x: box_mapping[x][0])
grouped_df['box_end'] = grouped_df['box'].apply(lambda x: box_mapping[x][1])
# Handle -np.inf and np.inf in box boundaries
grouped_df['box_start'] = grouped_df['box_start'].replace({-np.inf: '-inf', np.inf: 'inf'})
grouped_df['box_end'] = grouped_df['box_end'].replace({-np.inf: '-inf', np.inf: 'inf'})
# Define output columns and save to file
output_cols = ['box_start', 'box_end'] + delta_cols + ['delta0']
output_df = grouped_df[output_cols]
output_filename = 'average_deltas_by_box-85-2.5percentile.tsv'
output_df.to_csv(output_filename, sep='\t', index=False)
print(f"Saved {len(output_df)} rows to {output_filename}")
The main fixes:
Simplified bin creation: Created bins directly from the percentile values [0, 85, 87.5, 90, 92.5, 95, 97.5, 100].
Handled duplicate values: Used set() to remove any duplicate bin edges that might occur if multiple percentiles have the same value.
Fixed label creation: Created labels that match the actual number of bins created.
Better boundary mapping: Created a dictionary to map each label to its corresponding bin boundaries, making it easier to extract the start and end values.
Included delta0 in output: Added 'delta0' to the output columns to match the original code's behavior.
This should now correctly group the lowest 85% into one box and create separate boxes for each 2.5% interval above that.