trainer¶
- class fairdiverse.recommendation.trainer.RecTrainer(train_config)[source]¶
Bases:
object
- Set_Dataset(data_type, config, train_data_df, val_data_df, test_data_df)[source]¶
Initializes and returns the training, validation, and test datasets based on the specified data type and evaluation type.
This function creates appropriate dataset objects for training, validation, and testing based on the provided data type (point, pair, or sequential) and the evaluation type (CTR or ranking). It supports different dataset types for training and evaluation, and raises an error if an unsupported type is provided.
- Parameters:
data_type – The type of dataset to be used for training. Must be one of [‘point’, ‘pair’, ‘sequential’].
config – A configuration dictionary that contains parameters for dataset creation and evaluation type.
train_data_df – The DataFrame containing the training data.
val_data_df – The DataFrame containing the validation data.
test_data_df – The DataFrame containing the test data.
- Returns:
A tuple containing the training, validation, and test datasets.
- check_model_stage(config, Model)[source]¶
Checks if the provided data type in the configuration aligns with the supported model type.
This function verifies that the data type specified in the config dictionary is compatible with the model’s supported types. If the data type is not supported by the model, a ValueError is raised with an informative message.
- Parameters:
config – A configuration dictionary that includes the data type used for testing.
Model – The model class or object which has a type attribute specifying the supported data types.
- load_configs(dir)[source]¶
Loads and merges configuration files for the model, dataset, and evaluation.
This function loads multiple YAML configuration files, including the process configuration, dataset-specific settings, model configurations, and evaluation parameters. All configurations are merged, with the highest priority given to the class’s own config attribute.
- Parameters:
dir – The directory where the main process configuration file is located.
- Returns:
A dictionary containing the merged configuration from all files.