smftools.analysis.compute.ml_metrics#

Matrix-level helpers for binary classifier fitting and evaluation.

Inputs are feature matrices, labels, and metadata-derived parameters. No AnnData access or file I/O occurs here.

Functions

build_binary_classifier(model_name[, ...])

Construct a supported binary sklearn classifier pipeline.

evaluate_binary_classifier(y_true, y_score)

Evaluate a binary classifier from labels and positive-class scores.

fit_classifier(estimator, X_train, y_train)

Fit and return a fresh copy of an estimator.

make_metrics_row(**kwargs)

Build a summary row dictionary, dropping keys with value None.

normalize_pr_auc(pr_auc, pos_freq)

Express PR AUC as fold improvement over the baseline positive frequency.

predict_binary_scores(model, X)

Return a continuous positive-class score for a fitted binary classifier.

smftools.analysis.compute.ml_metrics.build_binary_classifier(model_name, random_state=42, **kwargs)#

Construct a supported binary sklearn classifier pipeline.

smftools.analysis.compute.ml_metrics.fit_classifier(estimator, X_train, y_train)#

Fit and return a fresh copy of an estimator.

smftools.analysis.compute.ml_metrics.predict_binary_scores(model, X)#

Return a continuous positive-class score for a fitted binary classifier.

Return type:

ndarray

smftools.analysis.compute.ml_metrics.normalize_pr_auc(pr_auc, pos_freq)#

Express PR AUC as fold improvement over the baseline positive frequency.

Return type:

float

smftools.analysis.compute.ml_metrics.evaluate_binary_classifier(y_true, y_score, y_pred=None, prefix='test', target_eval_freq=None, random_state=42)#

Evaluate a binary classifier from labels and positive-class scores.

Return type:

dict

smftools.analysis.compute.ml_metrics.make_metrics_row(**kwargs)#

Build a summary row dictionary, dropping keys with value None.

Return type:

dict