finol.optimization_layer.ModelTrainer¶
- class finol.optimization_layer.ModelTrainer(load_dataset_output)[源代码]¶
Class to train a machine learning model for portfolio selection.
- 参数:
load_dataset_output (Dict) – Dictionary containing output from function
load_dataset().
Methods
Plot the training and validation losses.
Train the machine learning model using the specified dataset.
- plot_loss()[源代码]¶
Plot the training and validation losses.
This method plots the average training and validation losses over epochs using matplotlib.
- 返回:
None
- 返回类型:
None
- train_model()[源代码]¶
Train the machine learning model using the specified dataset.
This method iterates over the specified number of epochs and trains the model using the training data. It calculates and stores the training and validation losses, saves the best model based on validation loss, and optionally plots the dynamic loss during training.
- 返回:
Dictionary containing the log directory for the trained model.
- 返回类型:
Dict