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_loss()

Plot the training and validation losses.

train_model()

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