scores.RandomScore
Returns random uncertainty scores per sample.
Usage
scores.RandomScore()This score assigns a random float in [0, 1] to each sample. It is useful as a baseline or for testing purposes. By default, the threshold is set to 0.99, so approximately 99% of samples are selected.
Methods
| Name | Description |
|---|---|
| fit() | Unused. |
| score() | Compute a random uncertainty score for every sample in a batch. |
| select() | Select samples for prediction based on their random uncertainty score. |
fit()
Unused.
Usage
fit(X=None, Y=None)score()
Compute a random uncertainty score for every sample in a batch.
Usage
score(X)Returns random scores where low values indicate likely inliers and high values indicate likely outliers.
Parameters
X: torch.Tensor-
Input batch of shape
(B, ...). Only the batch size is used.
Returns
torch.Tensor-
1-D tensor of shape
(B,)with uniform random scores in[0, 1].
Examples
import torch
from seapig.scores import RandomScore
score = RandomScore()
scores = score.score(torch.zeros(4, 10))select()
Select samples for prediction based on their random uncertainty score.
Usage
select(X)Samples with scores lower than the threshold are selected for prediction.
Parameters
X: torch.Tensor-
Input batch of shape
(B, ...). Only the batch size is used.
Returns
dict[str, torch.Tensor]-
A dict with keys
'score'(random scores) and'selected'(boolean mask whereTruemeans the sample is selected).
Examples
import torch
from seapig.scores import RandomScore
score = RandomScore()
result = score.select(torch.zeros(4, 10))
# result['selected'] is a boolean tensor of shape (4,)