Skip to content

Commit d7c3a92

Browse files
committed
Minor viz changes
1 parent f2debb3 commit d7c3a92

3 files changed

Lines changed: 30 additions & 14 deletions

File tree

codeclash/analysis/multiplayer/win_change_rate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def analyze_win_change_rate(log_dir: Path, game_pattern: str = "CoreWar.r15.s100
125125
ax1.set_xlabel("Number of Lead Changes per Tournament", fontsize=18, fontproperties=FONT_BOLD)
126126
ax1.set_ylabel("Frequency", fontsize=18, fontproperties=FONT_BOLD)
127127
ax1.tick_params(axis="both", labelsize=14)
128-
ax1.legend(prop=FONT_BOLD, fontsize=12)
128+
FONT_BOLD.set_size(16)
129+
ax1.legend(prop=FONT_BOLD)
129130
ax1.grid(alpha=0.3)
130131

131132
# Plot 2: Change rates comparison
@@ -142,7 +143,8 @@ def analyze_win_change_rate(log_dir: Path, game_pattern: str = "CoreWar.r15.s100
142143
# Add mean markers
143144
for i, data in enumerate([change_rates_6p, change_rates_2p], 1):
144145
ax2.plot(i, np.mean(data), "D", color="darkred", markersize=8, label="Mean" if i == 1 else "")
145-
ax2.legend(prop=FONT_BOLD, fontsize=12)
146+
FONT_BOLD.set_size(16)
147+
ax2.legend(prop=FONT_BOLD)
146148

147149
# Set tick labels with custom font
148150
for label in ax2.get_xticklabels():

codeclash/analysis/multiplayer/win_share.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ def analyze_winner_share(log_dir: Path, game_pattern: str = "CoreWar.r15.s1000")
116116
ax1.set_xlabel("Winner's Share of Total Points (%)", fontsize=18, fontproperties=FONT_BOLD)
117117
ax1.set_ylabel("Frequency", fontsize=18, fontproperties=FONT_BOLD)
118118
ax1.tick_params(axis="both", labelsize=14)
119-
ax1.legend(prop=FONT_BOLD, fontsize=12)
119+
FONT_BOLD.set_size(16)
120+
ax1.legend(prop=FONT_BOLD)
120121
ax1.grid(alpha=0.3)
121122

122123
# Plot 2: Box plot comparison
@@ -133,7 +134,8 @@ def analyze_winner_share(log_dir: Path, game_pattern: str = "CoreWar.r15.s1000")
133134
# Add mean markers
134135
for i, data in enumerate([winner_shares_6p, winner_shares_2p], 1):
135136
ax2.plot(i, np.mean(data), "D", color="darkred", markersize=8, label="Mean" if i == 1 else "")
136-
ax2.legend(prop=FONT_BOLD, fontsize=12)
137+
FONT_BOLD.set_size(16)
138+
ax2.legend(prop=FONT_BOLD)
137139

138140
# Set tick labels with custom font
139141
for label in ax2.get_xticklabels():

codeclash/analysis/viz/scatter_codebase_organization.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ def analyze_per_player_arena(data: list, N: int = 5) -> pd.DataFrame:
227227
def analyze_per_player(data: list, N: int = 5) -> pd.DataFrame:
228228
df = analyze_per_player_arena(data, N=N)
229229
df = df[df["total_files"] > 0]
230-
return df.groupby("player")["active_file_ratio"].agg(["mean", "std"]).reset_index()
230+
result = df.groupby("player")["active_file_ratio"].agg(["mean", "std", "count"]).reset_index()
231+
# Calculate standard error of the mean (SEM)
232+
result["sem"] = result["std"] / (result["count"] ** 0.5)
233+
return result
231234

232235

233236
def calculate_root_clutter_ratio(file_history: dict) -> dict:
@@ -263,7 +266,10 @@ def analyze_root_clutter_per_player(data: list) -> pd.DataFrame:
263266

264267
df = pd.DataFrame(results)
265268
df = df[df["total_files"] > 0]
266-
return df.groupby("player")["root_clutter_ratio"].agg(["mean", "std"]).reset_index()
269+
result = df.groupby("player")["root_clutter_ratio"].agg(["mean", "std", "count"]).reset_index()
270+
# Calculate standard error of the mean (SEM)
271+
result["sem"] = result["std"] / (result["count"] ** 0.5)
272+
return result
267273

268274

269275
def calculate_churn_concentration(file_history: dict, use_magnitude: bool = False) -> dict:
@@ -324,7 +330,10 @@ def analyze_churn_concentration_per_player(data: list, use_magnitude: bool = Fal
324330

325331
df = pd.DataFrame(results)
326332
df = df[df["total_churn"] > 0]
327-
return df.groupby("player")["churn_concentration"].agg(["mean", "std"]).reset_index()
333+
result = df.groupby("player")["churn_concentration"].agg(["mean", "std", "count"]).reset_index()
334+
# Calculate standard error of the mean (SEM)
335+
result["sem"] = result["std"] / (result["count"] ** 0.5)
336+
return result
328337

329338

330339
def plot_organization_metrics(file_reuse_df: pd.DataFrame, root_clutter_df: pd.DataFrame):
@@ -355,8 +364,8 @@ def plot_organization_metrics(file_reuse_df: pd.DataFrame, root_clutter_df: pd.D
355364
plt.errorbar(
356365
row["mean_clutter"],
357366
row["mean_reuse"],
358-
xerr=row["std_clutter"],
359-
yerr=row["std_reuse"],
367+
xerr=row["sem_clutter"],
368+
yerr=row["sem_reuse"],
360369
fmt="none",
361370
ecolor=color,
362371
elinewidth=1.5,
@@ -472,7 +481,10 @@ def analyze_file_reuse_per_player(data: list) -> pd.DataFrame:
472481

473482
df = pd.DataFrame(results)
474483
df = df[df["total_files_created"] > 0]
475-
return df.groupby("player")["file_reuse_ratio"].agg(["mean", "std"]).reset_index()
484+
result = df.groupby("player")["file_reuse_ratio"].agg(["mean", "std", "count"]).reset_index()
485+
# Calculate standard error of the mean (SEM)
486+
result["sem"] = result["std"] / (result["count"] ** 0.5)
487+
return result
476488

477489

478490
def calculate_filename_redundancy(file_history: dict) -> dict:
@@ -542,10 +554,10 @@ def calculate_redundancy_over_rounds(file_history: dict) -> list:
542554

543555
def plot_filename_redundancy_over_rounds(redundancy_df: pd.DataFrame):
544556
"""Line plot showing filename redundancy over rounds per model.
545-
546-
- X: Round number
547-
- Y: Filename redundancy ratio (mean across tournaments)
548-
- One line per model, colored consistently
557+
sc
558+
- X: Round number
559+
- Y: Filename redundancy ratio (mean across tournaments)
560+
- One line per model, colored consistently
549561
"""
550562
# Aggregate by player and round (mean across all tournaments)
551563
agg_redundancy = (

0 commit comments

Comments
 (0)