Download make_split.py from venom2410/enzyme-knn: direct link, hf CLI and curl.
- Browser
- Download file 982 Bytes
-
https://huggingface.co/venom2410/enzyme-knn/resolve/main/make_split.py
- Command line
-
hf download hf://venom2410/enzyme-knn/make_split.py
-
curl -L -o make_split.py https://huggingface.co/venom2410/enzyme-knn/resolve/main/make_split.py
982 Bytes
| """Write the strict hold-out sequences (no close relative in train) to holdout.json. | |
| python make_split.py --train ../data/train.parquet --out holdout.json | |
| """ | |
| import argparse | |
| import json | |
| from collections import defaultdict | |
| import pandas as pd | |
| from evaluate import strict_split | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--train", required=True) | |
| ap.add_argument("--out", default="holdout.json") | |
| ap.add_argument("--maxsim", type=float, default=0.11) | |
| ap.add_argument("--max_eval", type=int, default=3000) | |
| ap.add_argument("--pool", type=int, default=100000) | |
| a = ap.parse_args() | |
| df = pd.read_parquet(a.train, columns=["sequence", "ec_number"]) | |
| per = defaultdict(set) | |
| for s, e in zip(df["sequence"], df["ec_number"]): | |
| per[s].add(e) | |
| val, _ = strict_split(per, a) | |
| with open(a.out, "w") as f: | |
| json.dump(val, f) | |
| print("wrote", len(val), "sequences to", a.out) | |
| if __name__ == "__main__": | |
| main() | |