fusilli.utils.metrics_utilsο
Calculates metrics of the models and houses list of the available metrics to use.
Classes
|
Calculates metrics of the models and houses list of the available metrics to use. |
- class MetricsCalculator(base_model_instance)[source]ο
Bases:
object
Calculates metrics of the models and houses list of the available metrics to use.
- __init__(base_model_instance)[source]ο
- Parameters:
base_model_instance (fusilli.fusionmodels.base_model.BaseModel) β Instance of the base model. Has information on the prediction task and multiclass dimensions if applicable.
- accuracy(preds, labels, logits)[source]ο
Calculates accuracy.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
Accuracy value.
- Return type:
float
- auprc(preds, labels, logits)[source]ο
Calculates area under the precision-recall curve.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
AUPRC value.
- Return type:
float
- auroc(preds, labels, logits)[source]ο
Area under the receiver operating characteristic curve.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
AUROC value.
- Return type:
float
- balanced_accuracy(preds, labels, logits)[source]ο
Calculates balanced accuracy.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
Balanced accuracy value.
- Return type:
float
- f1(preds, labels, logits)[source]ο
Calculates F1 score. This is equivalent to the Dice coefficient.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
F1 score value.
- Return type:
float
- mae(preds, labels, logits)[source]ο
Calculates mean absolute error.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
MAE value.
- Return type:
float
- mse(preds, labels, logits)[source]ο
Calculates mean squared error.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
MSE value.
- Return type:
float
- precision(preds, labels, logits)[source]ο
Calculates precision.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
Precision value.
- Return type:
float
- r2(preds, labels, logits)[source]ο
Calculates R2 score.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
R2 score value.
- Return type:
float
- recall(preds, labels, logits)[source]ο
Calculates recall. This is equivalent to sensitivity.
- Parameters:
preds (torch.Tensor) β Predicted values from the model.
labels (torch.Tensor) β True labels.
logits (torch.Tensor) β Probability values from the model.
- Returns:
Recall value.
- Return type:
float