MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / evaluate

Function evaluate

experiments/benchmark/evaluate_benchmark_predictions.py:162–191  ·  view source on GitHub ↗
(benchmark_dir: Path, predictions_path: Path)

Source from the content-addressed store, hash-verified

160
161
162def evaluate(benchmark_dir: Path, predictions_path: Path) -> dict[str, Any]:
163 labels = load_labels(benchmark_dir)
164 predictions = load_predictions(predictions_path)
165
166 episode_metrics = []
167 missing_predictions = 0
168 for episode_id, label_rows in labels.items():
169 predicted_ids = predictions.get(episode_id)
170 if predicted_ids is None:
171 missing_predictions += 1
172 predicted_ids = []
173 episode_metrics.append(evaluate_episode(label_rows, predicted_ids))
174
175 summary = {
176 "episodes": len(labels),
177 "predicted_episodes": len(predictions),
178 "missing_predictions": missing_predictions,
179 }
180 for metric in [
181 "gNDCG@20",
182 "Useful@5",
183 "Useful@20",
184 "SelectedNDCG@20",
185 "StrictR@20+",
186 "MRR@20",
187 "Lift@20",
188 ]:
189 summary[metric] = mean_defined([row.get(metric) for row in episode_metrics])
190 summary["RecommendationScore"] = recommendation_score(summary)
191 return summary
192
193
194def parse_args() -> argparse.Namespace:

Callers 1

mainFunction · 0.85

Calls 6

load_labelsFunction · 0.85
load_predictionsFunction · 0.85
getMethod · 0.80
evaluate_episodeFunction · 0.70
mean_definedFunction · 0.70
recommendation_scoreFunction · 0.70

Tested by

no test coverage detected