"""Configuration for the xpectra weathered-unknowns study."""
from __future__ import annotations
from dataclasses import dataclass, field
from pathlib import Path
from ._paths import find_project_root
ROUTES = ("norm", "deriv1", "deriv2")
MODEL_NAMES = (
"Logistic Regression",
"SVM (RBF)",
"Random Forest (200)",
"XGBoost (100)",
"MLP (128,64)",
)
CALIBRATION_METHODS = ("none", "sigmoid", "isotonic", "temperature")
[docs]
@dataclass(frozen=True)
class TrustConfig:
routes: tuple[str, ...] = ROUTES
model_names: tuple[str, ...] = MODEL_NAMES
calibration_methods: tuple[str, ...] = CALIBRATION_METHODS
cv_folds: int = 5
test_size: float = 0.2
ece_bins: int = 15
# Drop exact-duplicate spectra (within study) so repeats can't leak across a
# random split or over-weight one study under LOSO. Only villegas_camacho
# carries any (348 rows, mostly PS/PVC); the other three studies have none.
dedupe_spectra: bool = True
# OOD
pca_components_ood: int = 20
knn_k: int = 5
target_coverage: float = 0.90
# Semi-supervised
pca_components_ssl: int = 50
self_train_threshold: float = 0.90
self_train_max_iter: int = 3
label_spread_neighbors: int = 10
# Weathering bands (cm^-1). Reference = CH2 scissoring ~1460.
carbonyl_band: tuple[float, float] = (1650.0, 1800.0)
reference_band: tuple[float, float] = (1420.0, 1470.0)
random_state: int = 42
# Working-data locations. Resolved at instantiation time relative to the user's project
# directory (found by walking up from cwd), NOT the package install location — the
# package may live in site-packages while the data lives with the notebooks.
processed_dir: Path = field(default_factory=lambda: find_project_root() / "processed_data")
results_dir: Path = field(default_factory=lambda: find_project_root() / "results")
figures_dir: Path = field(default_factory=lambda: find_project_root() / "figures")
cache_dir: Path = field(default_factory=lambda: find_project_root() / ".cache" / "xpectra")
[docs]
def ensure_dirs(self) -> None:
for path in (self.results_dir, self.figures_dir, self.cache_dir):
path.mkdir(parents=True, exist_ok=True)