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 augmentation: BandRotationConfig | None = None[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.