Download tasks/cell_lab/environment/methods/main/main.py from Tokenwave-AI/REE: direct link, hf CLI and curl.
- Browser
- Download file 656 Bytes
-
https://huggingface.co/datasets/Tokenwave-AI/REE/resolve/refs%2Fpr%2F1/tasks/cell_lab/environment/methods/main/main.py
- Command line
-
hf download hf://datasets/Tokenwave-AI/REE@refs/pr/1/tasks/cell_lab/environment/methods/main/main.py
-
curl -L -o main.py https://huggingface.co/datasets/Tokenwave-AI/REE/resolve/refs%2Fpr%2F1/tasks/cell_lab/environment/methods/main/main.py
656 Bytes
| import os,sys | |
| from pathlib import Path | |
| import numpy as np | |
| sys.path.insert(0,str(Path(os.environ['CORE_DIR'])/'interface')) | |
| from records import read_matrix,read_queries,write_prediction | |
| data,out=map(Path,sys.argv[1:]) | |
| header,rows,y=read_matrix(data/'train.tsv') | |
| queries=read_queries(data/'queries.tsv') | |
| # An empirical mean for each observed group, with the global mean as fallback. | |
| groups=np.array([r[1] for r in rows]) | |
| mean_by_group={g:y[groups==g].mean(axis=0) for g in sorted(set(groups))} | |
| global_mean=y.mean(axis=0) | |
| values=np.stack([mean_by_group.get(q[1],global_mean) for q in queries]) | |
| write_prediction(out/'prediction.tsv',header[3:],queries,values) | |