/// <summary>Find the the parameters resulting in the minimal results for a given evaluation measure using k-fold cross-validation</summary> /// <remarks>The recommender will be set to the best parameter value after calling this method.</remarks> /// <param name="evaluation_measure">the name of the evaluation measure</param> /// <param name="hyperparameter_name">the name of the hyperparameter to optimize</param> /// <param name="hyperparameter_values">the values of the hyperparameter to try out</param> /// <param name="recommender">the recommender</param> /// <param name="k">the number of folds to be used for cross-validation</param> /// <returns>the best (lowest) average value for the hyperparameter</returns> public static double FindMinimum(string evaluation_measure, string hyperparameter_name, double[] hyperparameter_values, RatingPrediction.RatingPredictor recommender, int k) { var data = recommender.Ratings; var split = new RatingCrossValidationSplit(data, k); double result = FindMinimum(evaluation_measure, hyperparameter_name, hyperparameter_values, recommender, split); recommender.Ratings = data; return(result); }
/// <summary>Find the the parameters resulting in the minimal results for a given evaluation measure (1D)</summary> /// <remarks>The recommender will be set to the best parameter value after calling this method.</remarks> /// <param name="evaluation_measure">the name of the evaluation measure</param> /// <param name="hp_name">the name of the hyperparameter to optimize</param> /// <param name="hp_values">the logarithms of the values of the hyperparameter to try out</param> /// <param name="basis">the basis to use for the logarithms</param> /// <param name="recommender">the recommender</param> /// <param name="split">the dataset split to use</param> /// <returns>the best (lowest) average value for the hyperparameter</returns> public static double FindMinimumExponential(string evaluation_measure, string hp_name, double[] hp_values, double basis, RatingPrediction.RatingPredictor recommender, ISplit <IRatings> split) { var new_hp_values = new double[hp_values.Length]; for (int i = 0; i < hp_values.Length; i++) { new_hp_values[i] = Math.Pow(basis, hp_values[i]); } return(FindMinimum(evaluation_measure, hp_name, new_hp_values, recommender, split)); }