Download predict.py from abhirath-a/dolos: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/abhirath-a/dolos/resolve/main/predict.py
- Command line
-
hf download hf://abhirath-a/dolos/predict.py
-
curl -L -o predict.py https://huggingface.co/abhirath-a/dolos/resolve/main/predict.py
1.11 kB
| """Run the published checkpoint locally, without the Dolos backend.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| from dolos_hybrid import DolosHybrid | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--input", type=Path, default=Path(__file__).parent / "examples/synthetic-transfers.csv") | |
| parser.add_argument("--model-dir", type=Path, default=Path(__file__).parent) | |
| parser.add_argument("--output", type=Path, default=Path("predictions.json")) | |
| parser.add_argument("--limit", type=int, default=2000) | |
| parser.add_argument("--explain", action="store_true") | |
| args = parser.parse_args() | |
| result = DolosHybrid(args.model_dir).predict_csv(args.input, limit=args.limit, explain=args.explain) | |
| args.output.write_text(json.dumps(result, indent=2) + "\n") | |
| scores = result["scores"] | |
| print(json.dumps({"run_id": result["run_id"], "scored": len(scores), | |
| "flagged": sum(score["score"] > 0 for score in scores), | |
| "output": str(args.output)}, indent=2)) | |
| if __name__ == "__main__": | |
| main() | |