recbole.utils.utils¶
-
recbole.utils.utils.
calculate_valid_score
(valid_result, valid_metric=None)[source]¶ return valid score from valid result
- Parameters
valid_result (dict) – valid result
valid_metric (str, optional) – the selected metric in valid result for valid score
- Returns
valid score
- Return type
float
-
recbole.utils.utils.
dict2str
(result_dict)[source]¶ convert result dict to str
- Parameters
result_dict (dict) – result dict
- Returns
result str
- Return type
str
-
recbole.utils.utils.
early_stopping
(value, best, cur_step, max_step, bigger=True)[source]¶ validation-based early stopping
- Parameters
value (float) – current result
best (float) – best result
cur_step (int) – the number of consecutive steps that did not exceed the best result
max_step (int) – threshold steps for stopping
bigger (bool, optional) – whether the bigger the better
- Returns
float, best result after this step
int, the number of consecutive steps that did not exceed the best result after this step
bool, whether to stop
bool, whether to update
- Return type
tuple
-
recbole.utils.utils.
ensure_dir
(dir_path)[source]¶ Make sure the directory exists, if it does not exist, create it
- Parameters
dir_path (str) – directory path
-
recbole.utils.utils.
get_model
(model_name)[source]¶ Automatically select model class based on model name
- Parameters
model_name (str) – model name
- Returns
model class
- Return type
Recommender