| --- |
| dataset_info: |
| features: |
| - name: mixture_T_id |
| list: int64 |
| - name: value |
| dtype: float64 |
| - name: T |
| dtype: float64 |
| - name: P |
| dtype: float64 |
| - name: cmp_ids |
| list: int64 |
| - name: cmp_mole_fractions |
| list: float64 |
| splits: |
| - name: train |
| num_bytes: 14089524 |
| num_examples: 153147 |
| download_size: 9382048 |
| dataset_size: 14089524 |
| configs: |
| - config_name: default |
| data_files: |
| - split: train |
| path: data/train-* |
| pretty_name: NIST log-viscosity (base + Redlich-Kister LOOCV fit) |
| tags: |
| - chemistry |
| - mixtures |
| - viscosity |
| - regression |
| language: |
| - en |
| --- |
| |
| # NIST log-viscosity — base dataset + per-fit CSVs |
|
|
| A two-layer dataset: |
|
|
| 1. **`points` (HF dataset main payload)** — the binary-only chemixhub |
| `nist-logV` measurements plus a `mixture_T_id` join key. Immutable; one |
| row per measurement. This is the data layer. |
| 2. **`fits/<name>.csv`** — one CSV per fit, keyed on `mixture_T_id`. Each |
| CSV holds whatever that fitter's results look like — fit parameters |
| plus a small canonical set (`pure_at_x0`, `pure_at_x1`, `nonlinearity`). |
| Multiple fits coexist; pushing a new fit doesn't touch the base data. |
|
|
| Built by [mixtureml-data](https://github.com/AI4ChemS/mixtureml-data). |
|
|
| ## What's in the box |
|
|
| - **`points` (HF dataset main payload, ~150K rows)** — one row per |
| measurement. Columns: `mixture_T_id`, `value` (log viscosity), `T` (K), |
| `P` (bar), `cmp_ids` (length-2 list of chemixhub compound IDs), |
| `cmp_mole_fractions` (length-2 list, aligned with `cmp_ids`). |
| - **`compounds.csv`** — chemixhub's `compound_id → smiles` map, filtered |
| to the IDs that appear in `points`. Lets downstream consumers translate |
| `cmp_ids` to SMILES without depending on the chemixhub repo. |
| - **`fits/rk_loocv.csv`** — the inaugural fit. One row per (mixture, |
| integer-rounded T-bin), keyed on `mixture_T_id`. See the schema below. |
| |
| Additional fits can be pushed alongside `fits/rk_loocv.csv` without |
| disturbing anything else; each has its own filename. |
| |
| ## Method: `rk_loocv` fit |
| |
| Per binary mixture and per integer-rounded T-bin (≥ 4 measurement rows), |
| fit the Redlich-Kister model: |
| |
| ``` |
| y(x) = β_2·(1 − x) + β_1·x + x(1 − x) · Σᵢ aᵢ (2x − 1)ⁱ for i = 0..p |
| └──── ψ (ideal) ─────┘ └──────── δ (excess) ──────────┘ |
| ``` |
| |
| The polynomial degree `p ∈ {0, 1, 2, 3}` is selected per bin via |
| **leave-one-out cross-validation** on the Predictive Average Relative |
| Deviation (PARD): |
| |
| ``` |
| PARD = (100 / N) · Σ_i |y_pred^(−i) − y_i| / |y_i| |
| ``` |
| |
| Closed-form LOO via the OLS hat-matrix diagonal: `r_loo_i = r_i / (1 − h_ii)`. |
| The winning `p` minimizes PARD. This is the methodology of Ramírez-de-Santiago, |
| *Viscosity of Binary Liquid Mixtures*, *Ind. Eng. Chem. Res.* 2024, 63, |
| 22470−22480 (§2, eqs 3–5). |
| |
| For `RkLoocvFitter`, `pure_at_x0` and `pure_at_x1` equal `β_2` and `β_1` |
| exactly (the excess vanishes at `x = 0` and `x = 1` because of the |
| `x(1 − x)` factor). `nonlinearity` is the L2 norm of the excess on `[0, 1]`, |
| computed analytically: `√(a^T G a)` where `G_ij = ∫₀¹ x²(1−x)² (2x−1)^(i+j) dx`. |
| |
| ## Loading |
| |
| ```python |
| import ast |
| from datasets import load_dataset |
| from huggingface_hub import hf_hub_download |
| import pandas as pd |
| |
| REPO = "ai4chems/nist-logv-binary" |
| |
| # Base data |
| points = load_dataset(REPO, split="train").to_pandas() |
| compounds = pd.read_csv(hf_hub_download(REPO, "compounds.csv", repo_type="dataset")) |
| |
| # RK-LOOCV fit |
| rk = pd.read_csv(hf_hub_download(REPO, "fits/rk_loocv.csv", repo_type="dataset")) |
| |
| # Sidecar cmp_ids columns come back as stringified lists — parse if needed: |
| rk["cmp_ids"] = rk["cmp_ids"].apply(ast.literal_eval) |
| rk["mixture_T_id"] = rk["mixture_T_id"].apply(ast.literal_eval) |
| |
| # Join points ↔ fit on mixture_T_id (single column). |
| points["mixture_T_id_t"] = points["mixture_T_id"].apply(tuple) |
| rk["mixture_T_id_t"] = rk["mixture_T_id"].apply(tuple) |
| joined = points.merge(rk, on="mixture_T_id_t", how="left", suffixes=("", "_fit")) |
| |
| # compound_id → SMILES lookup. |
| smiles = compounds.set_index("compound_id")["smiles"].to_dict() |
| ``` |
| |
| ## Reconstructing per-row predictions |
| |
| The fit CSV publishes the per-bin coefficients only; per-row predictions |
| are recomputable in closed form: |
| |
| ```python |
| import numpy as np |
| |
| def rk_predict(row): |
| """row from the joined frame: needs x_1, beta_1=pure_at_x1, beta_2=pure_at_x0, a_0..a_3.""" |
| x1_arr = np.array(row["cmp_mole_fractions"]) |
| c1 = min(row["cmp_ids"]) |
| x = float(x1_arr[list(row["cmp_ids"]).index(c1)]) |
| base = x * (1.0 - x) |
| skew = 2.0 * x - 1.0 |
| excess = 0.0 |
| for i in range(4): |
| a_i = row.get(f"a_{i}") |
| if a_i is not None and not np.isnan(a_i): |
| excess += a_i * (skew ** i) |
| return row["pure_at_x1"] * x + row["pure_at_x0"] * (1.0 - x) + base * excess |
| ``` |
| |
| `nonlinearity` and `linear_span = pure_at_x1 − pure_at_x0` are likewise |
| downstream computations. |
| |
| ## Schema |
| |
| ### `points` (HF dataset main payload) |
| |
| - `mixture_T_id` — `[cmp_id1_sorted, cmp_id2_sorted, round(T)]`. The join key. |
| - `value` — log viscosity (chemixhub-canonical column name). |
| - `T`, `P` — temperature (K), pressure (bar). |
| - `cmp_ids` — length-2 list of chemixhub compound IDs. |
| - `cmp_mole_fractions` — length-2 list of mole fractions, aligned with `cmp_ids`. |
| |
| ### `fits/rk_loocv.csv` |
| |
| Bin metadata (duplicated so the CSV is self-contained): |
| |
| - `mixture_T_id`, `cmp_ids`, `T` — keys. |
| - `n_in_bin` — number of measurement rows in this bin. |
| - `T_min`, `T_max`, `P_min`, `P_max` — actual spans of the bin's |
| measurements (`T_min` and `T_max` typically straddle `T`). |
| |
| Canonical fit columns (every fit CSV has these): |
| |
| - `pure_at_x0` — fitted curve at `x = 0`. |
| - `pure_at_x1` — fitted curve at `x = 1`. |
| - `nonlinearity` — L2 norm of `(curve − linear baseline)` on `[0, 1]`. |
| - `minima_x`, `minima_value` — `argmin` / `min` of the fitted curve on |
| `[0, 1]`; endpoints are valid candidates. Never NaN. |
| - `maxima_x`, `maxima_value` — `argmax` / `max` of the fitted curve on |
| `[0, 1]`; endpoints are valid candidates. Never NaN. |
| |
| `rk_loocv`-specific columns: |
| |
| - `best_p` — the LOOCV-selected RK degree (∈ {0, 1, 2, 3}). |
| - `best_pard` — the predictive ARD (%) at `best_p` (lower is better; |
| cross-validated, so it tracks generalization). |
| - `best_aard` — the training-set ARD (%) at `best_p` (lower-bounded by |
| PARD; closer to PARD ⇒ less overfitting headroom). |
| - `a_0`, `a_1`, `a_2`, `a_3` — RK excess coefficients. Coefficients with |
| index `i > best_p` are NaN. |
| |
| ## Source |
| |
| Built from chemixhub's `processed_NISTlogV.csv` |
| ([chemcognition-lab/chemixhub](https://github.com/chemcognition-lab/chemixhub)), |
| which derives from the NIST log-viscosity benchmark. Compound IDs are |
| those used by chemixhub. |
| |
| **Single-source filter**: every `(cmp_ids, round(T))` bin in the published |
| data comes from a single chemixhub `Ref_ID`. Bins where the source data |
| contained measurements from more than one reference were dropped at load |
| time, before fitting. Different references reporting the same nominal |
| measurement typically have systematic offsets, and pooling them would |
| distort the RK fit. |
| |