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

Function build_rows

experiments/drift/build_drift_adaptation_experiment.py:416–480  ·  view source on GitHub ↗
(
    benchmark_dir: Path,
    method_specs: Sequence[Tuple[str, Path]],
    *,
    pre_days: int,
    post_days: int,
    k: int,
    min_new_topic_hits: int,
)

Source from the content-addressed store, hash-verified

414
415
416def build_rows(
417 benchmark_dir: Path,
418 method_specs: Sequence[Tuple[str, Path]],
419 *,
420 pre_days: int,
421 post_days: int,
422 k: int,
423 min_new_topic_hits: int,
424) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]:
425 metadata = read_episode_metadata(benchmark_dir)
426 events = read_drift_events(benchmark_dir)
427 windows = select_window_episode_ids(metadata, events, pre_days=pre_days, post_days=post_days)
428
429 rows: List[Dict[str, Any]] = []
430 for method_name, output_dir in method_specs:
431 episode_path = output_dir / "episode_papers.jsonl"
432 if not episode_path.exists():
433 continue
434 grouped = group_episode_rows(episode_path)
435 post = method_episode_metrics(grouped, windows.get("PostDriftWindow", []), k)
436 active = method_episode_metrics(grouped, windows.get("ActiveDrift", []), k)
437 stable = method_episode_metrics(grouped, windows.get("Stable", []), k)
438 recovered = method_episode_metrics(grouped, windows.get("Recovered", []), k)
439 topics = topic_window_metrics(grouped, windows.get("PostDriftWindow", []), events, k)
440 delay = adaptation_delay_days(
441 grouped,
442 events,
443 metadata,
444 k=k,
445 post_days=post_days,
446 min_new_topic_hits=min_new_topic_hits,
447 )
448
449 rows.append(
450 {
451 "Method": method_name,
452 "PostEpisodes": post.get("EpisodeCount"),
453 "PostDrift_gNDCG@20": post.get("gNDCG@20"),
454 "PostDrift_Useful@20": post.get("Useful@20"),
455 "PostDrift_OracleRecall@20": post.get("OracleRecall@20"),
456 "PostDrift_StrictR@20+": post.get("StrictR@20+"),
457 "PostDrift_SelectedNDCG@20": post.get("SelectedNDCG@20"),
458 "NewTopicRecall@20": topics.get("NewTopicRecall@20"),
459 "NewTopicHits@20": topics.get("NewTopicHits@20"),
460 "OldTopicRate@20": topics.get("OldTopicRate@20"),
461 "AdaptationDelayDays": delay,
462 "ActiveDrift_gNDCG@20": active.get("gNDCG@20"),
463 "ActiveDrift_SelectedNDCG@20": active.get("SelectedNDCG@20"),
464 "Recovered_gNDCG@20": recovered.get("gNDCG@20"),
465 "Stable_gNDCG@20": stable.get("gNDCG@20"),
466 "Stable_SelectedNDCG@20": stable.get("SelectedNDCG@20"),
467 }
468 )
469
470 context = {
471 "benchmark_dir": str(benchmark_dir),
472 "drift_events": len(events),
473 "windows": {key: len(value) for key, value in sorted(windows.items())},

Callers 1

mainFunction · 0.70

Calls 8

read_drift_eventsFunction · 0.85
group_episode_rowsFunction · 0.85
method_episode_metricsFunction · 0.85
topic_window_metricsFunction · 0.85
adaptation_delay_daysFunction · 0.85
getMethod · 0.80
read_episode_metadataFunction · 0.70

Tested by

no test coverage detected