quantlab.model.predefined.mlp.MLPRegressor#
- class quantlab.model.predefined.mlp.MLPRegressor(config)[source]#
Bases:
QlibSequenceHeadQlib’s MLP benchmark model (
DNNModelPytorch) on rows.MLPNeton each cell’s latest bar. One epoch here is Qlib’seval_stepssteps: each step drawsbatch_sizetraining rows at random with replacement, and after every epoch the validation loss is computed,ReduceLROnPlateau(factor 0.5, patience 10, relative threshold 1e-4, lower bound 1e-5) steps on it, the epoch with the lowest one is kept, and training stops afterearly_stopepochs without a strictly lower one. The training target isCSRankNormof the label, the loss the MSE, the optimizer Adam with weight decay; gradients are not clipped, as in Qlib. Hyperparameters, with Qlib’s Alpha158 benchmark values (workflow_config_mlp_Alpha158.yaml) as defaults:layers([256]),act("LeakyReLU"),batch_size(8192),lr(2e-3),weight_decay(2e-4),eval_steps(20),epochs(400, Qlib’s 8000max_stepsover 20 steps an epoch) andearly_stop(50).window_barsis 1.Known differences from Qlib’s implementation:
the features are the model’s factors, and no
RobustZScoreNormis fitted on the training span: the default_transform_featureclips to ±3 and fills NaN with 0;the validation loss is averaged per bar, where Qlib pools every row;
the output has one column per label instead of one.
- Parameters:
- configModelConfig
Factors, labels, dates and hyperparameters.
Examples
>>> MLPRegressor(config).collect().train().name 'MLPRegressor_total.pth'
- DEFAULTS = {'act': 'LeakyReLU', 'batch_size': 8192, 'early_stop': 50, 'epochs': 400, 'eval_steps': 20, 'layers': [256], 'lr': 0.002, 'weight_decay': 0.0002, 'window_bars': 1}#
Every unset hyperparameter’s value; a head gives Qlib’s benchmark values.
- grad_clip_value = None#
Gradient value clip of the default
_train_one_batch; None disables.