Training & Data

Guardrails & Training Reference

Understand the protections NeuraLib applies to time-series data, then choose activations, objectives, metrics, optimizers, and schedules that match your task.

Updated Publisher Alien_AlgorithmsPine Script v6

Built-in data guardrails

  • Invalid rows are rejected: wrong-width rows and rows containing na never enter a dataset.
  • Shape checks protect calls: forward, training, backward, and evaluation paths validate tensors before graph execution.
  • Train and validation remain separated: holdout extraction is chronological.
  • Scaler leakage is controlled: validation transforms use the training-side profile.
  • Rolling windows preserve time order: chronological reads remain correct even after ring-buffer wrapping.
Guardrails catch mechanics, not research assumptions
NeuraLib can reject a malformed row, but it cannot know that your feature definition contains future information or that your chosen target is economically meaningless.

Activations

nl.ActivationKind includes Linear, ReLU, Leaky ReLU, ELU, GELU Approx, Sigmoid, Tanh, Softplus, Swish, and Softmax.

FamilyTypical role
LinearRegression output or raw logits.
ReLU / Leaky ReLU / ELUEfficient hidden-layer nonlinearities.
GELU Approx / SwishSmooth nonlinearities for deeper or attention-style models.
SigmoidBinary probability output when the loss expects probabilities.
TanhBounded signed hidden state or output.
SoftmaxMulti-class probabilities; prefer a from-logits loss during training when available.

Losses

LossTypical use
MSE, MAE, Huber, LogCoshGeneral regression. Huber and LogCosh reduce sensitivity to large outliers.
Binary Cross EntropyTwo-class probability output.
Binary Cross Entropy From LogitsNumerically stable two-class raw-logit training.
Categorical Cross EntropyMulti-class probability output.
Softmax Cross Entropy From LogitsNumerically stable multi-class raw-logit training.
DirectionalFinance-oriented penalty for incorrect sign.
QuantileA chosen conditional quantile instead of the mean.
Multi-Horizon WeightedMultiple forecast horizons with explicit weights.
SharpeSharpe-style risk-adjusted objective.

Metrics

Metrics describe behavior without driving gradients. Available kinds include MAE, RMSE, Directional Accuracy, Binary Accuracy, Binary Accuracy From Logits, Categorical Accuracy, and Cosine Similarity.

Optimizers and schedules

Optimizers

sgd(), momentum(), rmsprop(), adam(), and adamW() cover simple through adaptive update rules.

Schedules

constantSchedule(), stepDecay(), cosineDecay(), and warmupCosine() control the current rate, which can be inspected with currentRate().

Choosing an objective

  • Match output activation and loss expectations: logits with from-logits losses, probabilities with probability losses.
  • Use robust regression losses when rare market moves dominate MSE.
  • Keep a human-readable metric alongside the training objective.
  • Compare against a simple baseline; lower loss is not automatically useful trading information.
NeuraLib is a machine-learning research runtime for Pine Script. Model output is not financial advice and does not guarantee future performance. © Alien_Algorithms.