Metrics
Metrics score model predictions against ground truth inside a benchmark. Summaries below are taken from each class docstring.
Area under the precision-recall curve.
- class bioverse.metrics.auprc.AuprcMetric(name='AUPRC', reduction='nanmean', **kwargs)[source]
Bases:
MetricArea under the precision-recall curve.
Area under the receiver operating characteristic curve.
- class bioverse.metrics.auroc.AurocMetric(name='AUROC', reduction='nanmean', **kwargs)[source]
Bases:
MetricArea under the receiver operating characteristic curve.
Balanced accuracy for binary classification.
- class bioverse.metrics.balanced_binary_accuracy.BalancedBinaryAccuracyMetric(name='Bal.Acc.', threshold=0.5, **kwargs)[source]
Bases:
MetricBalanced accuracy for binary classification.
Balanced accuracy averaged over classes.
- class bioverse.metrics.balanced_multi_class_accuracy.BalancedMultiClassAccuracyMetric(name='Bal.Acc.', **kwargs)[source]
Bases:
MetricBalanced accuracy averaged over classes.
Accuracy for binary classification tasks.
- class bioverse.metrics.binary_accuracy.BinaryAccuracyMetric(name='Accuracy', threshold=0.5, **kwargs)[source]
Bases:
MetricAccuracy for binary classification tasks.
Average BLOSUM62 substitution score between true and predicted residues.
- class bioverse.metrics.blosum_score.BlosumScoreMetric(name: str = 'Blosum Score', on_axis: int = 2, per: int = 1, reduction='nanmean', **kwargs)[source]
Bases:
MetricAverage BLOSUM62 substitution score between true and predicted residues.
Coefficient of determination (R²).
- class bioverse.metrics.coefficient_of_determination.CoefficientOfDeterminationMetric(name='R2', **kwargs)[source]
Bases:
MetricCoefficient of determination (R²).
Enrichment factor at a fixed false-positive rate.
- class bioverse.metrics.enrichment_factor.EnrichmentFactorMetric(name='Enrichment Factor', cutoff_fraction=0.2, **kwargs)[source]
Bases:
MetricEnrichment factor at a fixed false-positive rate.
F1 score (harmonic mean of precision and recall).
- class bioverse.metrics.f1_score.F1ScoreMetric(name='Accuracy', **kwargs)[source]
Bases:
MetricF1 score (harmonic mean of precision and recall).
Maximum F1 score over classification thresholds.
- class bioverse.metrics.fmax.FmaxMetric(name='Fmax', **kwargs)[source]
Bases:
MetricMaximum F1 score over classification thresholds.
Macro-averaged precision over classes.
- class bioverse.metrics.macro_precision.MacroPrecisionMetric(name='Precision', **kwargs)[source]
Bases:
MetricMacro-averaged precision over classes.
Macro-averaged recall over classes.
- class bioverse.metrics.macro_recall.MacroRecallMetric(name='Recall', **kwargs)[source]
Bases:
MetricMacro-averaged recall over classes.
Mean absolute error between predictions and targets.
- class bioverse.metrics.mean_absolute_error.MeanAbsoluteErrorMetric(name='MAE', **kwargs)[source]
Bases:
MetricMean absolute error between predictions and targets.
Mean rank of actives in virtual screening.
- class bioverse.metrics.mean_active_rank.MeanActiveRankMetric(name='Mean Active Rank', **kwargs)[source]
Bases:
MetricMean rank of actives in virtual screening.
Mean angular error between predicted and true vectors.
- class bioverse.metrics.mean_angular_error.MeanAngularErrorMetric(name='Angular MAE', **kwargs)[source]
Bases:
MetricMean angular error between predicted and true vectors.
Mean 1-based rank of catalytic residues by predicted attribution score.
- class bioverse.metrics.mean_catalytic_rank.MeanCatalyticRankMetric(name='Mean Catalytic Rank', on_axis=2, per=1, **kwargs)[source]
Bases:
MetricMean 1-based rank of catalytic residues by predicted attribution score.
Operates along the last axis so the parent
Metricon_axis/perflattening can keep one protein (or batch of proteins) together. Defaults match residue-level metrics such as Recovery: flatten the batch axis (on_axis=2) and score each update separately (per=1).
Mean squared error between predictions and targets.
- class bioverse.metrics.mean_squared_error.MeanSquaredErrorMetric(name='MSE', **kwargs)[source]
Bases:
MetricMean squared error between predictions and targets.
Multi-class classification accuracy (fraction of argmax-correct predictions).
- class bioverse.metrics.multi_class_accuracy.MultiClassAccuracyMetric(name='Accuracy', **kwargs)[source]
Bases:
MetricMulti-class classification accuracy (fraction of argmax-correct predictions).
Base class for metrics that compare predicted and true class indices via
argmax. Subclassed byRecoveryMetric.
Exact-match accuracy for multi-label classification.
- class bioverse.metrics.multi_label_accuracy.MultiLabelAccuracyMetric(name='Accuracy', threshold=0.5, **kwargs)[source]
Bases:
MetricExact-match accuracy for multi-label classification.
Fraction of ordered pairs whose predicted ranking matches the labels.
- class bioverse.metrics.pairwise_ranking_accuracy.PairwiseRankingAccuracyMetric(name='Pairwise ranking', **kwargs)[source]
Bases:
MetricFraction of ordered pairs whose predicted ranking matches the labels.
Ties in
y_trueare skipped. A pair withy_true[i] > y_true[j]is correct wheny_pred[i] > y_pred[j]. Constant predictions score 0.
Pearson correlation coefficient between predictions and targets.
- class bioverse.metrics.pearsons_r.PearsonsRMetric(name='Pearson', **kwargs)[source]
Bases:
MetricPearson correlation coefficient between predictions and targets.
Perplexity of a language-model distribution.
- class bioverse.metrics.perplexity.PerplexityMetric(name='Perplexity', **kwargs)[source]
Bases:
MetricPerplexity of a language-model distribution.
Precision (positive predictive value).
- class bioverse.metrics.precision.PrecisionMetric(name='Precision', **kwargs)[source]
Bases:
MetricPrecision (positive predictive value).
Recall (true positive rate).
- class bioverse.metrics.recall.RecallMetric(name='Recall', **kwargs)[source]
Bases:
MetricRecall (true positive rate).
Sequence recovery rate (fraction of correctly predicted residues).
- class bioverse.metrics.recovery.RecoveryMetric(name='Recovery', on_axis=2, per=1, reduction='nanmean', **kwargs)[source]
Bases:
MultiClassAccuracyMetricSequence recovery rate (fraction of correctly predicted residues).
Spearman rank correlation between predictions and targets.
- class bioverse.metrics.spearmans_rho.SpearmansRhoMetric(name='Spearman', **kwargs)[source]
Bases:
MetricSpearman rank correlation between predictions and targets.
Ranks use the mid-rank (average) convention for ties. The coefficient is Pearson’s r on those ranks, so a constant input is undefined (
nan) rather than an artifact of table order.
Top-k classification accuracy.
- class bioverse.metrics.top_k_accuracy.TopKAccuracyMetric(name='Accuracy', k=10, **kwargs)[source]
Bases:
MetricTop-k classification accuracy.
Enrichment of beneficial labels among the model’s top-k predictions.
- class bioverse.metrics.top_k_enrichment.TopKEnrichmentMetric(name='Top-k enrichment', k: int = 10, threshold=None, **kwargs)[source]
Bases:
MetricEnrichment of beneficial labels among the model’s top-k predictions.
A label is beneficial when it is strictly above
threshold, or above the mean ofy_truewhenthresholdisNone. The score is(beneficial in top-k / k) / (beneficial / n), i.e. 1.0 is random.
Precision of the top-k attribution scores against catalytic residues.
- class bioverse.metrics.top_k_precision.TopKPrecisionMetric(name='Top-k Precision', k: int = 5, on_axis=2, per=1, **kwargs)[source]
Bases:
MetricPrecision of the top-k attribution scores against catalytic residues.
Rankings are computed along the last axis. Defaults match residue-level metrics such as Recovery (
on_axis=2,per=1).
Fraction of catalytic residues recovered in the top-k attribution scores.
- class bioverse.metrics.top_k_recall.TopKRecallMetric(name='Top-k Recall', k: int = 5, on_axis=2, per=1, **kwargs)[source]
Bases:
MetricFraction of catalytic residues recovered in the top-k attribution scores.
Rankings are computed along the last axis. Defaults match residue-level metrics such as Recovery (
on_axis=2,per=1).
Recovery metric that gives credit when the predicted residue is within the top-k BLOSUM62 substitutions for the true residue.
- class bioverse.metrics.topk_recovery.TopkRecoveryMetric(name: str = 'Top-k Recovery', k: int = 1, on_axis: int = 2, per: int = 1, **kwargs)[source]
Bases:
MetricRecovery metric that gives credit when the predicted residue is within the top-k BLOSUM62 substitutions for the true residue.
Ranking is based on BLOSUM62 scores per true residue, with ties sharing the same rank (i.e. identical scores are treated as the same rank).
For k=1 this reduces to standard Recovery, since the true residue has the highest BLOSUM62 score with itself in the 20×20 amino-acid sub-matrix.
- __init__(name: str = 'Top-k Recovery', k: int = 1, on_axis: int = 2, per: int = 1, **kwargs)[source]
- Parameters:
k (int) – Number of BLOSUM-based substitution ranks to treat as correct. k=1 is equivalent to standard Recovery (exact match).
on_axis – Passed through to the base Metric to match RecoveryMetric behaviour (defaults: on_axis=2, per=1).
per – Passed through to the base Metric to match RecoveryMetric behaviour (defaults: on_axis=2, per=1).
- compute(y_true: Array, y_pred: Array)[source]
y_true: integer residue tokens in PROTEIN_ALPHABET order. y_pred: logits or probabilities over the same alphabet.