---
title: predictor
sidebarTitle: predictor
---

# `catalax.predictor`

## Classes

### `Predictor` <sup><a href="https://github.com/JR-1991/Catalax/blob/master/catalax/predictor.py#L16" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


Abstract base class for predictors in the catalax framework.

All predictors must implement the predict method which takes a dataset
and returns predictions based on the model.


**Methods:**

#### `widget` <sup><a href="https://github.com/JR-1991/Catalax/blob/master/catalax/predictor.py#L24" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
widget(self, model: Model, t0: float = 0.0, t1: float = 100.0, ref_measurement: Optional[Measurement] = None)
```

Create an interactive widget for exploring Neural ODE predictions with adjustable initial conditions.

This function creates a comprehensive interactive interface that allows users to:
- Adjust initial conditions for each species in the model
- Modify the end time for predictions
- View real-time updates of the prediction plot
- Reset all values to defaults with a single click

**Args:**
- `model`: The model containing species information and structure
- `predictor`: The predictor object for generating predictions (e.g., trained Neural ODE)
- `t0`: Start time for predictions (default\: 0.0)
- `t1`: End time for predictions (default\: 100.0)
- `ref_measurement`: Reference measurement containing initial conditions to use as defaults.
            If None, uses default values of 10.0 for all species
- `plot_style`: Dictionary of matplotlib styling options. Merged with defaults\:
       - figsize\: (12, 6)
       - linewidth\: 2.5
       - alpha\: 0.8
       - grid\: True
       - grid_alpha\: 0.3

**Returns:**
- Interactive widget with text inputs and plot output. The widget automatically
- displays upon creation and updates plots in real-time as inputs change.

**Raises:**
- `ValueError`: If the model or predictor are invalid
- `RuntimeError`: If widget creation fails


#### `get_species_order` <sup><a href="https://github.com/JR-1991/Catalax/blob/master/catalax/predictor.py#L83" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
get_species_order(self) -> list[str]
```

Get the species order of the predictor.


#### `get_state_order` <sup><a href="https://github.com/JR-1991/Catalax/blob/master/catalax/predictor.py#L90" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
get_state_order(self) -> list[str]
```

Get the state order of the predictor.


#### `predict` <sup><a href="https://github.com/JR-1991/Catalax/blob/master/catalax/predictor.py#L97" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
predict(self, dataset: Dataset, config: Optional[SimulationConfig] = None, n_steps: int = 100, use_times: bool = False, hdi: Optional[Literal['lower', 'upper', 'lower_50', 'upper_50']] = None) -> Dataset
```

Make predictions using the predictor.

**Args:**
- `dataset`: Dataset containing initial conditions
- `config`: Optional simulation configuration parameters
- `n_steps`: Number of time steps to simulate
- `use_times`: Whether to use the time points from the dataset or to simulate at fixed time steps
- `**kwargs`: Additional keyword arguments specific to the predictor implementation

**Returns:**
- Dataset containing the predictions


#### `n_parameters` <sup><a href="https://github.com/JR-1991/Catalax/blob/master/catalax/predictor.py#L120" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
n_parameters(self) -> int
```

Get the number of parameters of the predictor.

