Edit on GitHub

starplast.prediction

Gene prediction with held-out groups, train-only preprocessing and explicit support.

UMAP is an optional intermediate representation, independent of the display map. Unknown labels are never negatives. Each outer fold reserves separate training and calibration groups; scores and uncertainty on test genes use neither their labels nor their fitted feature distribution. Network runs are explicitly transductive over a fixed, target-independent graph.

METHODS = ('prior', 'linear', 'boosted', 'neighbors', 'pca', 'umap', 'multiview', 'network')
@dataclass
class TaskSpec:

One outcome and validation contract; all settings are saved with a result.

TaskSpec( target: str, kind: str = 'classification', method: str = 'linear', features: tuple = (), group_column: str | None = 'orthogroup', folds: int = 3, seed: int = 42, dimensions: int = 20, neighbors: int = 15, min_feature_coverage: float = 0.05, min_gene_coverage: float = 0.1, min_probability: float = 0.0, calibrate: bool = True, interval_alpha: float = 0.1, exclude: tuple = (), blocks: dict = <factory>)
target: str
kind: str = 'classification'
method: str = 'linear'
features: tuple = ()
group_column: str | None = 'orthogroup'
folds: int = 3
seed: int = 42
dimensions: int = 20
neighbors: int = 15
min_feature_coverage: float = 0.05
min_gene_coverage: float = 0.1
min_probability: float = 0.0
calibrate: bool = True
interval_alpha: float = 0.1
exclude: tuple = ()
blocks: dict
@dataclass
class PredictionResult:

Held-out evaluations and unknown-gene hypotheses with reproducible provenance.

PredictionResult( spec: TaskSpec, predictions: pandas.DataFrame, metrics: dict, per_class: pandas.DataFrame, folds: list, provenance: dict, model: object = None)
spec: TaskSpec
predictions: pandas.DataFrame
metrics: dict
per_class: pandas.DataFrame
folds: list
provenance: dict
model: object = None
def save(self, directory):

Write ordinary CSV/JSON artifacts; fitted Python objects are not pickled.

def known_labels(series):

Boolean mask of observed categorical labels, preserving measured 0/False.

def group_ids(nodes, column):

Keep related genes together; genes with no group receive unique singleton IDs.

class FoldMatrix(sklearn.base.BaseEstimator, sklearn.base.TransformerMixin):

Fit feature filtering, median imputation, robust scaling and view weights on training genes.

FoldMatrix(min_coverage=0.05, blocks=None)
min_coverage
blocks
def fit(self, X, y=None):

Learn columns and all normalization statistics from this training frame only.

def transform(self, X):

Apply the frozen training transform; missing values map to training medians.

def coverage(self, X):

Fraction of retained measurements actually observed for each gene.

class MaskedFactors(sklearn.base.BaseEstimator, sklearn.base.TransformerMixin):

Train a low-rank representation by reconstructing only observed entries.

This is a masked matrix-completion baseline, not MOFA+. View balancing is supplied by FoldMatrix. New rows infer factors from observed features only.

MaskedFactors(components=20, iterations=12, ridge=0.1, seed=42)
components
iterations
ridge
seed
def fit(self, X, y=None):

Alternate low-rank reconstruction and replacement of missing entries.

def transform(self, X):

Solve regularized factors without using unknown feature entries.

def run(nodes, spec, log=<built-in function print>):

Evaluate held-out groups, then generate hypotheses for genuinely unlabelled genes.

All folds share the same frozen specification. For method selection, compare these development results and evaluate the selected method on a separate future dataset before claiming prospective performance.

def run_multilabel(nodes, targets, **kwargs):

Predict each measured trait independently; missing entries are never negative.

Targets must be separate observed binary columns, with NaN for unassayed genes. Every target and its registered family is excluded from the other target runs to avoid treating an unmeasured sibling phenotype as available input.