scxpand.core.prediction#
Core prediction orchestration for scXpand models.
This module contains the high-level prediction pipeline that coordinates: - Model loading and setup - Data preprocessing and inference - Results evaluation and saving
It serves as the domain service layer that orchestrates different components without being tightly coupled to any specific implementation.
Functions
|
Complete prediction pipeline from model loading to evaluation. |
- scxpand.core.prediction.run_prediction_pipeline(model_path, model_type=None, adata=None, data_path=None, save_path=None, batch_size=1024, num_workers=0, eval_row_inds=None)#
Complete prediction pipeline from model loading to evaluation.
This is the main orchestration function that coordinates the entire prediction workflow. It follows the dependency inversion principle by depending on abstractions (interfaces) rather than concrete implementations.
- Parameters:
model_path (
str|Path) – Path to directory containing the trained model.model_type (
ModelType|str|None(default:None)) – Type of model to use for prediction. If None, automatically detected from model_type.txt file in model_path.adata (
AnnData|None(default:None)) – In-memory AnnData object (alternative to data_path).data_path (
str|Path|None(default:None)) – Path to data file (alternative to adata).save_path (
str|Path|None(default:None)) – Directory to save prediction results.batch_size (
int(default:1024)) – Batch size for inference.num_workers (
int(default:0)) – Number of workers for data loading.eval_row_inds (
ndarray|None(default:None)) – Specific cell indices to evaluate (None for all).
- Return type:
- Returns:
Structured results containing predictions and metrics (if available).
- Raises:
ValueError – If neither adata nor data_path is provided.
FileNotFoundError – If model_path doesn’t exist.