Tune function for a distance metric learning algorithm, allowing as metrics the algorithm metadata, times and k-NN scores.
tune(dml, X, y, dml_params, tune_args, metrics, n_folds = 5, n_reps = 1, verbose = FALSE, seed = NULL, ...)
X | array-like (N x d), training vector, where N is the number of samples, and d is the number of features. |
---|---|
y | array-like (N), labels vector, where N is the number of samples. |
dml_params | Additional keyword parameters for the distance metric learning algorithm, specified in a named list. |
tune_args | A named list woth the parameters of the DML algorithm to tune. Each key has to be a keyword argument of the DML. The associated values have to be lists containing all the desired values for the tuning parameters. |
n_folds | Number of folds for cross validation. |
n_reps | Number of cross validations to do. |
verbose | Boolean. If True, a console log will be printed. |
seed | Integer. The seed used by the random number generator |
... | Additional keyword arguments for k-NN. |
The | string with the name of the DML Algorithm to tune. Select it from the items in the list `dml`. |
The | metrics to evaluate. If string, it must be a key of the metadata() function of the DML Algorithm, or 'time'. In this last case, the elapsed fitting time will be returned as a metric. If int, the metric will be the k-NN score, where k is the specified int. |
A list with the following elements: - results: A dataframe whose entries are all the cases considered for the tune parameters, and with a single column that shows the cross validation score for each case. - best_performance: A pair with the best case obtained, together with its corresponding score. - best_dml: The DML Algorithm object that obtained the best result in the tuning. - detailed_results: A named list whose keys are all the possible cases, and each entry is the cross validation table for the corresponding case, containing the scores for every fold.