Others
Data Manager
nazuna.data_manager.TimeSeriesDataManager
Manager for time-series data that handles loading and splitting.
Note on seq_len and pred_len
These parameters affect data splitting. When you specify a data range (e.g., 0.0-0.5 for training), the actual row indices depend on seq_len and pred_len. The actual sequence lengths used during evaluation or training can be shorter (specified in the criterion and model). E.g., for fair comparison across experiments with varying input lengths, set seq_len to the maximum value you plan to use.
__init__(path, colname_timestamp, seq_len, pred_len, white_list=None, step_start=0, step_width=1)
Parameters:
-
path(str) –Path to the CSV file.
-
colname_timestamp(str) –Column name for timestamps.
-
seq_len(int) –Input sequence length (affects data splitting).
-
pred_len(int) –Prediction sequence length (affects data splitting).
-
white_list(str | list[str] | None, default:None) –Column names to use. If None, all columns are used.
Batch Sampler
nazuna.batch_samplers.BatchSampler
A sampler that splits samples into batches in sequential order.
__init__(n_sample, batch_size)
Parameters:
-
n_sample(int) –Total number of samples.
-
batch_size(int) –Batch size.
nazuna.batch_samplers.BatchSamplerShuffle
Bases: BatchSamplerRandom
A sampler that shuffles samples and splits them into batches.
- At the start of each iteration, sample indices are shuffled, and batches are created based on the shuffled order.
__init__(n_sample, batch_size, seed=0)
Parameters:
-
n_sample(int) –Total number of samples.
-
batch_size(int) –Batch size.
-
seed(int, default:0) –Random seed.
Criteria
nazuna.criteria.MSE
Bases: BaseError
Mean Squared Error with channel and sequence weighting.
_setup(n_channel, pred_len, decay_rate=None, tolerance=0)
Parameters:
-
n_channel(int) –Number of channels in the prediction.
-
pred_len(int) –Length of the prediction sequence.
-
decay_rate(float | None, default:None) –Exponential decay rate for sequence weighting. If None or 1, uniform weights are used.
-
tolerance(float, default:0) –Errors below this threshold are treated as zero. Default is 0 (no tolerance).
Note
The weight for step i is decay_rate^i (before normalization). For example, if decay_rate=0.9, step 0 has weight 1.0, step 1 has 0.9, step 2 has 0.81, and so on.
nazuna.criteria.MAE
Bases: MSE
nazuna.criteria.ImprovementRate
Bases: BaseImprovement
Computes improvement rate over a baseline prediction.
Improvement rate = 1 - (pred_error / baseline_error) - Positive values indicate improvement over baseline - Zero indicates equal performance - Negative values indicate worse performance than baseline
_setup(n_channel, pred_len, decay_rate=None, tolerance=0, epsilon=1e-06, error_type='mae')
Parameters:
-
n_channel(int) –Number of channels in the prediction.
-
pred_len(int) –Length of the prediction sequence.
-
decay_rate(float | None, default:None) –Exponential decay rate for sequence weighting. If None or 1, uniform weights are used.
-
tolerance(float, default:0) –Errors below this threshold are treated as zero. Default is 0 (no tolerance).
-
epsilon(float, default:1e-06) –Small value to avoid division by zero.
-
error_type(str, default:'mae') –Type of error metric ("mse" or "mae").
forward(baseline, pred, true)
Parameters:
-
baseline–Baseline model prediction (batch_size, pred_len, n_channel)
-
pred–Model prediction to evaluate (batch_size, pred_len, n_channel)
-
true–Ground truth (batch_size, pred_len, n_channel)
Returns:
-
TimeSeriesError–Aggregated improvement rates