Download src/gp_extrusion/data.py from carbon-lab/gp-extrusion: direct link, hf CLI and curl.
- Browser
- Download file 809 Bytes
-
https://huggingface.co/carbon-lab/gp-extrusion/resolve/main/src/gp_extrusion/data.py
- Command line
-
hf download hf://carbon-lab/gp-extrusion/src/gp_extrusion/data.py
-
curl -L -o data.py https://huggingface.co/carbon-lab/gp-extrusion/resolve/main/src/gp_extrusion/data.py
809 Bytes
| """Load the tidy measurements as one row per setting x 12 outputs.""" | |
| import numpy as np | |
| import pandas as pd | |
| from .space import OUTPUTS, PARAMS, ROOT | |
| def load_settings(include_synthetic: bool = True) -> pd.DataFrame: | |
| """One row per setting: PARAMS, `source`, and a column per (target, position).""" | |
| df = pd.read_csv(ROOT / "data" / "extrusion.csv") | |
| if not include_synthetic: | |
| df = df[df["source"] == "real"] | |
| wide = df.pivot_table( | |
| index=[*PARAMS, "source"], | |
| columns="position", | |
| values=sorted({t for t, _ in OUTPUTS}), | |
| ) | |
| wide.columns = [f"{t}|{p}" for t, p in wide.columns] | |
| wide = wide[[f"{t}|{p}" for t, p in OUTPUTS]].reset_index() | |
| return wide | |
| def setting_array(df: pd.DataFrame) -> np.ndarray: | |
| return df[PARAMS].to_numpy(dtype=float) | |