Download predict_batch.py from addweb-solution/la-liga-score-predictor: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/addweb-solution/la-liga-score-predictor/resolve/main/predict_batch.py
- Command line
-
hf download hf://addweb-solution/la-liga-score-predictor/predict_batch.py
-
curl -L -o predict_batch.py https://huggingface.co/addweb-solution/la-liga-score-predictor/resolve/main/predict_batch.py
1.41 kB
| from pathlib import Path | |
| import csv | |
| from la_liga_score_predictor import LaLigaScorePredictor | |
| predictor = LaLigaScorePredictor.from_defaults( | |
| dataset_csv_path="sample_history.csv" | |
| ) | |
| input_path = Path("sample_fixtures.csv") | |
| output_path = Path("predictions_output.csv") | |
| with input_path.open(newline="", encoding="utf-8") as src, output_path.open("w", newline="", encoding="utf-8") as dst: | |
| reader = csv.DictReader(src) | |
| fieldnames = ["home_team", "away_team", "match_date", "predicted_score", "home_win", "draw", "away_win", "confidence_level"] | |
| writer = csv.DictWriter(dst, fieldnames=fieldnames) | |
| writer.writeheader() | |
| for row in reader: | |
| result = predictor.predict_match( | |
| home_team=row["home_team"], | |
| away_team=row["away_team"], | |
| match_date=row["match_date"], | |
| ) | |
| writer.writerow( | |
| { | |
| "home_team": row["home_team"], | |
| "away_team": row["away_team"], | |
| "match_date": row["match_date"], | |
| "predicted_score": result["predicted_score"], | |
| "home_win": result["result_probabilities"]["home_win"], | |
| "draw": result["result_probabilities"]["draw"], | |
| "away_win": result["result_probabilities"]["away_win"], | |
| "confidence_level": result["confidence_level"], | |
| } | |
| ) | |
| print(f"Wrote {output_path}") | |