spektran/spektran-ch4-v0
Viewer • Updated • 36k • 48
How to use spektran/spektran-baselines-v0 with Scikit-learn:
from huggingface_hub import hf_hub_download
import joblib
model = joblib.load(
hf_hub_download("spektran/spektran-baselines-v0", "sklearn_model.joblib")
)
# only load pickle files from sources you trust
# read more about it here https://skops.readthedocs.io/en/stable/persistence.htmlPre-trained baseline model weights for the SPEKTRAN gas-sensing benchmark. These allow inference on SPEKTRAN data without retraining.
| Checkpoint | Task | Input | Output | Val MAE |
|---|---|---|---|---|
ridge-t1-da/ |
T1 Concentration | DA raw scan (2000 pts) | ppm | 2.80 ppm |
cnn1d-t1-da/ |
T1 Concentration | DA raw scan (2000 pts) | ppm | 16.79 ppm |
ridge-t4-wms/ |
T4 WMS Concentration | WMS 2f signal | ppm | 12.46 ppm |
ridge-t9-temperature/ |
T9 Temperature | DA raw scan (2000 pts) | K | 7.03 K |
import numpy as np
data = np.load("ridge-t1-da/weights.npz")
# Normalize input
X_scaled = (raw_scan - data["scaler_mean"]) / data["scaler_scale"]
# Predict
concentration_ppm = X_scaled @ data["coef"] + data["intercept"][0]
import torch
import torch.nn as nn
import numpy as np
norm = np.load("cnn1d-t1-da/normalization.npz")
state = torch.load("cnn1d-t1-da/model.pt", weights_only=True)
model = nn.Sequential(
nn.Conv1d(1, 16, 15, stride=2, padding=7), nn.ReLU(),
nn.Conv1d(16, 32, 9, stride=2, padding=4), nn.ReLU(),
nn.Conv1d(32, 64, 5, stride=2, padding=2), nn.ReLU(),
nn.AdaptiveAvgPool1d(8), nn.Flatten(),
nn.Linear(64 * 8, 64), nn.ReLU(), nn.Linear(64, 1),
)
model.load_state_dict(state)
# Normalize and predict
x = torch.tensor((raw_scan - norm["input_mean"]) / norm["input_std"],
dtype=torch.float32).unsqueeze(0).unsqueeze(0)
with torch.no_grad():
z = model(x).item()
concentration_ppm = float(np.expm1(z * norm["target_std"][0] + norm["target_mean"][0]))
All models were trained on SPEKTRAN v0.5.0 official splits:
pip install spektran[dev] scikit-learn torch
python scripts/train_and_export_baselines.py --out checkpoints/
See baselines/README.md for full reproduction instructions and benchmark results.
@software{spektran2026,
title = {SPEKTRAN: Synthetic ML Training Data for Gas Sensing},
url = {https://github.com/spektran/spektran},
doi = {10.5281/zenodo.21790394},
version = {0.5.0},
year = {2026},
}