mood-benchmark / README.md
mood-anonymous's picture
README: tighten Quick Start 3 phrasing
a11eda0 verified
|
Raw
History Blame Contribute Delete
12.1 kB
metadata
license: cc-by-4.0
language:
  - en
tags:
  - materials-science
  - out-of-distribution-detection
  - graph-neural-networks
  - benchmark
pretty_name: MOOD - Materials Out-of-Distribution Detection
configs:
  - config_name: default
    description: All retained (dataset, architecture, split) settings.

MOOD: Materials Out-of-Distribution Detection Benchmark

Pre-extracted graph neural network embeddings, trained checkpoints, density-flow models, OOD split indices, supervised-probe outputs, and detector evaluation artifacts for the MOOD benchmark.

Anonymous review submission. Authors and affiliations will be filled in at camera-ready. The accompanying source code lives at https://anonymous.4open.science/r/MOOD-Bench-820B/ during the review period.

Layout

Per-setting directories are keyed by <dataset>/<arch>/<split>/fold_0/ (or seed_42/ under flow_models/), where <dataset> is one of the five MatBench tasks, <arch> is one of alignn, cgcnn, schnet, dimenet, and <split> is one of the 15 OOD predicates. Most directories use the matbench_<dataset> form (matbench_dielectric, matbench_log_gvrh, etc.); risk_coverage/ is the lone exception and uses bare names (dielectric, log_gvrh, etc.).

Path Description Approx. size
embeddings/matbench_<dataset>/<arch>/<split>/fold_0/{train,id_test,ood_test}.npy Penultimate-layer GNN embeddings on ID train, ID test, and OOD test for every retained (dataset, architecture, split) setting. Released raw — not L2-normalized. Each fold_0/ also contains matching *_pred.npy and *_targets.npy for traceability. 1.1 GB
splits/matbench_<dataset>/<split>/{train_idx,id_test_idx,ood_test_idx,balanced_id_test_idx,balanced_ood_test_idx}.npy + stats.json MatBench-row indices for each split partition. The balanced_*_idx.npy files index the original MatBench dataset and are subsets of the corresponding *_test_idx.npy files; use them when evaluating on a 1:1 ID/OOD subsample. Also covers OMee data-driven split protocols (LOCO, SparseXcluster, SparseYcluster) under splits/omee/. 7 MB
checkpoints/matbench_<dataset>/<arch>/<split>/fold_0/{best_model.pt or *.keras, config.yaml} Trained GNN checkpoints. ALIGNN and CGCNN ship best_model.pt (PyTorch); SchNet and DimeNet++ ship *.keras (kgcnn). config.yaml documents the per-cell run (architecture, dataset, split_type, fold, embedding_dim, n_train / n_id_test / n_ood_test, best_val_mae). 3.4 GB
flow_models/matbench_<dataset>/<arch>/<split>/fold_0/seed_42/{flow_state.pt, id_log_prob.npy, ood_log_prob.npy, results.json, *_nll_history.npy} Trained Real-NVP normalising flows (8 coupling layers, hidden 128) plus pre-computed log-densities on ID and OOD test embeddings. 4.1 GB
linear_probes/matbench_<dataset>/<arch>/<split>/fold_0/results.json Per-setting linear-probe summary. Keys: mean_auroc, std_auroc, cv_aurocs (list of per-fold AUROCs from 5-fold stratified CV with C=1.0), n_id_used, n_ood_used, config. 1 MB
linear_probes_mlp/matbench_<dataset>/<arch>/<split>/fold_0/results.json Same per-setting summary for the MLP probe (hidden 256→128, alpha=1.0, early stopping). 1 MB
results/matbench_<dataset>/<arch>/<split>/fold_0/auroc.json Per-cell consolidated AUROC + FPR95 for every detector reported in the paper, plus a knn_sweep block over $k \in {5, 10, 20, 50} \times {\text{L2-norm}, \text{raw}}$. The metadata fields n_id_test and n_ood_test are the test-pool sizes used to compute these AUROCs. 1 MB
risk_coverage/<dataset>/<arch>/<split>/fold_0/<detector>/results.json Per-(cell, detector) risk–coverage curves for eight detectors with cluster-stored artifacts: flow, iforest, knn_k10, kpca, lof, mds_bic, norm, ocsvm. Keys: aurc_actual (the deployment-relevant AURC), aurc_oracle/aurc_random/aurc_constant (normalization references for SPE), spe, plus coverages and risks arrays for plotting. Note: this directory uses bare dataset names (dielectric/), not the matbench_dielectric/ prefix used elsewhere. 10 MB
croissant.json Croissant 1.0 metadata (Core + Responsible AI fields), enumerating every directory above.

Benchmark axes

  • 5 MatBench regression tasks: dielectric (refractive index), log_gvrh (log shear modulus), log_kvrh (log bulk modulus), perovskites (formation energy), phonons (highest phonon frequency).
  • 4 GNN architectures: ALIGNN ($d{=}256$), CGCNN ($d{=}128$), SchNet ($d{=}64$), DimeNet++ ($d{=}64$).
  • 15 deterministic OOD splits: 6 compositional (carbide, chalcogenide, halide, intermetallic, nitride, oxide) and 9 structural (cubic, hexagonal, tetragonal, orthorhombic, monoclinic, triclinic, high-spacegroup, low-spacegroup, perovskite).

The Cartesian product yields 300 candidate (dataset, architecture, split) settings; 257 are retained after filtering splits with fewer than 50 minority-class samples and excluding 7 settings where CGCNN training collapsed on phonons.

Representative sample for review

The full release is ~9.2 GB. For a smaller representative sample (NeurIPS Evaluations & Datasets requires a sample for datasets > 4 GB), the embeddings/matbench_dielectric/ subtree is a self-contained slice:

  • Size: ~132 MB (504 .npy files)
  • Coverage: 1 of 5 MatBench tasks (dielectric) × all 4 architectures (ALIGNN, CGCNN, SchNet, DimeNet++) × all 14 retained OOD splits × {train, id_test, ood_test} embeddings + matching *_pred.npy / *_targets.npy.
  • Sample URL: /embeddings/matbench_dielectric
  • How the sample was created: the dielectric task was selected as the smallest-by-disk method-bottlenecked dataset (132 MB embeddings) while still covering the full benchmark structure — every architecture and every retained split is represented, so a reviewer can drop in a detector via the Quick start below and reproduce the layout the benchmark exercises. The other 4 tasks (log_gvrh, log_kvrh, perovskites, phonons) follow the identical layout in the full release.

Setup

pip install huggingface_hub numpy scikit-learn

huggingface_hub and numpy are required for the first two examples; scikit-learn is needed only for the full reproduction example.

Quick start 1 — load embeddings for a new detector

import numpy as np
from huggingface_hub import hf_hub_download

REPO = "mood-anonymous/mood-benchmark"
SETTING = "matbench_dielectric/alignn/comp_halide/fold_0"

def fetch(name):
    return np.load(hf_hub_download(
        repo_id=REPO,
        filename=f"embeddings/{SETTING}/{name}.npy",
        repo_type="dataset",
    ))

z_train  = fetch("train")      # (n_train, d)   raw
z_id_te  = fetch("id_test")    # (n_id_test, d) raw
z_ood_te = fetch("ood_test")   # (n_ood_test, d) raw

# Distance- and KNN-based detectors should L2-normalize first; density-
# and isolation-based detectors typically use raw embeddings.
def l2(x): return x / np.linalg.norm(x, axis=1, keepdims=True)

Quick start 2 — read a per-cell risk–coverage curve

import json
from huggingface_hub import hf_hub_download

REPO = "mood-anonymous/mood-benchmark"
# risk_coverage/ uses bare dataset names (no "matbench_" prefix).
SETTING = "dielectric/alignn/comp_halide/fold_0"

with open(hf_hub_download(
    REPO,
    filename=f"risk_coverage/{SETTING}/mds_bic/results.json",
    repo_type="dataset",
)) as f:
    rc = json.load(f)

print("AURC (deployment):", rc["aurc_actual"])
print("SPE:",                rc["spe"])
# rc["coverages"] / rc["risks"] are arrays for plotting risk vs coverage.

Quick start 3 — end-to-end detector evaluation (KNN k=20 norm)

A full evaluation loop for one detector: load embeddings, L2-normalize for distance-based scoring, use the full ID and OOD test pools (sizes match the n_id_test / n_ood_test metadata in auroc.json), and compute AUROC.

import numpy as np
from huggingface_hub import hf_hub_download
from sklearn.neighbors import NearestNeighbors
from sklearn.metrics import roc_auc_score

REPO = "mood-anonymous/mood-benchmark"
SETTING = "matbench_dielectric/alignn/comp_halide/fold_0"

def load(p): return np.load(hf_hub_download(REPO, filename=p, repo_type="dataset"))
def l2(x):   return x / np.linalg.norm(x, axis=1, keepdims=True)

# 1. Load embeddings.
z_train  = load(f"embeddings/{SETTING}/train.npy")
z_id_te  = load(f"embeddings/{SETTING}/id_test.npy")
z_ood_te = load(f"embeddings/{SETTING}/ood_test.npy")

# 2. L2-normalize (standard convention for distance-based detectors).
z_train, z_id_te, z_ood_te = map(l2, (z_train, z_id_te, z_ood_te))

# 3. KNN k=20 — mean Euclidean distance to k nearest train neighbours,
#    sign-flipped so smaller distance scores higher (= more ID-like).
knn = NearestNeighbors(n_neighbors=20).fit(z_train)
score_id  = -knn.kneighbors(z_id_te,  return_distance=True)[0].mean(1)
score_ood = -knn.kneighbors(z_ood_te, return_distance=True)[0].mean(1)

# 4. AUROC (positive class = ID).
y = np.r_[np.ones(len(score_id)), np.zeros(len(score_ood))]
print(f"KNN k=20 norm AUROC: {roc_auc_score(y, np.r_[score_id, score_ood]):.4f}")

Per-cell AUROC and FPR95 for every reported detector are stored alongside in results/<setting>/auroc.json for reference.

Optional — class-balanced 1:1 subsample

The full ID and OOD test pools are typically not the same size (e.g. 350 vs 1259 for the example above). For a strict 1:1 protocol, use the balanced indices in splits/, which point into the original MatBench rows rather than into the test-array positions:

SPLIT = "splits/matbench_dielectric/comp_halide"

id_test_idx  = load(f"{SPLIT}/id_test_idx.npy")
ood_test_idx = load(f"{SPLIT}/ood_test_idx.npy")
bal_id_idx   = load(f"{SPLIT}/balanced_id_test_idx.npy")
bal_ood_idx  = load(f"{SPLIT}/balanced_ood_test_idx.npy")

# Map MatBench-row indices in balanced_*_idx → positions in the test arrays.
def positions(test_idx, balanced_idx):
    pos = {int(i): k for k, i in enumerate(test_idx)}
    return np.array([pos[int(i)] for i in balanced_idx])

z_id_b  = z_id_te [positions(id_test_idx,  bal_id_idx )]
z_ood_b = z_ood_te[positions(ood_test_idx, bal_ood_idx)]
# Now |z_id_b| == |z_ood_b| == min(|ID_test|, |OOD_test|).

Intended uses

  • Evaluating new post-hoc OOD detectors on materials property prediction GNNs without retraining the encoder (use embeddings/).
  • Replicating the supervised-probe ceiling that drives the bottleneck classification (use linear_probes/ and linear_probes_mlp/).
  • Re-aggregating the headline AUROC matrix or computing alternative metrics on top of per-cell raw scores (use results/).
  • Replotting risk–coverage curves at any coverage threshold or computing alternative selective-prediction metrics (use risk_coverage/).
  • Re-running detectors that need the trained density model (use flow_models/) or that need the full GNN forward pass on novel inputs (use checkpoints/).
  • Studying the bottleneck dichotomy: dielectric and log_gvrh exhibit method bottlenecks (probe recovers signal, detectors do not); log_kvrh, perovskites, phonons exhibit encoder bottlenecks (no method recovers signal).

License

All released artifacts (embeddings, checkpoints, flow models, probe outputs, AUROC tables, risk–coverage curves): CC-BY-4.0.

Source MatBench data is not redistributed in this archive; it remains under its original Materials Project licensing terms and is obtained through the standard matminer loader.

Citation

@misc{mood2026,
  title        = {MOOD: Benchmarking Post-Hoc OOD Detection for Materials Property Prediction},
  author       = {Anonymous},
  year         = {2026},
  note         = {Under review},
  howpublished = {\url{https://anonymous.4open.science/r/MOOD-Bench-820B/}}
}