feat: complete Day 2 handoff with API service, PM2 process daemons, and test suites
This commit is contained in:
1 parent
564262340a
commit
12f0786be9
27 files changed
+3234
-1013
No files matched your search
@@ -0,0 +1,56 @@
|
||||
"""
|
||||
update_ranking_and_anomalies.py
|
||||
Synchronizes all multi-platform metrics through HIFFIRankingEngine.
|
||||
Re-computes XP scores, dynamic weights, statistical anomaly flags, and published ranks.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import pandas as pd
|
||||
|
||||
from core.ranking_engine import HIFFIRankingEngine
|
||||
|
||||
DATA_PATH = Path("data/hiffi_multiplatform_500.csv")
|
||||
|
||||
|
||||
def run_ranking_update():
|
||||
if not DATA_PATH.exists():
|
||||
print(f"File not found: {DATA_PATH}")
|
||||
return
|
||||
|
||||
df = pd.read_csv(DATA_PATH)
|
||||
print(f"Loaded master dataset with {len(df)} artists.")
|
||||
|
||||
engine = HIFFIRankingEngine()
|
||||
|
||||
print("[1/4] Calculating baseline production rankings...")
|
||||
df = engine.score_and_rank(df)
|
||||
|
||||
print("[2/4] Computing HIFFI-XP composite scores & dynamic weight redistribution...")
|
||||
df = engine.calculate_hiffi_xp(df)
|
||||
|
||||
print("[3/4] Running statistical anomaly detection...")
|
||||
df = engine.detect_metric_anomalies(df)
|
||||
|
||||
print("[4/4] Applying publication eligibility gates & tier constraints...")
|
||||
df = engine.apply_publication_eligibility_gates(df)
|
||||
|
||||
# Clean display types
|
||||
if "hiffi_xp_published_rank" in df.columns:
|
||||
df["hiffi_xp_published_rank"] = df["hiffi_xp_published_rank"].astype(int)
|
||||
|
||||
df.to_csv(DATA_PATH, index=False)
|
||||
|
||||
anomaly_counts = (df["anomaly_flags"] != "CLEAN").sum()
|
||||
tier_counts = df["platform_evidence_tier"].value_counts().to_dict()
|
||||
|
||||
print("\n==========================================")
|
||||
print("Multi-Platform Ranking & Anomaly Sync Complete!")
|
||||
print(f"Evidence Tiers Distribution: {tier_counts}")
|
||||
print(f"Statistical Anomalies Detected: {anomaly_counts} (Auditable Outliers)")
|
||||
print(f"Clean Normal Records: {len(df) - anomaly_counts}")
|
||||
print(f"Master CSV updated: {DATA_PATH}")
|
||||
print("==========================================")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_ranking_update()
|
||||
Reference in new issue
Block a user