Skip to main content

Choosing hyperparameters

Which settings matter, what they do, and how to set them

Guidance on choosing the hyperparameters of the NLSA Python toolkit: training and validation periods, delay window, predictors, kernel bandwidth and normalization, number of eigenfunctions, Koopman regularization, forecast horizon, and computing resources, with the values used for ENSO and blanks still to be filled for the MJO and station experiments.
NoteHow to read this page

The guidance below combines the settings of the example scripts with the practice of the published work on these methods. It gives starting points, not final answers: every value should be confirmed by validation on the data at hand. Values written ___ have not yet been fixed for the MJO and station experiments; they are to be filled in from the experiment logs, or from the tuning described here.

A tuning workflow

  1. Fix the problem. Choose the target, the lead times and the sampling (monthly or daily). These follow from the forecast question, not from tuning.
  2. Split the record in time. Keep the last part of the record as the test period, untouched until the end. Within the training period, hold out its last stretch (for example the last 15–20%) as a validation period for tuning. Compute the climatology from the training period only.
  3. Start from the defaults in the table below, and check the diagnostics: the bandwidth tuning curve, the kernel eigenvalues, and (for Koopman analysis) the generator spectrum.
  4. Tune one setting at a time, in order of influence: delay window, number of eigenfunctions in the forecast, then the kernel settings. Judge by validation skill (NRMSE and anomaly correlation) at the lead times that matter.
  5. Freeze the settings, retrain on the full training period, and score once on the test period.

The run modes help here: compute the data and kernel eigenfunctions once ("calcsave"), then vary the later settings with the earlier steps in "read" mode. Every setting is part of the output folder name, so runs never overwrite each other.

Summary

Hyperparameters, with the values of the ENSO examples and those still to be set
Setting Option ENSO, monthly (from the scripts) MJO, daily Stations, daily
Training period Time.date_range 1940–2019 1975–___ ___
Test period Time.date_range 2018–2025, 1986–2022 or 2016–2025 (overlapping the training period) ___ (after training) ___ (after training)
Delay window, half-width h DataPars.num_half_delays 6 (KAF), 24 (Koopman) ___ ___
Annual cycle in the predictors Climatology.remove Kept (False) ___ Removed (True)
Grid thinning Domain.step_lon, step_lat 4 (1° spacing) step_lon = ___ —
Cone kernel ConePars.zeta 0.99 (KAF), none (Koopman) ___ ___
Bandwidth factor TunePars.bandwidth_scl 1, 1.5 or 2 ___ ___
Kernel eigenfunctions, solver num_eigs, eigensolver 512, "eigh" ___, "eigh" or "eigsh" ___, "eigh"
Eigenfunctions in KAF PredPars.which_eigs 512 ___ ___
Koopman regularization KoopmanParsDiff.tau 0.005–0.01 ___ —
Galerkin basis which_eigs_galerkin 64–256 ___ —
Koopman eigenfunctions kept KoopmanParsDiff.num_eigs 65 ___ —
Forecast steps PredPars.num_steps 24 months 60 days 5 days (Pituffik), 14 days (other stations)

Five more settings are the same in all the ENSO examples, and are suggested unchanged for the MJO and station experiments: standardized predictors (Climatology.standardize = True), a variable bandwidth (TrainPars.bw_tune given as a TunePars), the "fokkerplanck" normalization (DmKernelPars.normalization), finite differences of order 4 (fd_order, velocity_fd_order), and single precision (FP = "f32").

Training and test periods

  • Chronological split. The test period must come after the training period, and no training sample may have its delay window or its forecast window (the num_steps steps after it) inside the test period. The ENSO examples do not follow this rule (see Experiments), so their skill over the overlap is partly in-sample.
  • Climatology from the training period. Set custom_climatology_date_range to the training period for both training and test data.
  • How much training data. Kernel methods need the training data to visit the states that the forecasts start from. Monthly data give about 12 samples per year (about 1,000 for 1940–2025); daily data give many more, but successive days are strongly correlated, so 50 years of daily data are not 30 times more informative than 50 years of monthly data. To see how much the record length matters, shorten the training period (for example 1975–2000 instead of 1975–2015) and compare the skill.

Delay window

The delay window (2h + 1 snapshots) is usually the most influential setting.

  • What it does. A longer window gives each sample more history, which helps to tell growing from decaying phases and filters out noise. For Koopman analysis, longer windows make the kernel eigenfunctions closer to Koopman eigenfunctions (Das and Giannakis 2019), which is why the Koopman example uses a 49-month window. But each extra delay removes a sample, makes the samples longer (more memory and computation), and can blur short-lived features.
  • Rule of thumb. Make the window a substantial fraction of the time scale of the phenomenon: 1 to 4 years for ENSO (13 and 49 months in the examples); for the MJO, whose cycle takes 30 to 90 days, a few weeks to two months; for station weather, governed by systems lasting days, a few days to two weeks.
  • How to choose. Compare validation skill for a few values, for example h = 0, 3, 6, 12 months for ENSO forecasts. For the MJO and stations: h = ___.

Predictors

  • Domain. Include the regions where the precursors of the target develop. A larger domain adds information but also unrelated variability. For ENSO forecasts, the Niño 3.4 region alone already gives skill; the Indo-Pacific domain is used to extract the global patterns.
  • Grid thinning. For large-scale patterns, every 4th point of ERA5’s 0.25° grid (1° spacing) is enough, and much cheaper than the full grid.
  • Annual cycle. Keeping the annual cycle in the predictors (Climatology(remove=False)) lets the kernel know the season, which matters for ENSO, whose evolution depends on the season. Remove it from the target (remove=True), which is then an anomaly.
  • Several predictor blocks. When station and ERA5 predictors are combined, their weights depend on the number of columns each contributes (see Data). Compare validation skill with each block alone and together.

Kernel

  • Bandwidth. Chosen automatically. Check the tuning curve (plots "bandwidth_tuning" and "kernel_tuning"): it should have a clear maximum inside the trial range. If the maximum is at an edge, widen log10_bandwidth_lims. Leave manifold_dim at None.
  • Bandwidth factor (bandwidth_scl). Values above 1 give a wider kernel and smoother eigenfunctions, which are more robust when extended to new samples but resolve less detail. The examples use 1 to 2; values between 1 and 2 are a sensible range to test.
  • Variable bandwidth. Keep it on: it adapts the kernel to sparse regions of the data, such as extreme states.
  • Cone kernel. ζ = 0.99, close to the maximum of 1, is the usual choice. It aligns the kernel with the direction of the dynamics, which can help forecasts; compare with and without it.
  • Normalization. "fokkerplanck" (α = ½) is the default of all examples. "laplace" (α = 1) removes the influence of the sampling density entirely. The bistochastic normalization is an alternative with similar behaviour.
  • Number of kernel eigenfunctions and solver. Compute at least as many as the largest number used later (in KAF or the Galerkin basis), and no more than the number of samples. Use the direct solver "eigh" while the N × N matrix fits in memory (see below), and the iterative solver "eigsh" beyond; the cost of "eigsh" grows with num_eigs.

Number of eigenfunctions in forecasts

which_eigs (or which_kernel_eigs) sets how many kernel eigenfunctions, L, the kernel analog forecast uses, and is the main setting of the forecast itself.

  • Small L: smooth forecasts that relax toward the climatology; less variance, more bias.
  • Large L: forecasts that follow the training data more closely; at L close to the number of samples, the forecasts can amplify noise, because the out-of-sample extension divides by the small eigenvalues.
  • How to choose. Scan L on a logarithmic grid (for example 16, 32, 64, …, up to num_eigs) and pick the value with the best validation skill. The best L can differ between short and long leads; the code uses one value for all leads. The ENSO examples use L = 512, about half the number of training samples. For the MJO and stations: L = ___.

Koopman analysis

  • Regularization τ. Too small, and rough, poorly resolved functions appear among the eigenfunctions with unstable frequencies; too large, and the physical modes are damped and mixed. Scan τ over, for example, 10⁻³ to 10⁻¹, and look for a range where the frequencies of the modes of interest (the annual cycle at 1 cycle per year, ENSO at 0.2–0.33 cycles per year, the MJO at periods of 30–90 days) are stable and their Dirichlet energies small. The ENSO examples use 0.005 and 0.01. The value of τ that works depends on the scale of the Laplace eigenvalues, which depends on the kernel bandwidth, so it does not carry over unchanged between data sets.
  • Galerkin basis. A larger basis resolves more modes but needs a larger τ to suppress rough ones. The examples use 64 and 256 functions. Check that the modes of interest stay the same when the basis grows.
  • Eigenfunctions kept (num_eigs). Enough to contain the modes of interest when sorted by energy; 65 in the examples.
  • Sorting. sort_by="energy" puts the smooth, physically meaningful modes first. Identify the mode of interest by its frequency and pattern, since its index changes with the settings.
  • Finite-difference order. 4 in all examples; higher orders are more accurate for smooth data but more sensitive to noise.

Forecast horizon

num_steps sets the longest lead. Leads beyond the limit of predictability add computation but no information: 24 months for ENSO, 60 days for the MJO, and 5 to 14 days for station weather (with weekly and monthly means for longer leads). Skill is commonly considered useful while the anomaly correlation stays above about 0.5 and the NRMSE below 1, and it is meaningful only relative to the persistence and climatology baselines (see Skill and outputs).

Computing resources

The kernel matrix has N × N entries for N training samples, and its memory grows quickly:

Memory of the kernel matrix
Training samples N Example One N × N matrix, single precision
1,000 80 years of monthly data 4 MB
4,096 Lorenz 63 TEST 67 MB
18,000 50 years of daily data 1.3 GB
30,000 80 years of daily data 3.6 GB
65,536 Lorenz 63 A100_EIGSH 17 GB
131,072 Lorenz 63 A100_EIGSH_2GPU 69 GB

The direct solver needs several such matrices at once, so plan for three to four times the figure in the table, plus the data. The iterative solver never stores the matrix; it needs memory for a few times N × num_eigs numbers, and recomputes kernel values instead.

Bandwidth tuning evaluates the kernel for every pair of samples at each trial bandwidth, so its cost grows with num_bandwidths × N² × the length of the delay vectors. For large N, use bandwidth_batch_size to limit memory, fewer trial bandwidths (for example 64), or coarser predictors. In double precision (FP = "f64") all memory figures double.

References

Das, S., and D. Giannakis. 2019. “Delay-Coordinate Maps and the Spectra of Koopman Operators.” Journal of Statistical Physics 175 (6): 1107–45. https://doi.org/10.1007/s10955-019-02272-w.