Utilities
Data utilities
Recommenders.leave_one_out_split — Methodleave_one_out_split(table; col_user = :userid, col_time = :timestamp)Leave-one-out split for the input table. For each user, whose column is specifed by col_user, the items are sorted by col_time, and the last one is split into the test set. The others remain in the train set.
Returns
train_tabletest_table
Recommenders.ratio_split — Functionratio_split(table, train_ratio = 0.7)Split the table randomly, with the train set ratio specifed by train_ratio argument. Current implementaion assumes table object that can be converted to DataFrame.
Returns
train_tabletest_table
Callbacks
For models trained by Stochastic Gradient Descent (SGD), one can give callback functions to the fit! method. Callback is any callable (functions or callable structs) that takes model, train_loss, epoch and verbose as inputs. If StopTrain exception is raised by the callback, training loop stops before the completion.
Currently only the following callbacks are implemented
Recommenders.EvaluateValidData — TypeEvaluateValidData(valid_metric::MeanMetric, valid_table, early_stopping_rounds, name = "val_metric")Callback to monitor the validation metrics during training, and raise StopTrain exception if early stopping is requred.
Constructor arguments
valid_metric: monotring metric. See Evaluation metrics for the available ones.valid_table: anyTables.jl-compatible object for validation dataset.early_stopping_rounds: If the validation metric does not improve more than this epochs, the early stopping is invoked. If set to be less than 1, no early stopping is applied.name: metrics name to show on logger.
Example
Use in the matrix factorizaion training.
ndcg10 = MeanNDCG(10)
cb = EvaluateValidData(ndcg10, test_table, 1, "val_NDCG")
model = ImplicitMF(16, true, 0.01)
fit!(
model,
train_table,
10,
callbacks = [cb],
col_item = :movieid,
n_epochs = 20,
n_negatives = 1,
learning_rate = 0.01,
verbose = 1,
)