Spaces:
Sleeping
Sleeping
File size: 2,817 Bytes
81cfb2c |
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 |
import argparse
import pandas as pd
def main(
input_csv: str,
out_counts: str = "num_raters_per_video.csv",
out_stats_all: str = "video_stats_all.csv",
out_stats_filtered: str = "video_stats_filtered.csv",
min_raters: int = 2,
):
# 1) λ°μ΄ν° λ‘λ
df = pd.read_csv(input_csv)
# μ«μν 보μ₯ (λ¬Έμ/λΉμΉΈ μμμ λ λλΉ)
for col in ["action_consistency", "physical_plausibility"]:
if col in df.columns:
df[col] = pd.to_numeric(df[col], errors="coerce")
# 2) λΉλμ€λ³ κ³ μ νκ°μ μ
counts = (
df.groupby("video_id")["participant_id"]
.nunique()
.reset_index(name="num_raters")
)
counts.to_csv(out_counts, index=False)
# 3) λΉλμ€λ³ ν΅κ³ (νκ· /νμ€νΈμ°¨/νλ³Έμ)
agg_map = {
"participant_id": pd.Series.nunique, # κ³ μ νκ°μ μ
"action_consistency": ["mean", "std", "count"],
"physical_plausibility": ["mean", "std", "count"],
}
stats = df.groupby("video_id").agg(agg_map)
# μ»¬λΌ ννν
stats.columns = [
"num_raters",
"action_mean", "action_std", "action_count",
"physical_mean", "physical_std", "physical_count",
]
stats = stats.reset_index()
# 3-1) (μ ν) λ³λκ³μ(CV)λ μ°Έκ³ μ©μΌλ‘ μΆκ°
stats["action_cv"] = stats["action_std"] / stats["action_mean"]
stats["physical_cv"] = stats["physical_std"] / stats["physical_mean"]
# μ μ₯ (λͺ¨λ λΉλμ€)
stats.to_csv(out_stats_all, index=False)
# 4) μ΅μ νκ°μ μ μ΄μλ§ νν°λ§
stats_filtered = stats[stats["num_raters"] >= min_raters].copy()
stats_filtered.to_csv(out_stats_filtered, index=False)
# 5) μμ½ νλ¦°νΈ
print("β
μ μ₯ μλ£")
print(f"- λΉλμ€λ³ νκ°μ μ: {out_counts}")
print(f"- λΉλμ€λ³ ν΅κ³(μ 체): {out_stats_all}")
print(f"- λΉλμ€λ³ ν΅κ³(νκ°μ {min_raters}λͺ
μ΄μ): {out_stats_filtered}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Human eval λΆμ μ€ν¬λ¦½νΈ")
parser.add_argument("--input_csv", type=str, required=True, help="μλ³Έ CSV κ²½λ‘")
parser.add_argument("--out_counts", type=str, default="num_raters_per_video.csv")
parser.add_argument("--out_stats_all", type=str, default="video_stats_all.csv")
parser.add_argument("--out_stats_filtered", type=str, default="video_stats_filtered.csv")
parser.add_argument("--min_raters", type=int, default=2, help="μ΅μ νκ°μ μ κΈ°μ€")
args = parser.parse_args()
main(
input_csv=args.input_csv,
out_counts=args.out_counts,
out_stats_all=args.out_stats_all,
out_stats_filtered=args.out_stats_filtered,
min_raters=args.min_raters,
)
|