AIICE
aiice.AIICE
High-level interface for loading Arctic ice data, preparing datasets, and benchmarking models.
This class provides a simple API to:
- Load historical ice data within a specified date range (see
aiice.loader.Loader) - Convert the data into sliding-window datasets (see
aiice.preprocess.SlidingWindowDataset) - Create a PyTorch DataLoader for batch processing
- Benchmark any PyTorch model on the OSI-SAF dataset with specified metrics
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pre_history_len
|
`int`
|
Number of past time steps to include in each input sample (X). |
required |
forecast_len
|
`int`
|
Number of future time steps to predict (Y) in each sample. |
required |
batch_size
|
`int`
|
Batch size for the DataLoader. Defaults to 16. |
16
|
start
|
`date`, `str`
|
Start date of the data to load. If None, defaults to the earliest available data. |
None
|
end
|
`date`, `str`
|
End date of the data to load. If None, defaults to the latest available data. |
None
|
step
|
`int` or `str`
|
Step between files. If |
None
|
threshold
|
`float`
|
Threshold for binarizing the target Y. Values above threshold are set to 1, below or equal set to 0. Defaults to None. |
None
|
x_binarize
|
`bool`
|
Whether to apply the same threshold binarization to input X. Defaults to False. |
False
|
threads
|
`int`
|
Number of parallel download threads. You can reduce this value in case of rate limiting HuggingFace API errors. Defaults to 16. |
16
|
device
|
`str`
|
Device to place tensors on ("cpu", "cuda", etc.). If None, uses PyTorch default device. |
None
|
Example
aiice = AIICE(pre_history_len=30, forecast_len=7, batch_size=32, start="2022-01-01", end="2022-12-31")
model = MyModel()
results = aiice.bench(model, metrics={"mae", "psnr"})
Source code in src/aiice/benchmark.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
bench
bench(model: Module, metrics: dict[str, MetricFn] | list[str] | None = None, path: str | None = None, detailed: bool = True, plot_workers: int = 4, fps: int = 2) -> dict[str, list[float]]
Run benchmarking evaluation of a model on the prepared dataset.
The method iterates over the internal DataLoader, generates model predictions, computes evaluation metrics, and optionally produces visualization GIFs comparing ground truth and predicted forecasts.
When path is provided, visualization generation is executed
asynchronously using a thread pool so that plotting does not block
model inference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
`nn.Module`
|
PyTorch model used to generate predictions. The model is expected
to accept inputs |
required |
metrics
|
`dict[str, MetricFn]` or `list[str]`
|
Metrics to compute during evaluation. If a list of metric names is
provided, the metrics are resolved from the built-in registry.
If |
None
|
path
|
`str`
|
Directory where forecast visualizations will be saved. If provided, each sample in the dataset will produce a GIF animation showing the forecast horizon, comparing ground truth and model predictions frame by frame. The files are named: |
None
|
detailed
|
`bool`
|
If True, returns full statistics for each metric like mean, last value, count, min, and max. If False, returns only the mean value per metric. |
True
|
plot_workers
|
`int`
|
Number of worker threads used for asynchronous plot generation. Increasing this value can speed up visualization when many samples are processed. Defaults to 4. |
4
|
fps
|
`int`
|
Frames per second of the generated GIF animations. Defaults to 2. |
2
|
Returns:
| Type | Description |
|---|---|
dict[str, list[float]]
|
|
Source code in src/aiice/benchmark.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |