Upload 6 files
Browse files
dataset/AptaBench_dataset.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dataset/AptaBench_dataset.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f8b01685137cc495b35b50681eccf6e1fd4ade476b13067462ea5f2d6cc4459
|
| 3 |
+
size 112730
|
dataset/make_splits.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
import json
|
| 4 |
+
import numpy as np
|
| 5 |
+
import pandas as pd
|
| 6 |
+
|
| 7 |
+
# make src/ available
|
| 8 |
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))
|
| 9 |
+
|
| 10 |
+
from data.split import (
|
| 11 |
+
stratified_group_splits,
|
| 12 |
+
disjoint_aptamer_splits,
|
| 13 |
+
disjoint_molecule_splits,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
# ======================================================
|
| 17 |
+
# CONFIG
|
| 18 |
+
# ======================================================
|
| 19 |
+
DATASET_PATH = os.path.join(os.path.dirname(__file__), "AptaBench_dataset_v3.csv")
|
| 20 |
+
N_SPLITS = 5
|
| 21 |
+
RANDOM_STATE = 42
|
| 22 |
+
FRAC_TOLERANCE = 0.02 # acceptable abs deviation from expected test fraction
|
| 23 |
+
MAX_TRIES = 200 # retry different seeds to meet ratio
|
| 24 |
+
|
| 25 |
+
# ======================================================
|
| 26 |
+
# LOAD DATA
|
| 27 |
+
# ======================================================
|
| 28 |
+
df = pd.read_csv(DATASET_PATH)
|
| 29 |
+
|
| 30 |
+
# ======================================================
|
| 31 |
+
# MAKE OUTPUT DIR
|
| 32 |
+
# ======================================================
|
| 33 |
+
outdir = os.path.join(os.path.dirname(__file__), "splits")
|
| 34 |
+
os.makedirs(outdir, exist_ok=True)
|
| 35 |
+
|
| 36 |
+
# ======================================================
|
| 37 |
+
# HELPER TO SAVE SPLITS
|
| 38 |
+
# ======================================================
|
| 39 |
+
def save_splits(name, splits):
|
| 40 |
+
outpath = os.path.join(outdir, f"{name}.json")
|
| 41 |
+
data = []
|
| 42 |
+
for i, (tr, va) in enumerate(splits):
|
| 43 |
+
data.append({
|
| 44 |
+
"fold": i,
|
| 45 |
+
"train_idx": tr.tolist(),
|
| 46 |
+
"val_idx": va.tolist(),
|
| 47 |
+
})
|
| 48 |
+
with open(outpath, "w") as f:
|
| 49 |
+
json.dump(data, f, indent=2)
|
| 50 |
+
print(f"Saved {name} splits -> {outpath}")
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
# ======================================================
|
| 54 |
+
# STRATIFIED
|
| 55 |
+
# ======================================================
|
| 56 |
+
splits = stratified_group_splits(
|
| 57 |
+
df,
|
| 58 |
+
n_splits=N_SPLITS,
|
| 59 |
+
random_state=RANDOM_STATE,
|
| 60 |
+
frac_tolerance=FRAC_TOLERANCE,
|
| 61 |
+
max_tries=MAX_TRIES,
|
| 62 |
+
)
|
| 63 |
+
save_splits("stratified", splits)
|
| 64 |
+
|
| 65 |
+
# ======================================================
|
| 66 |
+
# DISJOINT APTAMER
|
| 67 |
+
# ======================================================
|
| 68 |
+
splits = disjoint_aptamer_splits(
|
| 69 |
+
df,
|
| 70 |
+
n_splits=N_SPLITS,
|
| 71 |
+
random_state=RANDOM_STATE,
|
| 72 |
+
frac_tolerance=FRAC_TOLERANCE,
|
| 73 |
+
max_tries=MAX_TRIES,
|
| 74 |
+
)
|
| 75 |
+
save_splits("disjoint_aptamer", splits)
|
| 76 |
+
|
| 77 |
+
# ======================================================
|
| 78 |
+
# DISJOINT MOLECULE
|
| 79 |
+
# ======================================================
|
| 80 |
+
splits = disjoint_molecule_splits(
|
| 81 |
+
df,
|
| 82 |
+
n_splits=N_SPLITS,
|
| 83 |
+
random_state=RANDOM_STATE,
|
| 84 |
+
scaffold_missing="separate",
|
| 85 |
+
frac_tolerance=FRAC_TOLERANCE,
|
| 86 |
+
max_tries=MAX_TRIES,
|
| 87 |
+
)
|
| 88 |
+
save_splits("disjoint_molecule", splits)
|
| 89 |
+
|
| 90 |
+
print("All splits successfully saved in dataset/splits/")
|
dataset/splits/disjoint_aptamer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dataset/splits/disjoint_molecule.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dataset/splits/stratified.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|