-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcomprehensive_rejection_analysis.py
More file actions
805 lines (607 loc) · 33.9 KB
/
comprehensive_rejection_analysis.py
File metadata and controls
805 lines (607 loc) · 33.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
#!/usr/bin/env python3
"""
Comprehensive analysis of bid rejection and hire rejection reasons
"""
import json
from collections import Counter, defaultdict
import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path
def extract_themes(reasons_list):
"""Extract common themes from rejection/feedback reasons"""
theme_keywords = {
'skill_mismatch': ['skill', 'experience', 'expertise', 'qualifications', 'background'],
'communication': ['message', 'communication', 'understanding', 'proposal', 'pitch'],
'competition': ['better', 'stronger', 'more', 'competitive', 'other'],
'rate_budget': ['rate', 'budget', 'cost', 'price', 'expensive'],
'fit': ['fit', 'match', 'align', 'suitable', 'appropriate']
}
theme_counts = defaultdict(int)
for reason in reasons_list:
reason_lower = reason.lower()
for theme, keywords in theme_keywords.items():
if any(keyword in reason_lower for keyword in keywords):
theme_counts[theme] += 1
return theme_counts
def print_data_overview(simulation_data, experiment_name):
"""Print overview of simulation data"""
hiring_outcomes = simulation_data.get('hiring_outcomes', [])
all_bids = simulation_data.get('all_bids', [])
all_jobs = simulation_data.get('all_jobs', [])
freelancers = simulation_data.get('freelancer_profiles', {})
config = simulation_data.get('simulation_config', {})
print(f"📊 Loaded simulation data for {experiment_name}")
print("📈 Data Overview:")
print(f" - Hiring outcomes: {len(hiring_outcomes)}")
print(f" - Total bids: {len(all_bids)}")
print(f" - Total jobs: {len(all_jobs)}")
print(f" - Freelancers: {len(freelancers)}")
print(f" - Freelancer Agent Type: {config.get('freelancer_agent_type', 'N/A')}")
print(f" - Client Agent Type: {config.get('client_agent_type', 'N/A')}")
print("\n🔄 ANALYZING ALL REJECTION DIRECTIONS:")
print(" 1. Client rejections of freelancer bids")
print(" 2. Freelancer rejections of job opportunities")
print(" 3. Client feedback to freelancers about rejected bids")
def _categorize_hiring_outcome(outcome):
"""Categorize a single hiring outcome into hired, rejected, or no-bid"""
selected = outcome.get('selected_freelancer')
reasoning = outcome.get('reasoning', '')
outcome_data = {'selected': selected, 'reasoning': reasoning}
if selected and selected != 'none' and selected is not None:
return 'hired', outcome_data
elif selected == 'none' or selected is None:
if 'no bid' in reasoning.lower() or 'no bids' in reasoning.lower():
return 'no_bid', outcome_data
else:
return 'rejected', outcome_data
else:
return 'no_bid', outcome_data
def _categorize_all_outcomes(hiring_outcomes):
"""Categorize all hiring outcomes"""
hired_outcomes = []
client_rejected_outcomes = []
no_bid_outcomes = []
for outcome in hiring_outcomes:
category, outcome_data = _categorize_hiring_outcome(outcome)
if category == 'hired':
hired_outcomes.append(outcome_data)
elif category == 'rejected':
client_rejected_outcomes.append(outcome_data)
else: # no_bid
no_bid_outcomes.append(outcome_data)
return hired_outcomes, client_rejected_outcomes, no_bid_outcomes
def _print_outcome_summary(hired_outcomes, client_rejected_outcomes, no_bid_outcomes):
"""Print summary of outcome categorization"""
print(f" - Jobs with successful hires: {len(hired_outcomes)}")
print(f" - Jobs where client rejected all bids: {len(client_rejected_outcomes)}")
print(f" - Jobs with no bids received: {len(no_bid_outcomes)}")
def _print_rejection_patterns(client_rejection_reasons):
"""Print client rejection patterns"""
if client_rejection_reasons:
print("\n🚫 CLIENT REJECTION PATTERNS:")
print(f" Total client rejection decisions with reasoning: {len(client_rejection_reasons)}")
for i, reason in enumerate(client_rejection_reasons[:5], 1):
print(f" {i}. \"{reason[:120]}{'...' if len(reason) > 120 else ''}\"")
else:
print("\n🚫 CLIENT REJECTION PATTERNS: No explicit rejection reasoning found")
def analyze_client_rejections(hiring_outcomes):
"""Analyze client-side rejection patterns"""
print("\n🏢 CLIENT-SIDE REJECTION ANALYSIS:")
hired_outcomes, client_rejected_outcomes, no_bid_outcomes = _categorize_all_outcomes(hiring_outcomes)
_print_outcome_summary(hired_outcomes, client_rejected_outcomes, no_bid_outcomes)
client_rejection_reasons = [outcome['reasoning'] for outcome in client_rejected_outcomes if outcome['reasoning']]
_print_rejection_patterns(client_rejection_reasons)
return hired_outcomes, client_rejected_outcomes, client_rejection_reasons
def analyze_freelancer_rejections(all_decisions):
"""Analyze freelancer-side rejection patterns (choosing not to bid)"""
print("\n👥 FREELANCER-SIDE REJECTION ANALYSIS (freelancers choosing NOT to bid):")
freelancer_rejections = []
freelancer_bids = []
for decision in all_decisions:
if decision.get('decision') == 'no':
freelancer_rejections.append({
'freelancer_id': decision.get('freelancer_id'),
'freelancer_name': decision.get('freelancer_name'),
'job_id': decision.get('job_id'),
'job_title': decision.get('job_title'),
'reasoning': decision.get('reasoning', ''),
'round': decision.get('round')
})
elif decision.get('decision') == 'yes':
freelancer_bids.append(decision)
print(f" - Total freelancer decisions: {len(all_decisions)}")
print(f" - Freelancer rejections (chose not to bid): {len(freelancer_rejections)}")
print(f" - Freelancer bids (chose to bid): {len(freelancer_bids)}")
meaningful_rejections = [r for r in freelancer_rejections if r['reasoning'] and r['reasoning'].strip()]
print(f" - Freelancer rejections with detailed reasoning: {len(meaningful_rejections)}")
if meaningful_rejections:
print("\n📝 FREELANCER REJECTION REASONING SAMPLES:")
for i, rejection in enumerate(meaningful_rejections[:5], 1):
reasoning_text = rejection['reasoning'][:120] + ("..." if len(rejection['reasoning']) > 120 else "")
print(f"{i:2d}. Job: {rejection['job_title'][:50]}...")
print(f" Reasoning: {reasoning_text}")
freelancer_rejection_themes = extract_themes([r['reasoning'] for r in meaningful_rejections])
print_themes("FREELANCER REJECTION THEMES", freelancer_rejection_themes)
else:
print(" No detailed freelancer rejection reasoning found (expected for Random freelancers)")
freelancer_rejection_themes = {}
return meaningful_rejections, freelancer_rejection_themes
def _extract_feedback_reasons_from_freelancers(freelancers):
"""Extract feedback reasons from all freelancers"""
total_feedback_entries = 0
freelancer_feedback_reasons = []
for freelancer_id, freelancer in freelancers.items():
bid_feedback = freelancer.get('bid_feedback', [])
total_feedback_entries += len(bid_feedback)
for feedback in bid_feedback:
if isinstance(feedback, dict):
feedback_content = feedback.get('feedback', {})
if isinstance(feedback_content, dict):
main_reason = feedback_content.get('main_reason', '')
if main_reason:
freelancer_feedback_reasons.append(main_reason)
return total_feedback_entries, freelancer_feedback_reasons
def _print_feedback_summary(total_feedback_entries, freelancer_feedback_reasons):
"""Print summary of client feedback"""
print(f" - Total client feedback entries stored by freelancers: {total_feedback_entries}")
print(f" - Feedback with detailed reasons: {len(freelancer_feedback_reasons)}")
def _print_feedback_details(freelancer_feedback_reasons):
"""Print detailed client feedback with counts"""
print("\n📝 CLIENT FEEDBACK TO FREELANCERS:")
reason_counts = Counter(freelancer_feedback_reasons)
for i, (reason, count) in enumerate(reason_counts.most_common(5), 1):
percentage = (count / len(freelancer_feedback_reasons)) * 100
print(f"{i:2d}. {reason:<80} ({count:2d}, {percentage:4.1f}%)")
def analyze_client_feedback(freelancers):
"""Analyze client feedback to freelancers about rejected bids"""
print("\n📬 CLIENT FEEDBACK TO FREELANCERS (stored by freelancers about rejected bids):")
total_feedback_entries, freelancer_feedback_reasons = _extract_feedback_reasons_from_freelancers(freelancers)
_print_feedback_summary(total_feedback_entries, freelancer_feedback_reasons)
if freelancer_feedback_reasons:
_print_feedback_details(freelancer_feedback_reasons)
client_feedback_themes = extract_themes(freelancer_feedback_reasons)
print_themes("CLIENT FEEDBACK TO FREELANCERS THEMES", client_feedback_themes)
else:
print(" No detailed client feedback found (expected for Random freelancers)")
client_feedback_themes = {}
return total_feedback_entries, freelancer_feedback_reasons, client_feedback_themes
def analyze_successful_hires(hired_outcomes):
"""Analyze successful hiring reasons"""
hire_reasons = [outcome['reasoning'] for outcome in hired_outcomes if outcome['reasoning']]
if hire_reasons:
print("\n✅ TOP SUCCESSFUL HIRING REASONS:")
hire_reason_counts = Counter(hire_reasons)
for i, (reason, count) in enumerate(hire_reason_counts.most_common(10), 1):
percentage = (count / len(hire_reasons)) * 100
print(f"{i:2d}. {reason[:80]:<80} ({count:3d}, {percentage:4.1f}%)")
return hire_reasons
def analyze_job_fulfillment(all_jobs, all_bids, hired_outcomes):
"""Analyze job fulfillment metrics"""
jobs_with_bids = set()
for bid in all_bids:
jobs_with_bids.add(bid['job_id'])
total_jobs = len(all_jobs)
jobs_with_bids_count = len(jobs_with_bids)
jobs_without_bids = total_jobs - jobs_with_bids_count
print("\n📊 JOB FULFILLMENT ANALYSIS:")
print(f" - Total jobs posted: {total_jobs}")
print(f" - Jobs that received bids: {jobs_with_bids_count}")
print(f" - Jobs with no bids: {jobs_without_bids}")
print(f" - Jobs with successful hires: {len(hired_outcomes)}")
if jobs_with_bids_count > 0:
print(f" - Bid-to-hire conversion rate: {len(hired_outcomes)/jobs_with_bids_count*100:.1f}%")
return jobs_with_bids_count
def print_themes(title, themes):
"""Print theme breakdown"""
print(f"\n🔍 {title}:")
total_themes = sum(themes.values())
for theme, count in sorted(themes.items(), key=lambda x: x[1], reverse=True):
percentage = (count / total_themes) * 100 if total_themes > 0 else 0
print(f" - {theme.replace('_', ' ').title()}: {count} ({percentage:.1f}%)")
def create_pie_chart(data, title, filename, colors=None):
"""Create a professional pie chart for paper figures"""
if not data:
print(f"No data available for {title}")
return
labels, values = zip(*data)
# Create output directory
output_dir = Path("papers/figures")
output_dir.mkdir(exist_ok=True)
if colors is None:
colors = plt.cm.Set3(np.linspace(0, 1, len(labels)))
# Set style for consistent, professional appearance
plt.style.use('default')
plt.rcParams['font.size'] = 12
plt.rcParams['font.family'] = 'serif'
fig, ax = plt.subplots(figsize=(8, 6))
# Create pie chart with percentage labels
wedges, texts, autotexts = ax.pie(values, labels=labels, autopct='%1.1f%%',
colors=colors, startangle=90)
# Improve text formatting
for autotext in autotexts:
autotext.set_color('white')
autotext.set_fontweight('bold')
autotext.set_fontsize(10)
for text in texts:
text.set_fontsize(11)
ax.set_title(title, fontsize=14, fontweight='bold', pad=20)
# Equal aspect ratio ensures that pie is drawn as a circle
ax.axis('equal')
plt.tight_layout()
plt.savefig(output_dir / filename, dpi=300, bbox_inches='tight')
plt.close()
print(f"Created {filename}")
def create_combined_rejection_chart(client_data, freelancer_data):
"""Create a combined figure with two subplots for client and freelancer rejection reasons"""
# Create output directory
output_dir = Path("papers/figures")
output_dir.mkdir(exist_ok=True)
# Set style for consistent, professional appearance
plt.style.use('default')
plt.rcParams['font.size'] = 11
plt.rcParams['font.family'] = 'serif'
# Create figure with two subplots (wider to accommodate legends)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(20, 8))
# Colors for consistency across both charts
colors = plt.cm.Set3(np.linspace(0, 1, 5))
# Client rejection chart (left subplot)
if client_data:
client_labels, client_values = zip(*client_data)
# Create pie chart without labels (use legend instead)
wedges1, texts1, autotexts1 = ax1.pie(
client_values,
autopct='%1.1f%%',
colors=colors[:len(client_labels)],
startangle=90,
pctdistance=0.85 # Move percentage labels closer to center
)
# Improve text formatting for percentages
for autotext in autotexts1:
autotext.set_color('white')
autotext.set_fontweight('bold')
autotext.set_fontsize(10)
# Add legend instead of direct labels to avoid overlap
ax1.legend(wedges1, client_labels, title="Rejection Reasons",
loc="center left", bbox_to_anchor=(1, 0, 0.5, 1), fontsize=10)
ax1.set_title('LLM Client Rejection Reasons', fontsize=14, fontweight='bold', pad=20)
# Freelancer rejection chart (right subplot)
if freelancer_data:
freelancer_labels, freelancer_values = zip(*freelancer_data)
# Create pie chart without labels (use legend instead)
wedges2, texts2, autotexts2 = ax2.pie(
freelancer_values,
autopct='%1.1f%%',
colors=colors[:len(freelancer_labels)],
startangle=90,
pctdistance=0.85 # Move percentage labels closer to center
)
# Improve text formatting for percentages
for autotext in autotexts2:
autotext.set_color('white')
autotext.set_fontweight('bold')
autotext.set_fontsize(10)
# Add legend instead of direct labels to avoid overlap
ax2.legend(wedges2, freelancer_labels, title="Rejection Reasons",
loc="center left", bbox_to_anchor=(1, 0, 0.5, 1), fontsize=10)
ax2.set_title('LLM Freelancer Strategic Rejection Reasons', fontsize=14, fontweight='bold', pad=20)
# Equal aspect ratio ensures that pies are drawn as circles
ax1.axis('equal')
ax2.axis('equal')
# Add overall title
fig.suptitle('LLM Agent Rejection Patterns Comparison', fontsize=16, fontweight='bold', y=0.95)
plt.tight_layout()
plt.subplots_adjust(top=0.85) # Make room for suptitle
# Save the combined chart
filename = output_dir / "rejection_analysis_combined.png"
plt.savefig(filename, dpi=300, bbox_inches='tight')
plt.close()
print(f"Created combined rejection analysis chart: {filename}")
def analyze_comprehensive_rejections():
"""Comprehensive analysis of rejection patterns"""
print("=== COMPREHENSIVE REJECTION ANALYSIS ===")
# Load simulation data for comparative analysis
experiments = [
("results/simuleval/true_gpt_simulation_20250905_001404.json", "LLM-LLM (Both Agents Use Reasoning)"),
("results/simuleval/true_gpt_simulation_20250910_123457.json", "Random-LLM (Random Freelancer, LLM Client)")
]
experiment_results = {}
for file_path, experiment_name in experiments:
print(f"\n{'='*80}")
print(f"ANALYZING: {experiment_name}")
print(f"{'='*80}")
with open(file_path, 'r') as f:
simulation_data = json.load(f)
results = analyze_experiment_rejections(simulation_data, experiment_name)
experiment_results[experiment_name] = results
# Comparative analysis
print(f"\n{'='*80}")
print("COMPARATIVE ANALYSIS SUMMARY")
print(f"{'='*80}")
comparative_analysis(experiment_results)
return experiment_results
def extract_experiment_data(simulation_data):
"""Extract relevant data components from simulation data."""
return {
'hiring_outcomes': simulation_data.get('hiring_outcomes', []),
'all_bids': simulation_data.get('all_bids', []),
'all_jobs': simulation_data.get('all_jobs', []),
'freelancers': simulation_data.get('freelancer_profiles', {}),
'all_decisions': simulation_data.get('all_decisions', []),
'config': simulation_data.get('simulation_config', {})
}
def run_rejection_analyses(data):
"""Run all rejection-related analyses and return results."""
hired_outcomes, client_rejected_outcomes, client_rejection_reasons = analyze_client_rejections(
data['hiring_outcomes']
)
meaningful_rejections, freelancer_rejection_themes = analyze_freelancer_rejections(
data['all_decisions']
)
total_feedback_entries, freelancer_feedback_reasons, client_feedback_themes = analyze_client_feedback(
data['freelancers']
)
hire_reasons = analyze_successful_hires(hired_outcomes)
jobs_with_bids_count = analyze_job_fulfillment(
data['all_jobs'],
data['all_bids'],
hired_outcomes
)
return {
'hired_outcomes': hired_outcomes,
'client_rejected_outcomes': client_rejected_outcomes,
'client_rejection_reasons': client_rejection_reasons,
'meaningful_rejections': meaningful_rejections,
'freelancer_rejection_themes': freelancer_rejection_themes,
'total_feedback_entries': total_feedback_entries,
'freelancer_feedback_reasons': freelancer_feedback_reasons,
'client_feedback_themes': client_feedback_themes,
'hire_reasons': hire_reasons,
'jobs_with_bids_count': jobs_with_bids_count
}
def process_client_themes(client_rejection_reasons):
"""Process and print client rejection themes."""
if client_rejection_reasons:
client_themes = extract_themes(client_rejection_reasons)
print_themes("CLIENT REJECTION THEMES", client_themes)
return client_themes
return {}
def compile_experiment_results(experiment_name, data, analysis_results, client_themes):
"""Compile all analysis results into a comprehensive dictionary."""
return {
'experiment_name': experiment_name,
'config': data['config'],
'total_jobs': len(data['all_jobs']),
'total_bids': len(data['all_bids']),
'jobs_with_bids': analysis_results['jobs_with_bids_count'],
'successful_hires': len(analysis_results['hired_outcomes']),
'bid_to_hire_conversion': (
len(analysis_results['hired_outcomes']) / analysis_results['jobs_with_bids_count'] * 100
if analysis_results['jobs_with_bids_count'] > 0 else 0
),
# Client-side rejection data
'client_rejections': len(analysis_results['client_rejected_outcomes']),
'client_rejection_reasons': analysis_results['client_rejection_reasons'],
'client_themes': client_themes,
# Freelancer-side rejection data (freelancers choosing NOT to bid)
'freelancer_rejections': len(analysis_results['meaningful_rejections']),
'freelancer_rejections_with_reasons': len(analysis_results['meaningful_rejections']),
'freelancer_rejection_themes': analysis_results['freelancer_rejection_themes'],
'freelancer_rejection_reasons': [r['reasoning'] for r in analysis_results['meaningful_rejections']],
# Client feedback to freelancers data
'total_client_feedback_entries': analysis_results['total_feedback_entries'],
'client_feedback_with_reasons': len(analysis_results['freelancer_feedback_reasons']),
'client_feedback_themes': analysis_results['client_feedback_themes'],
'client_feedback_reasons': analysis_results['freelancer_feedback_reasons'],
'hire_reasons': analysis_results['hire_reasons']
}
def analyze_experiment_rejections(simulation_data, experiment_name):
"""Analyze rejection patterns for a single experiment - both client and freelancer perspectives"""
print_data_overview(simulation_data, experiment_name)
data = extract_experiment_data(simulation_data)
analysis_results = run_rejection_analyses(data)
client_themes = process_client_themes(analysis_results['client_rejection_reasons'])
return compile_experiment_results(experiment_name, data, analysis_results, client_themes)
def extract_experiment_results(experiment_results):
"""Extract and organize LLM-LLM and Random-LLM results."""
experiments = list(experiment_results.keys())
llm_llm_results = None
random_llm_results = None
for exp_name in experiments:
results = experiment_results[exp_name]
short_name = "LLM-LLM" if "LLM-LLM" in exp_name else "Random-LLM"
if short_name == "LLM-LLM":
llm_llm_results = results
else:
random_llm_results = results
return llm_llm_results, random_llm_results
def print_performance_metrics(llm_llm_results, random_llm_results):
"""Print performance metrics comparison."""
print("\n📊 MARKET PERFORMANCE COMPARISON:")
print(f"{'Metric':<30} {'LLM-LLM':<20} {'Random-LLM':<20}")
print("-" * 70)
metrics = [
("Total Jobs", "total_jobs"),
("Jobs with Bids", "jobs_with_bids"),
("Successful Hires", "successful_hires"),
("Bid-to-Hire Rate (%)", "bid_to_hire_conversion"),
("Client Feedback Entries", "total_client_feedback_entries"),
("Client Feedback Details", "client_feedback_with_reasons")
]
for metric_name, metric_key in metrics:
llm_val = llm_llm_results.get(metric_key, 0)
random_val = random_llm_results.get(metric_key, 0)
if metric_key == "bid_to_hire_conversion":
print(f"{metric_name:<30} {llm_val:<20.1f} {random_val:<20.1f}")
else:
print(f"{metric_name:<30} {llm_val:<20} {random_val:<20}")
def print_client_rejection_analysis(llm_llm_results, random_llm_results):
"""Print client-side rejection analysis."""
print("\n🏢 CLIENT-SIDE REJECTION ANALYSIS:")
print(f"{'Metric':<25} {'LLM-LLM':<15} {'Random-LLM':<15} {'Notes':<30}")
print("-" * 85)
llm_client_rejections = llm_llm_results.get('client_rejections', 0)
random_client_rejections = random_llm_results.get('client_rejections', 0)
print(f"{'Client Rejections':<25} {llm_client_rejections:<15} {random_client_rejections:<15} {'Both use LLM clients':<30}")
def print_client_rejection_themes(llm_llm_results, random_llm_results):
"""Print client rejection themes comparison."""
print("\n🎯 CLIENT REJECTION THEMES COMPARISON:")
print(f"{'Theme':<20} {'LLM-LLM':<15} {'Random-LLM':<15} {'Difference':<15}")
print("-" * 65)
# Get all unique client themes
all_client_themes = set()
all_client_themes.update(llm_llm_results.get('client_themes', {}).keys())
all_client_themes.update(random_llm_results.get('client_themes', {}).keys())
llm_client_total = sum(llm_llm_results.get('client_themes', {}).values())
random_client_total = sum(random_llm_results.get('client_themes', {}).values())
for theme in sorted(all_client_themes):
llm_count = llm_llm_results.get('client_themes', {}).get(theme, 0)
random_count = random_llm_results.get('client_themes', {}).get(theme, 0)
llm_pct = (llm_count / llm_client_total * 100) if llm_client_total > 0 else 0
random_pct = (random_count / random_client_total * 100) if random_client_total > 0 else 0
diff = llm_pct - random_pct
theme_name = theme.replace('_', ' ').title()
print(f"{theme_name:<20} {llm_pct:<15.1f} {random_pct:<15.1f} {diff:+6.1f}pp")
def print_freelancer_rejection_analysis(llm_llm_results, random_llm_results):
"""Print freelancer rejection analysis."""
print("\n🚫 FREELANCER REJECTION ANALYSIS (freelancers choosing NOT to bid):")
print(f"{'Metric':<25} {'LLM-LLM':<15} {'Random-LLM':<15} {'Notes':<30}")
print("-" * 85)
llm_freelancer_rejections = llm_llm_results.get('freelancer_rejections_with_reasons', 0)
random_freelancer_rejections = random_llm_results.get('freelancer_rejections_with_reasons', 0)
print(f"{'Freelancer Rejections':<25} {llm_freelancer_rejections:<15} {random_freelancer_rejections:<15} {'LLM vs Random freelancers':<30}")
def print_freelancer_rejection_themes(llm_llm_results, random_llm_results):
"""Print freelancer rejection themes comparison."""
print("\n🔍 FREELANCER REJECTION THEMES:")
print(f"{'Theme':<20} {'LLM-LLM':<15} {'Random-LLM':<15} {'Expected Pattern':<20}")
print("-" * 75)
# Get all unique freelancer rejection themes
all_freelancer_rejection_themes = set()
all_freelancer_rejection_themes.update(llm_llm_results.get('freelancer_rejection_themes', {}).keys())
all_freelancer_rejection_themes.update(random_llm_results.get('freelancer_rejection_themes', {}).keys())
llm_rejection_total = sum(llm_llm_results.get('freelancer_rejection_themes', {}).values())
random_rejection_total = sum(random_llm_results.get('freelancer_rejection_themes', {}).values())
for theme in sorted(all_freelancer_rejection_themes):
llm_count = llm_llm_results.get('freelancer_rejection_themes', {}).get(theme, 0)
random_count = random_llm_results.get('freelancer_rejection_themes', {}).get(theme, 0)
llm_pct = (llm_count / llm_rejection_total * 100) if llm_rejection_total > 0 else 0
random_pct = (random_count / random_rejection_total * 100) if random_rejection_total > 0 else 0
theme_name = theme.replace('_', ' ').title()
expected = "LLM > Random" if llm_pct > random_pct else "Random > LLM"
print(f"{theme_name:<20} {llm_pct:<15.1f} {random_pct:<15.1f} {expected:<20}")
def print_client_feedback_analysis(llm_llm_results, random_llm_results):
"""Print client feedback to freelancers analysis."""
print("\n📬 CLIENT FEEDBACK TO FREELANCERS ANALYSIS:")
print(f"{'Metric':<25} {'LLM-LLM':<15} {'Random-LLM':<15} {'Notes':<30}")
print("-" * 85)
llm_client_feedback = llm_llm_results.get('client_feedback_with_reasons', 0)
random_client_feedback = random_llm_results.get('client_feedback_with_reasons', 0)
print(f"{'Client Feedback':<25} {llm_client_feedback:<15} {random_client_feedback:<15} {'LLM vs Random freelancers':<30}")
def print_client_feedback_themes(llm_llm_results, random_llm_results):
"""Print client feedback themes comparison."""
print("\n🔍 CLIENT FEEDBACK TO FREELANCERS THEMES:")
print(f"{'Theme':<20} {'LLM-LLM':<15} {'Random-LLM':<15} {'Expected Pattern':<20}")
print("-" * 75)
# Get all unique client feedback themes
all_client_feedback_themes = set()
all_client_feedback_themes.update(llm_llm_results.get('client_feedback_themes', {}).keys())
all_client_feedback_themes.update(random_llm_results.get('client_feedback_themes', {}).keys())
llm_client_feedback_total = sum(llm_llm_results.get('client_feedback_themes', {}).values())
random_client_feedback_total = sum(random_llm_results.get('client_feedback_themes', {}).values())
for theme in sorted(all_client_feedback_themes):
llm_count = llm_llm_results.get('client_feedback_themes', {}).get(theme, 0)
random_count = random_llm_results.get('client_feedback_themes', {}).get(theme, 0)
llm_pct = (llm_count / llm_client_feedback_total * 100) if llm_client_feedback_total > 0 else 0
random_pct = (random_count / random_client_feedback_total * 100) if random_client_feedback_total > 0 else 0
theme_name = theme.replace('_', ' ').title()
expected = "LLM > Random" if llm_pct > random_pct else "Random > LLM"
print(f"{theme_name:<20} {llm_pct:<15.1f} {random_pct:<15.1f} {expected:<20}")
def print_key_insights(llm_llm_results, random_llm_results):
"""Print key insights from the comparative analysis."""
print("\n💡 KEY INSIGHTS:")
llm_client_rejections = llm_llm_results.get('client_rejections', 0)
random_client_rejections = random_llm_results.get('client_rejections', 0)
llm_client_feedback = llm_llm_results.get('client_feedback_with_reasons', 0)
random_client_feedback = random_llm_results.get('client_feedback_with_reasons', 0)
llm_freelancer_rejections = llm_llm_results.get('freelancer_rejections_with_reasons', 0)
random_freelancer_rejections = random_llm_results.get('freelancer_rejections_with_reasons', 0)
# Market efficiency comparison
if llm_llm_results.get('bid_to_hire_conversion', 0) > random_llm_results.get('bid_to_hire_conversion', 0):
diff = llm_llm_results.get('bid_to_hire_conversion', 0) - random_llm_results.get('bid_to_hire_conversion', 0)
print(f" • LLM freelancers + LLM clients achieve {diff:.1f}% higher bid-to-hire conversion")
# Client-side reasoning (both use LLM clients)
if llm_client_rejections > 0 and random_client_rejections > 0:
print(" • Both configurations use LLM clients - both show systematic rejection reasoning")
elif llm_client_rejections > 0 or random_client_rejections > 0:
print(" • LLM clients provide structured rejection reasoning when present")
# Client feedback to freelancers patterns
if llm_client_feedback > 0 and random_client_feedback == 0:
print(f" • Only LLM freelancers receive/store detailed feedback from clients ({llm_client_feedback} vs {random_client_feedback})")
print(" • Random freelancers don't process detailed rejection feedback")
# Freelancer rejection patterns
if llm_freelancer_rejections > 0 and random_freelancer_rejections > 0:
print(f" • LLM freelancers provide detailed reasoning for rejecting jobs ({llm_freelancer_rejections:,} reasoned rejections)")
print(" • Random freelancers provide no meaningful rejection reasoning (generic probabilistic decisions)")
# Strategic pairing insights
print(" • Client reasoning quality independent of freelancer type (both use LLM clients)")
print(" • Freelancer feedback processing depends on freelancer reasoning capability")
print(" • Full LLM-LLM pairing creates most efficient market outcomes")
def comparative_analysis(experiment_results):
"""Compare rejection patterns across experiments"""
print("🔍 COMPARATIVE DECISION-MAKING QUALITY ANALYSIS")
print("-" * 60)
llm_llm_results, random_llm_results = extract_experiment_results(experiment_results)
print_performance_metrics(llm_llm_results, random_llm_results)
print_client_rejection_analysis(llm_llm_results, random_llm_results)
print_client_rejection_themes(llm_llm_results, random_llm_results)
print_freelancer_rejection_analysis(llm_llm_results, random_llm_results)
print_freelancer_rejection_themes(llm_llm_results, random_llm_results)
print_client_feedback_analysis(llm_llm_results, random_llm_results)
print_client_feedback_themes(llm_llm_results, random_llm_results)
print_key_insights(llm_llm_results, random_llm_results)
def _find_llm_llm_results(experiment_results):
"""Find LLM-LLM experiment results from all experiments"""
for exp_name, results in experiment_results.items():
if "LLM-LLM" in exp_name:
return results
return None
def _get_theme_mapping():
"""Get the mapping from internal theme names to paper-friendly names"""
return {
'skill_mismatch': 'Skill Mismatch',
'fit': 'Project Fit',
'rate_budget': 'Rate/Budget',
'communication': 'Communication',
'competition': 'Competition'
}
def _prepare_theme_data(themes, theme_mapping):
"""Prepare theme data with mapped names and percentages"""
data = []
total = sum(themes.values())
for theme, count in themes.items():
mapped_name = theme_mapping.get(theme, theme.replace('_', ' ').title())
percentage = (count / total * 100) if total > 0 else 0
data.append((mapped_name, percentage))
data.sort(key=lambda x: x[1], reverse=True)
return data
def generate_paper_pie_charts(experiment_results):
"""Generate pie charts for the paper based on analysis results"""
print(f"\n{'='*80}")
print("GENERATING PIE CHARTS FOR PAPER")
print(f"{'='*80}")
llm_llm_results = _find_llm_llm_results(experiment_results)
if not llm_llm_results:
print("No LLM-LLM results found for pie chart generation")
return
client_themes = llm_llm_results.get('client_themes', {})
freelancer_themes = llm_llm_results.get('freelancer_rejection_themes', {})
if client_themes and freelancer_themes:
theme_mapping = _get_theme_mapping()
client_data = _prepare_theme_data(client_themes, theme_mapping)
freelancer_data = _prepare_theme_data(freelancer_themes, theme_mapping)
create_combined_rejection_chart(client_data, freelancer_data)
print("Pie chart generation completed!")
if __name__ == "__main__":
experiment_results = analyze_comprehensive_rejections()
# Generate pie charts for the paper
if experiment_results:
generate_paper_pie_charts(experiment_results)