neuralbench.main.Experiment

pydantic model neuralbench.main.Experiment[source][source]

Brain-modeling experiment with support for loading pretrained weights.

Fields:
field task_name: str = ''[source]
field data: Data [Required][source]
field target_scaler: StandardScaler | None = None[source]
field compute_class_weights: bool = False[source]
field brain_model_config: BaseModelConfig [Required][source]
field brain_model_output_size: int | None = None[source]
field pretrained_weights_fname: str | None = None[source]
field downstream_model_wrapper: DownstreamWrapper | None = None[source]
field trainer_config: TrainerConfig [Required][source]
field loss: BaseLoss [Required][source]
field lightning_optimizer_config: LightningOptimizer [Required][source]
field eval_only: bool = False[source]
field metrics: list[BaseMetric] [Required][source]
field validate_before_training: bool = True[source]
field test_full_metrics: list[BaseMetric] = [][source]
field test_full_retrieval_metrics: list[BaseMetric] = [][source]
field save_test_predictions: bool = False[source]
field csv_config: CsvLoggerConfig | None = None[source]
field wandb_config: WandbLoggerConfig | None = None[source]
field seed: int = 0[source]
field delete_checkpoints_on_exit: bool = True[source]
field infra: TaskInfra = TaskInfra(version='1')[source]
field dummy: dict[str, Any] = {}[source]
field brain_model_name: str = ''[source]
prepare_pl_module(train_loader: DataLoader, val_loader: DataLoader | None = None) None[source][source]
fit(trainer: Trainer, train_loader: DataLoader, valid_loader: DataLoader) None[source][source]
setup_wandb_logger(wandb_config: WandbLoggerConfig, savedir: str) WandbLogger[source][source]

Setup wandb logger and launch initialization.

setup_run()[source][source]

Setup paths and wandb logger.

setup_trainer(is_test: bool = False) Trainer[source][source]

Create callbacks and setup Trainer.

property run: dict[str, Any][source]

setup, train, test, cleanup.

Returns a dict of test metrics (e.g. {"test/bal_acc": 0.85, ...}) plus n_total_params and n_trainable_params.

Type:

Execute the full experiment lifecycle

test_predictions() dict[str, Any][source][source]

Raw per-window test predictions.

Requires save_test_predictions=True. Returns a dict with:

  • "metadata": a pandas.DataFrame with one row per test window (timeline, batch_idx, dataloader_idx, plus subject_id and a retrieval group label when available);

  • "y_true" / "y_pred": arrays of shape (n_windows, ...) aligned with metadata, concatenated across batches.

WindowPredictionCollector streams the predictions to the uid folder during the test loop (metadata as CSV, arrays appended to a shared memmap file), so they survive cache hits and are read straight from disk. This is a read-only accessor: call run() first (a cache hit is fine); if the artifacts are missing it raises rather than launching a run. The per-batch array chunks are concatenated on read, so loading materializes the full arrays in RAM.