finol.optimization_layer.ModelTrainer

class finol.optimization_layer.ModelTrainer(load_dataset_output)[source]

Class to train a machine learning model for portfolio selection.

Parameters:

load_dataset_output (Dict) – Dictionary containing output from function load_dataset().

Methods

plot_loss()

Plot the training and validation losses.

train_model()

Train the machine learning model using the specified dataset.

plot_loss()[source]

Plot the training and validation losses.

This method plots the average training and validation losses over epochs using matplotlib.

Returns:

None

Return type:

None

train_model()[source]

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.

Returns:

Dictionary containing the log directory for the trained model.

Return type:

Dict