simet.services.roc_auc¶
simet.services.roc_auc ¶
RocAucService ¶
Utilities for feature standardization used in ROC-AUC workflows.
standardize_train
staticmethod
¶
standardize_train(X)
Fit standardization parameters on X and return the standardized data.
Computes per-feature mean and standard deviation over the batch and returns the standardized tensor along with the fitted parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
Tensor
|
Input features of shape |
required |
Returns:
| Type | Description |
|---|---|
tuple[Tensor, Tensor, Tensor]
|
tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
- |
Notes
- Uses
sigma = std.clamp_min(1e-6)to avoid division by zero. - Statistics are computed along
dim=0withkeepdim=Trueso they broadcast correctly when standardizing. - For reproducible pipelines, persist
muandsigmafor use on validation/test sets.
Source code in simet/services/roc_auc.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
standardize_with
staticmethod
¶
standardize_with(X, mu, sigma)
Standardize X using provided per-feature mean and std.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
Tensor
|
Input features, shape |
required |
mu
|
Tensor
|
Per-feature mean, shape |
required |
sigma
|
Tensor
|
Per-feature std, shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Standardized features of the same shape/dtype/device as |
Notes
muandsigmaare typically obtained fromstandardize_trainon the training set and reused for validation/test to avoid data leakage.- Relies on PyTorch broadcasting; alternative shapes that broadcast
(e.g.,
(n_features,)) are also accepted.
Source code in simet/services/roc_auc.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |