66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
"""
|
|||
|
|
scripts/audit_weights.py
|
||
|
|
Audits dynamic weight allocation, platform presence tiers, and high-rank evidence.
|
||
|
|
"""
|
||
|
|
from pathlib import Path
|
||
|
|
import pandas as pd
|
||
|
|
import numpy as np
|
||
|
|
|
||
|
|
DATASET_PATH = Path("data/hiffi_multiplatform_500.csv")
|
||
|
|
|
||
|
|
if not DATASET_PATH.exists():
|
||
|
|
raise FileNotFoundError(f"Master cohort not found at {DATASET_PATH}")
|
||
|
|
|
||
|
|
df = pd.read_csv(DATASET_PATH)
|
||
|
|
|
||
|
|
# Explicitly define platform presence (YouTube, Spotify presence, Instagram presence)
|
||
|
|
df["has_youtube"] = df["production_hiffi_score"].notna()
|
||
|
|
df["has_spotify"] = df["spotify_monthly_listeners"].notna()
|
||
|
|
df["has_instagram"] = df["instagram_followers"].notna()
|
||
|
|
|
||
|
|
df["verified_platform_count"] = (
|
||
|
|
df["has_youtube"].astype(int) +
|
||
|
|
df["has_spotify"].astype(int) +
|
||
|
|
df["has_instagram"].astype(int)
|
||
|
|
)
|
||
|
|
|
||
|
|
print("=" * 70)
|
||
|
|
print("1. VERIFIED PLATFORM PRESENCE TIERS")
|
||
|
|
print("=" * 70)
|
||
|
|
tier_summary = df.groupby("verified_platform_count")["hiffi_xp_score"].agg(
|
||
|
|
count="count",
|
||
|
|
mean="mean",
|
||
|
|
std="std",
|
||
|
|
min="min",
|
||
|
|
max="max"
|
||
|
|
).round(2)
|
||
|
|
print(tier_summary)
|
||
|
|
|
||
|
|
print("\n" + "=" * 70)
|
||
|
|
print("2. TOP 50 PLATFORM EVIDENCE DISTRIBUTION")
|
||
|
|
print("=" * 70)
|
||
|
|
top_50 = df[df["hiffi_xp_rank"] <= 50]
|
||
|
|
top_50_dist = top_50["verified_platform_count"].value_counts().sort_index(ascending=False)
|
||
|
|
for tier, count in top_50_dist.items():
|
||
|
|
print(f"Tier {tier} Platforms Verified: {count:2d} artists ({count / len(top_50) * 100:4.1f}%)")
|
||
|
|
|
||
|
|
print("\n" + "=" * 70)
|
||
|
|
print("3. TOP 10 PLATFORM EVIDENCE DISTRIBUTION")
|
||
|
|
print("=" * 70)
|
||
|
|
top_10 = df[df["hiffi_xp_rank"] <= 10]
|
||
|
|
top_10_dist = top_10["verified_platform_count"].value_counts().sort_index(ascending=False)
|
||
|
|
for tier, count in top_10_dist.items():
|
||
|
|
print(f"Tier {tier} Platforms Verified: {count:2d} artists ({count / len(top_10) * 100:4.1f}%)")
|
||
|
|
|
||
|
|
print("\n" + "=" * 70)
|
||
|
|
print("4. RANK DELTA EXTREMES & AUDIT TRAIL")
|
||
|
|
print("=" * 70)
|
||
|
|
cols = ["name", "production_hiffi_rank", "hiffi_xp_rank", "rank_delta", "verified_platform_count"]
|
||
|
|
top_gainers = df.sort_values(by="rank_delta", ascending=False).head(3)[cols]
|
||
|
|
top_fallers = df.sort_values(by="rank_delta", ascending=True).head(3)[cols]
|
||
|
|
|
||
|
|
print("Top 3 Gainers:")
|
||
|
|
print(top_gainers.to_string(index=False))
|
||
|
|
print("\nTop 3 Fallers:")
|
||
|
|
print(top_fallers.to_string(index=False))
|
||
|
|
print("=" * 70)
|