scxpand.core.inference_results#
Inference results data structure for scXpand models.
This module defines the InferenceResults dataclass that provides a structured way to return inference results instead of using dictionaries.
Classes
|
Structured results from scXpand model inference. |
|
Model metadata information. |
- class scxpand.core.inference_results.InferenceResults(predictions, metrics=None, model_info=None)#
Structured results from scXpand model inference.
This dataclass provides a clean, typed interface for accessing inference results instead of using dictionaries. It automatically handles cases where ground truth labels are not available (metrics will be None).
- Variables:
predictions – Array of prediction probabilities [0, 1] for each cell
metrics – Dictionary containing evaluation metrics (None if ground truth unavailable)
model_info – Model metadata information (None for local models)
Examples
>>> results = scxpand.run_inference( ... data_path="data.h5ad", model_path="model/" ... ) >>> print(f"Generated {len(results.predictions)} predictions") >>> if results.metrics: ... print(f"AUROC: {results.metrics['AUROC']:.3f}") >>> if results.model_info: ... print(f"Model type: {results.model_info.model_type}")
- __init__(predictions, metrics=None, model_info=None)#
- get_harmonic_avg_auroc()#
Get the harmonic average AUROC across strata if available.
- class scxpand.core.inference_results.ModelInfo(model_name=None, model_type=None, version=None, source=None, url=None)#
Model metadata information.
- Variables:
model_name – Name of the model (for registry models)
model_type – Type of model (e.g., “mlp”, “autoencoder”)
version – Model version (for registry models)
source – Source of the model (“local”, “registry”, “external_url”)
url – URL for external models
- __init__(model_name=None, model_type=None, version=None, source=None, url=None)#