Log10#
- class torch_uncertainty.metrics.regression.Log10(**kwargs)[source]#
Computes the LOG10 metric.
The Log10 metric computes the mean absolute error in the base-10 logarithmic space.
\[\text{Log10} = \frac{1}{N} \sum_{i=1}^{N} |\log_{10}(y_i) - \log_{10}(\hat{y_i})|\]where: - \(N\) is the number of elements in the batch. - \(y_i\) represents the true target values. - \(\hat{y_i}\) represents the predicted values.
This metric is useful for scenarios where the data spans multiple orders of magnitude, and evaluating error in log-space provides a more meaningful comparison.
Inputs: -
preds
: \((N)\) -target
: \((N)\)- Parameters:
kwargs – Additional keyword arguments, see Advanced metric settings.
Example:
from torch_uncertainty.metrics.regression import Log10 import torch # Initialize the metric log10_metric = Log10() # Example predictions and targets preds = torch.tensor([10.0, 100.0, 1000.0]) target = torch.tensor([12.0, 95.0, 1020.0]) # Update the metric state log10_metric.update(preds, target) # Compute the Log10 error result = log10_metric.compute() print(f"Log10 Error: {result.item()}") # Output: Log10 Error: 0.03668594